Opened 7 weeks ago
Last modified 7 weeks ago
#63990 new defect (bug)
`Tests_Media::test_quality_with_avif_conversion_file_sizes` sometimes runs with GD
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Media | Keywords: | has-patch has-unit-tests |
| Focuses: | tests | Cc: |
Description
Tests_Media::test_quality_with_avif_conversion_file_sizes was added in [59247] (#61614) to confirm a specific edge case when editing AVIF images with Imagick is not reintroduced.
However, because _wp_image_editor_choose() tests each editor class and returns the first one with support for AVIF, the test can run using GD instead of Imagick when only GD supports the file format.
Change History (5)
This ticket was mentioned in PR #9921 on WordPress/wordpress-develop by @desrosj.
7 weeks ago
#1
- Keywords has-unit-tests added
@adamsilverstein commented on PR #9921:
7 weeks ago
#2
In the current location (the Tests_Media class), a specific image editor is not enforced, so the test can fall back to using GD when Imagick is not compiled with AVIF support.
That is the desired behavior: run the test using GD as long as it supports AVIF. Moving this test means it won't run against GD, but it should be able to run against and pass under GD (as long as AVIF support is available), right?
7 weeks ago
#3
My original understanding was that the test was confirming a specific edge case in Imagick no longer occurred. But it makes more sense that the intention was to allow both to be tested.
As it's currently running, the test will never run for GD when Imagick supports AVIF because the first editor with support for the format is used. This PR is the wrong approach now that I better understand the intent of the test.
Would it make sense to ensure that this test runs for _both_ Imagick and GD, and then possibly a third time where the first appropriate editor is chosen by WordPress?
@adamsilverstein commented on PR #9921:
7 weeks ago
#4
Would it make sense to ensure that this test runs for both Imagick and GD, and then possibly a third time where the first appropriate editor is chosen by WordPress?
It makes sense to force it to run for each: Imagick and GD - in the cases where that engine supports AVIF. Except in the edge case of some specific PHP versions that falsely report GD AVIF support (as per the test code). I don't think we need the third case, we test the editor choosing functionality elsewhere (I believe).
My original understanding was that the test was confirming a specific edge case in Imagick no longer occurred.
The bug report was certainly about an issue found with Imagick, but the resulting tests are actually useful to run for both engines. My expectation is that they should pass in both although we may have only been testing against Imagick so far.
Some additional context: at the time we added these tests our development environments lacked GD AVIF support entirely. AVIF support can be conditionally compiled into GD at build time, so AVIF support is not a given even when running a PHP version with bundled GD support. I'm planning to build GD locally with AVIF support.
Does the Trixie container have both Imagick and GD AVIF support built in?
@adamsilverstein commented on PR #9921:
7 weeks ago
#5
@desrosj - I tried improving the tests by specifying the editor to test with and testing against both in https://github.com/WordPress/wordpress-develop/pull/9965
This moves the
test_quality_with_avif_conversion_file_sizestest method and related filter hooks to theTests_Image_Editor_Imagickclass, which specifically forces the use ofWP_Image_Editor_Imagick.In the current location (the
Tests_Mediaclass), a specific image editor is not enforced, so the test can fall back to using GD when Imagick is not compiled with AVIF support.Trac ticket: Core-63990.