Problem/Motivation
Call to undefined function Drupal\system\Plugin\ImageToolkit\imageavif() in Drupal\system\Plugin\ImageToolkit\GDToolkit::checkAvifSupport() (line 565 of web/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php)
Using Drupal 11.2.0-beta1 with only a few contrib modules that are not using the ImageToolkit.
Steps to reproduce
Edit or create a user:
/admin/people/create
/user/edit
or
/user/1/edit
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3526690
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:
- 3526690-call-to-undefined
changes, plain diff MR !12254
Comments
Comment #2
xmacinfoIt also affects user creation.
Comment #3
xmacinfoPHPStorm finds the GD file with the proper function:
/Applications/PhpStorm.app/Contents/plugins/php-impl/lib/php.jar!/stubs/gd/gd.phpI tried clearing the cache a few times to no luck.
Using PHP Version 8.4.6 or PHP 8.3.16, Drupal Status Report PHP info has:
GD Support enabled
GD Version bundled (2.1.0 compatible)
Comment #4
ishani patel commentedHello,
I've followed the steps and checked with D11.1.6, and using PHP Version 8.3.19
But not reproduce the issue.
Thank you!
Comment #5
mstrelan commentedYou somehow have a php build that is missing the global imageavif function. What happens if you modify that line 565 to
$supported = function_exists('imageavif') && imageavif(imagecreatetruecolor(1, 1), $tempFile, 0, 10) && fstat($tempFile)['size'] > 0;Comment #6
cilefen commentedI linked to this issue from #3202016: Let GDToolkit support AVIF image format. Yes it seems like Drupal should check whether the function exists before calling it.
Comment #7
andypostNot clear how it possible to by-pass guard
function_exists('imageavif')maybe this function exists but disabled somehowComment #8
cilefen commentedI may be misunderstanding your comment but in Drupal there is not a
function_existscheck forimageavif.Comment #9
xmacinfo@ishani patel The bug affect only Drupal 11.2.x, not Drupal 11.1.x.
Comment #10
cilefen commentedComment #12
grimreaperHi,
I am encountering the same fatal error on an env without AVIF support.
On status report page, there is a warning about the missing AVIF support but this does not prevent the fatal error.
Comment #13
mondrakeGiven that #3524206: Use avif with webp fallback for all core image styles has practically made AVIF the default for 11.2, I think this will be Critical in case PHP is not binding the avif functions.
Comment #14
mondrakeComment #15
xmacinfo@grimreaper
Indeed, now I see the status message error message:
Not sure why I was not seeing this yesterday.
Comment #16
xmacinfoMy development stack will not support AVIF for the foreseeable future. Fortunately, my production stack supports AVIF.
AVIF Support enabledSo, we need to make sure the fallback to WEBP works on all user create/edit paths:
admin/people/create/user/editor
/user/1/editComment #17
andypostThis guard is required
Comment #18
xmacinfoYes, but I do not see a fallback to WEBP.
Are we returning FALSE instead of falling back to WEBP?
Comment #19
andypostComment #20
andypost@xmacinfo this method is for detection, see the commit from #3524206: Use avif with webp fallback for all core image styles
Comment #21
mstrelan commented@xmacinfo this function is just a check to see if avif is supported. It is called by GDToolkit::supportedTypes and if it returns FALSE then we don't include avif as a supported type. The
image_convert_avifplugin checks if avif is supported and creates an avif if it is, and a webp (or whatever else you configure) if not. Agree with the RTBC but would be good for @xmacinfo or @grimreaper to confirm it works with this patch.Comment #22
grimreaperHi,
I confirm the fix and RTBC on an environment without AVIF support, no more fatal error when displaying a form with an image field like /media/add/image
Thanks!
Comment #25
catchCommitted/pushed to 11.x and cherry-picked to 11.2.x, thanks!
Comment #28
damien laguerre commentedI get a warning message after installing the 11.2:
Debian 11 / PHP8.3.
GD library Version => 2.3.3
Comment #29
damien laguerre commentedI suggest adding an "@"
Comment #30
mondrake@damien laguerre would you kindly open a new issue for that, and link it here? This issue is closed and unlikely to be reopened.
Comment #31
greg.harveyI made a new issue here. #3532792: avif error - Could not encode image: No codec available