When processing pages for one of the WikiProjects, the script died with the following fatal error:
PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ServerException' with message 'Server error: `GET https://en.wikipedia.org/w/api.php?action=query&formatversion=2&format=json&titles=Kysyl-Yuryuyya&prop=redirects&rdlimit=500` resulted in a `503 Backend fetch failed` response: <!DOCTYPE html> <html lang=en> <meta charset=utf-8> <title>Wikimedia Error</title> <style> * { margin: 0; padding: 0; } (truncated...) ' in /mnt/nfs/labstore-secondary-tools-home/kaldari/popularpages/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:111 Stack trace: #0 /mnt/nfs/labstore-secondary-tools-home/kaldari/popularpages/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /mnt/nfs/labstore-secondary-tools-home/kaldari/popularpages/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /mnt/nfs/labstore-secondary-tools-home/kaldari/popularpages/ in /mnt/nfs/labstore-secondary-tools-home/kaldari/popularpages/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 111
Let's make sure the script has better exception handling so it can deal with server errors from the API. For example, we may want to put the API call for redirects (which isn't 100% vital) inside a try/catch block and just log the exception (or have it try again).