Problem/Motivation
Drupal version affected is 11.2.1.
Drupal core fills the logs with PHP warnings if the AVIF codec is not available.
Full message:
Warning: imageavif(): avif error - Could not encode image: No codec available\n in /path/to/drupal/web/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php line 565 (Drupal\\Core\\Entity\\EntityStorageException)"
It's only a warning, but it's annoying and resource consuming, and broke our test suite. :-)
Steps to reproduce
Install Drupal on a machine that doesn't have the necessary AVIF support (Debian 11 is an easy way to test), make an image upload field, upload an image, check the logs.
Steps to reproduce
Proposed resolution
Suppress the warning from the avif support check. This won't be fixed in PHP in the near future: https://bugs.php.net/bug.php?id=81217
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Comments
Comment #2
quietone commentedIf this problem was discovered on a version of Drupal that is not 11.x, add that information in the issue summary and leave the version at 11.x. In Drupal core changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies. Also mentioned on the version section of the list of issue fields documentation. Thanks.
Comment #3
greg.harveyComment #4
greg.harveyDone, thank you.
Comment #7
nicrodgersWe were experiencing this php warning in our behat test suite after upgrading from 11.x to 11.2
It's caused by a combination of old linux system (in this case, Debian 11) and PHP misbehaving.
On affected systems, you can reproduce the error by running
As you can see, php thinks it has avif support because it's returning true (you can also see this in the phpinfo output within the gd section) but the reality is that it's unable to create avif files because the codec is missing and gives that warning.
There's a bug on php.net for it:
https://bugs.php.net/bug.php?id=81217
The php bug has been closed as not a PHP bug - they say:
Personally I think the php team are being dismissive here. Clearly it is a bug that could be better handled in php, because on the one hand php is saying YES, AVIF is supported here, and then on the other, when you try to use it it errors out because the codec is missing. But we are where we are.
For Drupal, I think the easy fix here is to suppress the warning from the imageavif() command within checkAvifSupport(). The function correctly returns FALSE on the affected systems so I think it's fine to suppress the php warning.
Comment #8
smustgrave commentedTemped to tag for tests but don't know what they would be, but summary still needs to be updated please.
Comment #9
swentel commentedHmm, more or less related or not? We're getting "AVIF image support has been disabled" in our logs, which seems to be a warning from PHP. cf https://bugs.php.net/bug.php?id=81217
Status page at Drupal does say it's supported: Supported image file formats: GIF, JPEG, PNG, WEBP, AVIF
Kind of annoying the watchdog is now being filled with these logs. Not sure what approach is best here for better testing it will actually work :)
Comment #10
mstrelan commentedI think this is one of those cases where we are better off just getting the bug fixed rather than trying to work out how to test it. Updated proposed resolution.
Comment #11
smustgrave commentedthat's fair, then this should be straight forward.
Comment #12
catchAgreed we don't need tests here, however I think we should add an inline comment above this line explaining why we're suppressing the error with a link to the php bug report to make it easier for someone to figure out why we're doing it.
Comment #13
nicrodgersI've added an inline comment as per @catch's suggestion above.
Comment #14
smustgrave commentedfeedback appears to be addressed.
Comment #17
catchCommitted/pushed to 11.x and cherry-picked to 11.2.x, thanks!