Problem/Motivation
follow up to https://www.drupal.org/project/imagemagick/issues/3401093
Error: Typed property Drupal\imagemagick\Plugin\ImageToolkit\ImagemagickToolkit::$width must not be accessed before initialization in Drupal\imagemagick\Plugin\ImageToolkit\ImagemagickToolkit->getWidth() (line 633 of /var/www/html/web/modules/contrib/imagemagick/src/Plugin/ImageToolkit/ImagemagickToolkit.php).
Steps to reproduce
Not sure at all. We are using custom tokens, that replace file_entity ids and render responsive images from it.
btw: on drupal 10.1, php 8.1
Proposed resolution
Change the class property definition back to its state before the latest release.
| Comment | File | Size | Author |
|---|
Issue fork imagemagick-3408403
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
mondrakeWe need to fix this and push out a new release. I'd definitely would like to have some test coverage for the case when this property is accessed not being initialized yet, need to figure out the case.
Comment #4
mondrake@axroth I wouldn't like to revert the typehinting, rather ensure the case of uninitialized property be gracefully handled in the getters. See MR. We need test coverage, though.
Comment #5
axroth commented@mondrake absolutely! Like your solution. For tests I cannot help I think.
Comment #6
mondrakeIs anybody able to post at least a full backtrace?
Comment #7
rakesh.nimje84@gmail.com commentedMerge request !21 changes are working like a charm!
Comment #9
mondrakeOK, so this definitely happens if the toolkit parses an invalid image, and
::getWidth()is called without prior checking::isValid(), which should not happen in theory. But as someone said,Waiting for RTBC by someone that has had the issue before committing and pushing a release, thanks.
Comment #10
mondrakeComment #11
mistrae commentedCan confirm the error disappear with this MR
Comment #13
mondrakeThanks