• Resolved sjumb

    (@sjumb)


    # 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

    ---

    ## Summary

    GdMethod::convert_image_to_output() throws ResolutionOversizeException for images larger

    than 8192px, but no catch block 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 cause

    src/Conversion/Method/GdMethod.php:199-200

    php<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 only catch on 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>

    ResolutionOversizeException is not listed. All exception classes extend ExceptionAbstract

    directly (a flat hierarchy), so it is not caught by inheritance either, and there is no catch

    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 same try and are equally

    absent from the catch list:

    | 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 FunctionUnavailableException and @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 server

    Imagick::queryformats( 'WEBP' ) returns an empty array (ImageMagick 6.9.10-68 built without

    WebP), so ImagickMethod::is_method_active() returns false and 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 what RemoteMethod.php:130 already 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 implements ExceptionInterface and each one represents a

    recoverable "skip this file" condition, catching the interface in LibraryMethodAbstract

    would close this class of bug for good rather than one exception at a time — and would make

    LibraryMethodAbstract consistent with RemoteMethod.

    ## Verification

    After adding ResolutionOversizeException to the catch clause, 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 quick CURLINFO_SIZE_DOWNLOAD_T fix in 6.6.3.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @sjumb,

    Thank you so much for taking the time to prepare such an amazingly detailed, well-researched, and thorough bug report! Reports of this quality are a absolute joy to read and make fixing issues so much easier.

    We have just released version 6.6.4, which includes a fix for this issue.

    Following your recommendation, we refactored the exception handling in LibraryMethodAbstract to catch ExceptionInterface instead of maintaining an explicit list of individual exception classes.

    As a result, images exceeding resolution limits (as well as any other image-level conversion exceptions) are now gracefully caught, logged as warnings, and skipped—preventing HTTP 500 fatal errors completely.

    Please update to 6.6.4 and let us know if everything works as expected on your setup. Thanks again for helping us make the plugin better!

    Best,
    Mateusz

    Thread Starter sjumb

    (@sjumb)

    Hi Mateusz,

    Thank you for the incredibly quick turnaround!

    I’ve updated to 6.6.4 and can confirm it works as expected on our setup.
    The oversized image is now skipped with a warning and the remaining files
    convert normally.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @sjumb, I’m glad I could help you! If you’re happy with the plugin and my support, I’d really appreciate it if you could leave a quick review on WordPress.org – it helps others and means a lot to me. You can add your review here:
    https://wordpress.org/support/plugin/webp-converter-for-media/reviews/

    Thanks a ton! Let me know if you ever need anything.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.