diff options
author | Tim Starling <tstarling@wikimedia.org> | 2022-02-01 12:11:09 +1100 |
---|---|---|
committer | Tim Starling <tstarling@wikimedia.org> | 2022-02-02 16:27:44 +1100 |
commit | ca71e69fc6fc4b6a90a961136c2c4b4c5e0ac792 (patch) | |
tree | 882507cdf7ae7668867b733db9a800c2c8910c86 /includes/media/SvgHandler.php | |
parent | 16d1a8197ebc7e247689e6696160dd7e63f1117a (diff) | |
download | mediawikicore-ca71e69fc6fc4b6a90a961136c2c4b4c5e0ac792.tar.gz mediawikicore-ca71e69fc6fc4b6a90a961136c2c4b4c5e0ac792.zip |
Try not to discard Excimer timeout exceptions
Don't catch and discard exceptions from the RequestTimeout library,
except when the exception is properly handled and the code seems to be
trying to wrap things up.
In most cases the exception is rethrown. Ideally it should instead be
done by narrowing the catch, and this was feasible in a few cases. But
sometimes the exception being caught is an instance of the base class
(notably DateTime::__construct()). Often Exception is the root of the
hierarchy of exceptions being thrown and so is the obvious catch-all.
Notes on specific callers:
* In the case of ResourceLoader::respond(), exceptions were caught for API
correctness, but processing continued. I added an outer try block for
timeout handling so that termination would be more prompt.
* In LCStoreCDB the Exception being caught was Cdb\Exception not
\Exception. I added an alias to avoid confusion.
* In ImageGallery I added a special exception class.
* In Message::__toString() the rationale for catching disappears
in PHP 7.4.0+, so I added a PHP version check.
* In PoolCounterRedis, let the shutdown function do its thing, but
rethrow the exception for logging.
Change-Id: I4c3770b9efc76a1ce42ed9f59329c36de04d657c
Diffstat (limited to 'includes/media/SvgHandler.php')
-rw-r--r-- | includes/media/SvgHandler.php | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/includes/media/SvgHandler.php b/includes/media/SvgHandler.php index e0469f065db6..21bc53f8db85 100644 --- a/includes/media/SvgHandler.php +++ b/includes/media/SvgHandler.php @@ -23,6 +23,7 @@ use MediaWiki\MediaWikiServices; use MediaWiki\Shell\Shell; +use Wikimedia\RequestTimeout\TimeoutException; use Wikimedia\ScopedCallback; /** @@ -415,6 +416,8 @@ class SvgHandler extends ImageHandler { try { $svgReader = new SVGReader( $filename ); $metadata += $svgReader->getMetadata(); + } catch ( TimeoutException $e ) { + throw $e; } catch ( Exception $e ) { // @todo SVG specific exceptions // File not found, broken, etc. $metadata['error'] = [ |