Make WordPress Core

Opened 12 months ago

Closed 28 hours ago

#60798 closed defect (bug) (fixed)

Investigate potentially failing Imagick PDF alpha channel test

Reported by: swissspidy's profile swissspidy Owned by: antpb's profile antpb
Milestone: 6.8 Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch has-unit-tests
Focuses: Cc:

Description (last modified by swissspidy)

The test \Tests_Image_Editor_Imagick::test_remove_pdf_alpha_channel_should_remove_the_alpha_channel_in_preview() was introduced in #39216 / [56271].

On some hosting providers, this test appears to be failing with errors such as this:

Tests_Image_Editor_Imagick::test_remove_pdf_alpha_channel_should_remove_the_alpha_channel_in_preview
The intermediate size could not be retrieved.
Failed asserting that false is of type "array".

/tmp/wp-test-runner/tests/phpunit/tests/image/editorImagick.php:680

Examples:

https://make.wordpress.org/hosting/test-results/r57849/wpsabot-r57849/
https://make.wordpress.org/hosting/test-results/r57848/wetopibot-r57848/

We should investigate this failure to see whether it's an issue in core or with the hosting provider.

The test mentions "Ghostscript version >= 9.14", so maybe it's just a matter of skipping the test if the installed Ghostscript version (gs --version I think) is older than that.

Attachments (2)

60798.patch (872 bytes) - added by antpb 12 months ago.
60798-2.patch (872 bytes) - added by antpb 12 months ago.

Download all attachments as: .zip

Change History (28)

#1 @swissspidy
12 months ago

  • Description modified (diff)

cc @antpb @javiercasares

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


12 months ago

#3 @swissspidy
12 months ago

tl;dr from the above Slack discussion:

\WP_Image_Editor_Imagick::remove_pdf_alpha_channel is currently checking the ImageMagick version, but it looks like we need to check the Imagick version via phpversion( 'imagick' ).

So maybe even as simple as version_compare( phpversion( 'imagick' ), '9.14', '>=' ) would work.

@antpb
12 months ago

#4 @antpb
12 months ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 6.6

I've attached a patch. I'm pretty certain the version check is checking ImageMagick and not the correct imagick version. From the php docs it says the function being used currently only returns the ImageMagick version: https://www.php.net/manual/en/imagick.getversion.php

Imagick::getVersion — Returns the ImageMagick API version

We should just directly do the phpversion() call to the module to get the version. We could use some testing from hosts seeing the test errors.

Prior art also: https://github.com/WordPress/wordpress-develop/blob/4f9b520d3e2531c9ffb9ee5c06a2e2a7e34f9c52/src/wp-admin/includes/class-wp-debug-data.php#L540

For manual testing to ensure this patch doesnt result in a regression please repeat the report here to ensure it is still fixed with this new version check: https://core.trac.wordpress.org/ticket/39216

Last edited 12 months ago by antpb (previous) (diff)

This ticket was mentioned in Slack in #core-media by swissspidy. View the logs.


12 months ago

@antpb
12 months ago

#6 @joedolson
12 months ago

  • Keywords commit added

This looks good to me; it'll definitely help to be checking the right package! ;)

#7 @swissspidy
12 months ago

  • Owner set to antpb
  • Status changed from new to assigned

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


10 months ago

#9 @antpb
9 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 58415:

Media: Use version_compare() for Imagick version check when removing alpha.

Previously remove_pdf_alpha_channel() used Imagick::getVersion() to validate the environment is capable of handling alpha. This was the incorrect function to use to check the module version as it will only provide the ImageMagick API version. This patch adjusts to instead use phpversion() as this is the correct method to get the Imagick version needed to determine alpha compatibility. This fixes a number of host tests that have been correctly failing on subsets of environments. Serendipidously, sometimes the API version was high enough to avoid shining light on this problem.

Props swissspidy, joedolson, antpb.
Fixes #60798.

#10 @antpb
9 months ago

In 58417:

Media: Revert r58415 Use version_compare() for Imagick version check when removing alpha.
This commit is a clean revert of r58415 as tests seem to now be failing with this change. Likely the test needs an update as well to accomodate the new successful version check.
Follow-up to [60798].
Props jorbin, hellofromTonya.
See #60798.

#11 @SergeyBiryukov
9 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#12 @oglekler
9 months ago

  • Keywords commit removed
  • Milestone changed from 6.6 to 6.7

Moving this ticket to the next milestone due to RC1 coming.

#13 @sippis
7 months ago

We just started setting up our automated test reporter and ran into this issue. See https://make.wordpress.org/hosting/test-results/r58902/evermadebot-r58902/

Read the history and looked into the reverted patch.

<?php phpversion( 'imagick' )

reports 3.7.0 which seems to be the latest stable as per PECL so checking against 9.14 feels a bit odd to me. Maybe I'm missing something?

#14 @swissspidy
7 months ago

  • Keywords needs-patch added; dev-feedback has-patch removed

3.7.0 is just the version of the imagick extension, whereas 9.14 is the version of the ImageMagick library used by imagick. Two different things.

If we indeed need to check imagick version, then yes 9.14 is the wrong version to compare to there.

This ticket was mentioned in Slack in #core by chaion07. View the logs.


5 months ago

#16 @chaion07
5 months ago

Thanks @swissspidy for reporting this. As we move closer to the RC1 for 6.7 in a matter of days we want to possibly bump the milestone following the feedback received from a recent bug-scrub session. We'll revisit this Ticket in a few days.

Cheers!

#17 @swissspidy
5 months ago

  • Milestone changed from 6.7 to 6.8

#18 @desrosj
2 months ago

  • Keywords has-patch needs-refresh added; needs-patch removed

This ticket was mentioned in PR #8144 on WordPress/wordpress-develop by @sukhendu2002.


2 months ago
#19

  • Keywords needs-refresh removed

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


8 days ago

This ticket was mentioned in Slack in #core-media by audrasjb. View the logs.


8 days ago

#22 @adamsilverstein
8 days ago

3.7.0 is just the version of the imagick extension, whereas 9.14 is the version of the ImageMagick library used by imagick. Two different things.

If we indeed need to check imagick version, then yes 9.14 is the wrong version to compare to there.

We can use the same check in the remove_pdf_alpha_channel function:

$version = Imagick::getVersion();
// Remove alpha channel if possible to avoid black backgrounds for Ghostscript >= 9.14. RemoveAlphaChannel added in ImageMagick 6.7.5.
if ( $version['versionNumber'] >= 0x675 ) {
Last edited 8 days ago by adamsilverstein (previous) (diff)

This ticket was mentioned in PR #8484 on WordPress/wordpress-develop by @adamsilverstein.


8 days ago
#23

  • Keywords has-unit-tests added

#24 @adamsilverstein
8 days ago

@swissspidy I tried an updated approach in https://core.trac.wordpress.org/ticket/60798. Do you suggest I reach out in the hosting channel to get this tested?

#25 @swissspidy
7 days ago

Should be fine to just commit this and then we'll see the results on the hosting results page.

#26 @adamsilverstein
28 hours ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 60030:

Media: fix potentially failing Imagick PDF alpha channel test.

Only test PDF alpha functionality when supported by the server.

Props: adamsilverstein, swissspidy, antpb, sippis.
Fixes #60798.

Note: See TracTickets for help on using tickets.