Skip to content

Tests: Skip the PDF alpha channel test when the PDF cannot be loaded - #14214

Closed
ekamran wants to merge 1 commit into
WordPress:trunkfrom
ekamran:fix/pdf-alpha-test-without-ghostscript
Closed

ekamran wants to merge 1 commit into
WordPress:trunkfrom
ekamran:fix/pdf-alpha-test-without-ghostscript

Conversation

@ekamran

@ekamran ekamran commented Oct 12, 2026

Copy link
Copy Markdown

test_remove_pdf_alpha_channel_should_remove_the_alpha_channel_in_preview() fails when Imagick is installed but Ghostscript is not, with "The intermediate size could not be retrieved."

The test skips only when wp_image_editor_supports() reports no PDF support. That check uses Imagick::queryFormats(), which still lists PDF when Ghostscript is missing, as noted in https://core.trac.wordpress.org/ticket/45813. So the test runs, no preview is generated, and the assertion fails.

The four PDF tests in tests/phpunit/tests/image/functions.php already skip in this case. r48341 gave them a second check that loads the file with wp_get_image_editor(). This test was added later, in r56271, without it. This PR adds the same check.

Where it shows up:

Testing

I ran the alpha channel test and the four functions.php PDF tests on Ubuntu 24.04 (PHP 8.3.6, ImageMagick 6.9.12-98) and on the wordpressdevelop/php image (PHP 8.3.35, ImageMagick 7.1.1-43). In the image, I renamed /usr/bin/gs for the runs without Ghostscript.

  • trunk, no Ghostscript: the alpha channel test fails, the other four are skipped.
  • This PR, no Ghostscript: all five are skipped with "File is not an image."
  • trunk and this PR, with Ghostscript: all five pass, 21 assertions.

Both environments gave the same results. vendor/bin/phpcs on the changed file is clean.

Trac ticket: https://core.trac.wordpress.org/ticket/65819

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code, Codex (testing and review)
The investigation, verification and final decisions are mine, and I take responsibility for the change.

`wp_image_editor_supports()` reports PDF support when Imagick lists the
PDF format, even if Ghostscript is not installed, so the test failed
instead of being skipped. Use the same `wp_get_image_editor()` check as
the other PDF tests in `tests/phpunit/tests/image/functions.php`.

See #65819.
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props ekamran.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@lancewillett
lancewillett requested a balanced review from Copilot October 12, 2026 20:40
@lancewillett

Copy link
Copy Markdown
Member

wporg-sync pushed a commit that referenced this pull request Oct 12, 2026
Check that `wp_get_image_editor()` can load the PDF before testing alpha-channel removal. ImageMagick can advertise PDF support when Ghostscript is unavailable. Match the existing PDF tests while preserving the preview and pixel assertions on supported systems.

Developed in: #14214

Props ekamran.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64318 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 12, 2026
Check that `wp_get_image_editor()` can load the PDF before testing alpha-channel removal. ImageMagick can advertise PDF support when Ghostscript is unavailable. Match the existing PDF tests while preserving the preview and pixel assertions on supported systems.

Developed in: WordPress/wordpress-develop#14214

Props ekamran.
See #65819.

Built from https://develop.svn.wordpress.org/trunk@64318


git-svn-id: http://core.svn.wordpress.org/trunk@63468 1a063a9b-81f0-0310-95a4-ce76da25c4cd

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

1 open finding
What changed in this PR

Updates the Imagick PDF alpha-channel test to skip when WordPress cannot actually load the PDF (e.g., Imagick present but Ghostscript missing), aligning behavior with existing PDF tests.

Changes:

  • Adds a wp_get_image_editor() loadability check before running the PDF preview/assertions.
  • Skips the test with the underlying WP_Error message when the editor cannot load the PDF.
File Description
tests/​phpunit/​tests/​image/​editorImagick.php Adds an editor instantiation check to skip the PDF alpha channel test when PDF loading fails (commonly due to missing Ghostscript).

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +670 to +672
$editor = wp_get_image_editor( $test_file );
if ( is_wp_error( $editor ) ) {
$this->markTestSkipped( $editor->get_error_message() );
@ekamran
ekamran deleted the fix/pdf-alpha-test-without-ghostscript branch October 13, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants