Opened 5 months ago
Last modified 2 months ago
#63932 new defect (bug)
Investigate failing Imagick tests on PHP 8.3 and 8.4
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Media | Keywords: | has-patch has-unit-tests |
| Focuses: | Cc: |
Description
Background: #63876
Fixing the self-signed MySQL certificate issue in the PHP 8.3 and 8.4 container images that are based on Debian Trixie surfaces two errors and two failures in the Imagick tests.
Failing GitHub Actions workflow run can be found here.
There were 2 errors: 1) Tests_Image_Editor_Imagick::test_image_max_bit_depth ImagickException: no encode delegate for this image format `AVIF' @ error/constitute.c/WriteImage/1412 /var/www/tests/phpunit/tests/image/editorImagick.php:726 /var/www/vendor/bin/phpunit:122 2) Test_Image_Resize_Imagick::test_resize_avif TypeError: getimagesize(): Argument #1 ($filename) must be of type string, WP_Error given /var/www/src/wp-includes/media.php:5736 /var/www/tests/phpunit/tests/image/resize.php:107 /var/www/vendor/bin/phpunit:122
There were 2 failures:
1) Tests_Image_Editor_Imagick::test_resizes_are_small_for_16bit_images with data set "test8" ('/var/www/tests/phpunit/includ...t8.png')
The resized image file size is not smaller than the original file size.
Failed asserting that 99853 is less than 45231.
/var/www/tests/phpunit/tests/image/editorImagick.php:794
/var/www/vendor/bin/phpunit:122
2) Tests_Image_Editor_Imagick::test_png_color_type_is_preserved_after_resize with data set "test8_color_type_3" ('/var/www/tests/phpunit/includ...t8.png', 3)
The PNG original color type should be preserved after resize for /var/www/tests/phpunit/includes/../data/images/png-tests/test8.png.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'3'
+'4'
/var/www/tests/phpunit/tests/image/editorImagick.php:848
/var/www/vendor/bin/phpunit:122
In addition a risky test was flagged which also covers AVIF handling. It may or may not be related and should be investigated.
There was 1 risky test: 1) Tests_Media::test_quality_with_avif_conversion_file_sizes This test did not perform any assertions /var/www/tests/phpunit/tests/media.php:5473 /var/www/vendor/bin/phpunit:122
Change History (28)
This ticket was mentioned in PR #9749 on WordPress/wordpress-develop by @johnbillion.
5 months ago
#1
- Keywords has-patch has-unit-tests added
#2
follow-up:
↓ 5
@
5 months ago
- Keywords has-patch has-unit-tests removed
@johnbillion for the first two, it seems that AVIF is supported in the new ImageMagick version, but no is not being added as a delegate
https://www.imagemagick.org/discourse-server/viewtopic.php?p=161544&sid=fc7993f28ef8acbc600eb4e4996d8133#p161544
Wonder if it was not skipping these two tests before, and never been tested.
About the other two tests, looks like a new version in ImageMagick. I wrote those tests some months ago and I remember we were having trouble with that topic because Imagick was inconsistent among versions.
Do you remember, @siliconforks? I will take a look tomorrow to see those inconsistencies with the color types, they were a headache (wonder if they have changed the codes in the new ImageMagick version).
For the last one skipped, the same as the first two. It seems that its not being skipped, but probably the sizes_to_compare array is empty leading into 0 tests.
#4
@
5 months ago
Noting that the version of ImageMagick on the passing tests is 6.9.11-60 while the version in the failing version is 7.1.1-43. https://imagemagick.org/script/porting.php#imv7 has some information on the move from 6 to 7 and might help identify some things that could help here.
#5
in reply to:
↑ 2
@
5 months ago
Replying to SirLouen:
About the other two tests, looks like a new version in ImageMagick. I wrote those tests some months ago and I remember we were having trouble with that topic because Imagick was inconsistent among versions.
Do you remember, @siliconforks? I will take a look tomorrow to see those inconsistencies with the color types, they were a headache (wonder if they have changed the codes in the new ImageMagick version).
Well, the problem is presumably with ImageMagick version 7 (as noted in this comment), but I've never used that version so I don't know what the problem is.
I just ran all of the above tests on a machine with Ubuntu 24.04, which has PHP 8.3 but with ImageMagick 6.9, and all 5 tests are passing.
#6
@
5 months ago
@johnbillion this is my proposal for now
- Keeping back ImageMagick 7 for now
https://github.com/WordPress/wpdev-docker-images/pull/184/
- Create a new ticket to solve all the ImageMagick 7. I thought it was a single problem, but this is widespread. This may take time, there are major breaking changes that might need time in several places.
This ticket was mentioned in PR #9775 on WordPress/wordpress-develop by @siliconforks.
5 months ago
#7
Trac ticket: https://core.trac.wordpress.org/ticket/63932
#8
follow-up:
↓ 9
@
5 months ago
PR #9775 is intended as a suggested (partial) alternative to PR #9749 for the PNG-related failing tests.
This PR has the following advantages:
- It checks the ImageMagick version rather than the PHP version because it is really ImageMagick version 7 that is the problem.
- It only skips the one data file that is causing test failures (test8.png). The other data files should work fine with ImageMagick 7.
Note that this PR addresses only the PNG-related failing tests and not the AVIF-related ones, because I don't think the AVIF failures are caused by ImageMagick 7 (I suspect that the problem with those is something else).
#9
in reply to:
↑ 8
;
follow-up:
↓ 10
@
5 months ago
Replying to siliconforks:
- It checks the ImageMagick version rather than the PHP version because it is really ImageMagick version 7 that is the problem
I've been trying to figure out the changes regarding alpha and greyscale in IM7 but have not been able to get to a nice conclusion. Do you think its totally impossible now to compress greyscale alpha-1 images?
#10
in reply to:
↑ 9
@
5 months ago
Replying to SirLouen:
I've been trying to figure out the changes regarding alpha and greyscale in IM7 but have not been able to get to a nice conclusion. Do you think its totally impossible now to compress greyscale alpha-1 images?
I'm not sure - ImageMagick 7 changed a lot of things so it's difficult to tell whether it's still possible to get the information needed from the public API.
I've created a post in the ImageMagick discussions in an attempt to get some clarification on this:
https://github.com/ImageMagick/ImageMagick/discussions/8348
@siliconforks commented on PR #9775:
4 months ago
#11
I think I prefer the approach used in #9749 since it makes use of an official annotation in PHPUnit .
The problem with PR #9749 is that it will skip the tests test_resizes_are_small_for_16bit_images and test_png_color_type_is_preserved_after_resize on a system with PHP 8.3 or 8.4 and ImageMagick 6. But there's no need for this - the tests pass on that system. (I've tested this on Ubuntu 24.04 LTS, which has PHP 8.3 and ImageMagick 6.)
I would guess that the reverse problem can happen too (although I have not tested this) - you could have a system with PHP 8.2 (or an earlier version) and ImageMagick 7, and then the tests would fail.
4 months ago
#12
The problem with https://github.com/WordPress/wordpress-develop/pull/9749 is that it will skip the tests test_resizes_are_small_for_16bit_images and test_png_color_type_is_preserved_after_resize on a system with PHP 8.3 or 8.4 and ImageMagick 6. But there's no need for this - the tests pass on that system. (I've tested this on Ubuntu 24.04 LTS, which has PHP 8.3 and ImageMagick 6.)
I know it's good to test as many combinations as possible, but are there actually any documented differences between how ImageMagick 6.x works on PHP 7.2-8.0 that would be inconsistent with PHP >= 8.1?
I would guess that the reverse problem can happen too (although I have not tested this) - you could have a system with PHP 8.2 (or an earlier version) and ImageMagick 7, and then the tests would fail.
The commit that changed the underlying base image for the official PHP images was made to PHP 8.1-8.5. The 8.1 & 8.2 containers have not yet been rebuilt and published because that only happens when an update is released for that version of PHP. 8.1 & 8.2 are currently only receiving security updates, so it's not known when (or if) a new build will be published. But when that does happen, the base image will then be the same as the 8.3 & 8.4 ones currently with ImageMagick 7.
@siliconforks commented on PR #9775:
4 months ago
#13
I know it's good to test as many combinations as possible, but are there actually any documented differences between how ImageMagick 6.x works on PHP 7.2-8.0 that would be inconsistent with PHP >= 8.1?
Probably not.
The commit that changed the underlying base image for the official PHP images was made to PHP 8.1-8.5. The 8.1 & 8.2 containers have not yet been rebuilt and published because that only happens when an update is released for that version of PHP. 8.1 & 8.2 are currently only receiving security updates, so it's not known when (or if) a new build will be published. But when that does happen, the base image will then be the same as the 8.3 & 8.4 ones currently with ImageMagick 7.
That's basically the sort of situation my PR is intended to address. If you have a system with PHP 8.1 or 8.2 and ImageMagick 6, but you later update ImageMagick to version 7, the code will detect that (because it just checks the ImageMagick version) and skip the problematic tests.
@johnbillion commented on PR #9775:
4 months ago
#14
I've merged this into #9749, thanks. Happy to use an exclusion which is more targeted, and hopefully it won't be in place for long.
@johnbillion commented on PR #9749:
4 months ago
#16
#25
follow-up:
↓ 26
@
3 months ago
I'd like to check the status of this ticket. Are the remaining tasks to fix the tests on the trunk branch, specifically 6.9?
#26
in reply to:
↑ 25
;
follow-up:
↓ 27
@
3 months ago
Replying to wildworks:
I'd like to check the status of this ticket. Are the remaining tasks to fix the tests on the trunk branch, specifically 6.9?
They are already merged in trunk and backported, not sure why it's still open
cc @desrosj
#27
in reply to:
↑ 26
@
3 months ago
Replying to SirLouen:
Replying to wildworks:
I'd like to check the status of this ticket. Are the remaining tasks to fix the tests on the trunk branch, specifically 6.9?
They are already merged in trunk and backported, not sure why it's still open
cc @desrosj
The tests have been disabled for the specific platform that was having problems (with ImageMagick 7), so they are no longer failing, but the underlying issue is still there.
That's probably not something that's going to get resolved before WordPress 6.9 is released, though.
This temporarily disables failing Imagick tests prior to investigation.
Adds some missing
WP_Errorassertions too which means an error will be a failure instead.Branches from #9746