GDToolkit::load() doesn't check value, returned from executing $function

Created on 1 March 2024, 4 months ago

Problem/Motivation

Drupal version is 10.2.3, PHP is 8.2.
Function, called inside GDToolkit::load() may return FALSE in case of error. System checks execution with try/catch, but doesn't check, if $image is not FALSE. This leads to the error TypeError: Drupal\system\Plugin\ImageToolkit\GDToolkit::setImage(): Argument #1 ($image) must be of type ?GdImage, bool given, called in /web/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php on line 284 in Drupal\system\Plugin\ImageToolkit\GDToolkit->setImage() (line 201 of /web/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php)..

Steps to reproduce

I don't have exact steps to reproduce, because locally I can get error only if I hacking code in order to raise such situation.

Proposed resolution

Add checking for boolean result of the function.

Remaining tasks

provide MR/patch, review, give feedback, merge if possible.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
Image systemΒ  β†’

Last updated about 23 hours ago

Created by

πŸ‡·πŸ‡ΊRussia ilya.no

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024