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.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3424941-6.patch | 838 bytes | tormi |
| #2 | 3424941-2.patch | 807 bytes | ilya.no |
Issue fork drupal-3424941
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
ilya.no commentedAttaching initial patch.
Comment #3
smustgrave commentedThanks for reporting.
Will need a failing test to show the issue as next steps
Comment #4
plachInstead of duplicating this logic, why don't we just set
$imagetoFALSEin thecatchbranch?Comment #6
tormiI followed platch's suggestion in #4, also created a separate static patch, didn't change the status (no tests yet).
Comment #7
tormiHere's my stack trace from local environment.
The size of the `public://images-2024-09/IG-post_Foli-kumppani (1).png` is 18MB and `createDerivative` fails because of this - there's no derivate in https://xxx.lndo.site/sites/default/files/styles/medium/public/images-20...
The website encountered an unexpected error. Try again later.
And here's the image creation failure stack trace:
This might be related to https://www.drupal.org/project/drupal/issues/3261924
Comment #8
tormiOkay, this did the trick for me:
max_filesize: '10 MB'.