Security update for Core, with self-updated composer
[yaffs-website] / vendor / psy / psysh / src / Psy / VersionUpdater / GitHubChecker.php
index 520d7c5be037d1a9d9540aede6c151d9807a10f7..5ac6969dda8b62d05407364a772b1f920ac19dda 100644 (file)
@@ -68,8 +68,22 @@ class GitHubChecker implements Checker
      */
     public function fetchLatestRelease()
     {
-        $context = stream_context_create(array('http' => array('user_agent' => 'PsySH/' . Shell::VERSION)));
+        $context = stream_context_create(array(
+            'http' => array(
+                'user_agent' => 'PsySH/' . Shell::VERSION,
+                'timeout'    => 3,
+            ),
+        ));
 
-        return json_decode(@file_get_contents(self::URL, false, $context));
+        set_error_handler(function () {
+            // Just ignore all errors with this. The checker will throw an exception
+            // if it doesn't work :)
+        });
+
+        $result = @file_get_contents(self::URL, false, $context);
+
+        restore_error_handler();
+
+        return json_decode($result);
     }
 }