Bug report: Uncaught `ResolutionOversizeException`
-
# Bug report: Uncaught</strong><strong>ResolutionOversizeException</strong><strong>causes a fatal error (HTTP 500)
**Plugin:** WebP Converter for Media
**Version:** 6.6.2 and 6.6.3 (still present in the latest release)
**Environment:** WordPress 7.0.2 / PHP 8.5.5 (fpm-fcgi) / conversion method: GD (bundled 2.1.0), shared hosting
---
## SummaryGdMethod::convert_image_to_output()throwsResolutionOversizeExceptionfor images larger
than 8192px, but nocatchblock anywhere in the plugin handles it. The exception escapes as
a fatal error, so a single oversized image in the Media Library breaks conversion entirely.
## What happens
Running a bulk regeneration from the settings screen returns:<br><br>500 - (https://example.com/wp-json/webp-converter/v1/regenerate/)<br><br>
The REST response carries no message, so the cause is invisible from the admin UI. Running the
plugin's own WP-CLI command reveals it:<br><br>PHP Fatal error: Uncaught WebpConverter\Exception\ResolutionOversizeException:<br><br> Image is larger than maximum 8K resolution: ".../uploads/2024/05/example.jpg"<br><br> in .../src/Conversion/Method/GdMethod.php:200<br><br>
## Root causesrc/Conversion/Method/GdMethod.php:199-200php<br><br>} elseif ( ( imagesx( $image ) > 8192 ) || ( imagesy( $image ) > 8192 ) ) {<br><br> throw new ResolutionOversizeException( $source_path );<br><br>src/Conversion/Method/LibraryMethodAbstract.php:54-61— the onlycatchon this path:php<br><br>} catch ( OutputPathException $e ) {<br><br> $this->save_conversion_error( $e->getMessage(), $plugin_settings );<br><br>} catch ( SourcePathException|FilesizeOversizeException|ImageInvalidException $e ) {<br><br> $this->save_conversion_error( $e->getMessage(), $plugin_settings );<br><br> $this->skip_crashed->create_crashed_file( $output_path );<br><br>} catch ( LargerThanOriginalException $e ) {<br><br> return;<br><br>}<br><br>ResolutionOversizeExceptionis not listed. All exception classes extendExceptionAbstract
directly (a flat hierarchy), so it is not caught by inheritance either, and there is nocatch
higher up the stack —MethodIntegrator::convert_paths()does not wrap the call.
Every other "skip this file" condition degrades gracefully into a warning. This one does not.
## The same gap affects other exceptions on this path
Found by inspection, not reproduced — but they are thrown inside the sametryand are equally
absent from thecatchlist:
| Exception | Thrown at | Trigger |
|---|---|---|
|ResolutionOversizeException|GdMethod.php:200| image over 8192px **(reproduced)** |
|ImageAnimatedException|GdMethod.php:91| animated GIF |
|ConversionErrorException|GdMethod.php:202,ImagickMethod.php:165| encoder failure |
|FunctionUnavailableException|GdMethod.php:99,154,159,167,172,198| missing GD function |
|ExtensionUnsupportedException|GdMethod.php:106,ImagickMethod.php:92| unsupported extension |
|ImagickUnavailableException|ImagickMethod.php:90| Imagick missing |
|ImagickNotSupportWebpException|ImagickMethod.php:146| Imagick without WebP |
Notably,GdMethod::convert_image_to_output()documents@throws ConversionErrorException,@throws FunctionUnavailableExceptionand@throws ResolutionOversizeException, yet none of
the three is caught.
## Why there is no user-side workaround
Switching to Imagick would avoid GD's 8192px limit, but on this serverImagick::queryformats( 'WEBP' )returns an empty array (ImageMagick 6.9.10-68 built without
WebP), soImagickMethod::is_method_active()returnsfalseand the plugin correctly disables
that option. On shared hosting ImageMagick cannot be rebuilt.
So on any server with GD-only WebP support, one oversized image makes the endpoint return 500
with no way to recover from the settings screen. We are currently patching the plugin file
after every update, which is obviously not sustainable.
## Suggested fix
Minimal — add the exception to the existing clause:php<br><br>} catch ( SourcePathException|FilesizeOversizeException|ImageInvalidException|ResolutionOversizeException $e ) {<br><br>
Preferable — catch the whole family, which is whatRemoteMethod.php:130already does:php<br><br>} catch ( ExceptionInterface $e ) {<br><br> $this->save_conversion_error( $e->getMessage(), $plugin_settings );<br><br>}<br><br>
Since every plugin exception implementsExceptionInterfaceand each one represents a
recoverable "skip this file" condition, catching the interface inLibraryMethodAbstract
would close this class of bug for good rather than one exception at a time — and would makeLibraryMethodAbstractconsistent withRemoteMethod.
## Verification
After addingResolutionOversizeExceptionto thecatchclause, the same run completes
normally:<br><br>Warning: Image is larger than maximum 8K resolution: ".../example.jpg"<br><br>Success: ...<br><br>Converted files: 2<br><br>Failed or skipped: 1<br><br>EXIT=0<br><br>
The oversized file is skipped with a warning, and the remaining images convert as expected.
Thank you for the plugin — and for the quickCURLINFO_SIZE_DOWNLOAD_Tfix in 6.6.3.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.