From 57abdc8baa3c70e17a42b6b671b641182a138417 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 23 Apr 2019 10:04:33 +0200 Subject: [PATCH] static/gravatar: Don't respond with a 500 in case of a connection error --- application/controllers/StaticController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/application/controllers/StaticController.php b/application/controllers/StaticController.php index 57e7ce513..3667ef67f 100644 --- a/application/controllers/StaticController.php +++ b/application/controllers/StaticController.php @@ -52,7 +52,11 @@ class StaticController extends Controller return; } - $img = file_get_contents('http://www.gravatar.com/avatar/' . $filename . '?s=120&d=mm'); + $img = @file_get_contents('http://www.gravatar.com/avatar/' . $filename . '?s=120&d=mm'); + if ($img === false) { + $this->httpNotFound('Unable to connect to gravatar.com'); + } + $cache->store($cacheFile, $img); $response->setHeader('ETag', sprintf('"%s"', $cache->etagForCachedFile($cacheFile)));