]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
robustness fix
authorJoey Hess <joey@kitenet.net>
Wed, 30 Mar 2011 14:54:24 +0000 (10:54 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 30 Mar 2011 14:54:24 +0000 (10:54 -0400)
Don't fail if libravatar fails for some reason. Reasons I can think
of:

* too old version to do openid lookups (fall back to email lookup)
* network problem perhaps

IkiWiki/Plugin/comments.pm

index df20e7b966434701b32800c232b000e7826dc20c..fcce6c5a6d131193a2a3b2932dc5a3b5778b0b66 100755 (executable)
@@ -189,13 +189,18 @@ sub preprocess {
                        $commentauthor = $commentuser;
                }
 
-               eval 'use Libravatar::URL';
+               eval q{use Libravatar::URL};
                if (! $@) {
                        if (defined $commentopenid) {
-                               $commentauthoravatar = libravatar_url(openid => $commentopenid, https => $ENV{HTTPS});
+                               eval {
+                                       $commentauthoravatar = libravatar_url(openid => $commentopenid, https => $ENV{HTTPS});
+                               }
                        }
-                       elsif (my $email = IkiWiki::userinfo_get($commentuser, 'email')) {
-                               $commentauthoravatar = libravatar_url(email => $email, https => $ENV{HTTPS});
+                       if (! defined $commentauthoravatar &&
+                           (my $email = IkiWiki::userinfo_get($commentuser, 'email'))) {
+                               eval {
+                                       $commentauthoravatar = libravatar_url(email => $email, https => $ENV{HTTPS});
+                               }
                        }
                }
        }