Skip to content

Pass the ImageMagick settings on to the WP-CLI processes - #422

Merged
schlessera merged 1 commit into
mainfrom
fix/forward-imagemagick-env
Nov 2, 2026
Merged

schlessera merged 1 commit into
mainfrom
fix/forward-imagemagick-env

Conversation

@schlessera

@schlessera schlessera commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

media-command's macOS job fails every night on its 7 PDF scenarios, even though Ghostscript is installed there.

Cause

  • On macOS, setup-php installs ImageMagick somewhere other than where it was built. It points ImageMagick at its coder modules and configuration through MAGICK_CODER_MODULE_PATH, MAGICK_CONFIGURE_PATH and the like.
  • The wp processes the tests launch get only $_ENV and a few named variables. $_ENV is empty with the usual variables_order, so the MAGICK_* variables never arrive.
  • Without them, ImageMagick loads no coder modules, so Imagick supports no PDF and WordPress makes no PDF previews. JPEG still works, because WordPress falls back to GD for it.
  • On Linux, ImageMagick comes from the system with its paths built in, which is why only macOS is affected.

Change

Every MAGICK_* variable is passed on to the launched processes.

Testing

I ran a diagnostic scenario on the macOS runner in media-command:

Before With this change
Imagick::queryFormats( 'PDF' ) empty PDF, 262 formats in total
Reading the test PDF — 1088×1408
PDF scenarios 7 fail all pass (run)

phpcs and PHPStan pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Improvements
    • Image-processing settings provided through MAGICK_ environment variables are now available to launched WP-CLI processes, helping commands use the same configuration as the surrounding environment. Other environment settings and coverage behavior remain unchanged.

setup-php installs ImageMagick on macOS somewhere else than it was built for,
and points it at its coders and configuration through MAGICK_* variables.
The launched processes did not get these, so Imagick supported none of the
formats ImageMagick provides as modules, and PDF previews were never made.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera
schlessera requested a review from a team as a code owner November 2, 2026 12:53
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b831e82-5e2d-468a-914e-074c73dccc7a
Commits

Reviewing files that changed from the base of the PR and between 4c17e6d and 91e9c6f.

Files selected for processing: 1
  • src/Context/FeatureContext.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

get_process_env_variables() now forwards inherited environment variables whose names begin with MAGICK_ to launched WP-CLI processes. Other environment construction and coverage handling remain unchanged.

Changes: ImageMagick process environment

Layer / File(s) Summary
Forward inherited ImageMagick variables
src/Context/FeatureContext.php
get_process_env_variables() adds inherited variables with the MAGICK_ prefix to the environment used for launched WP-CLI processes.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Possibly related issues

  • wp-cli/wp-cli-tests#395: This change forwards MAGICK_* settings to launched wp processes, but does not declare or check the ImageMagick requirement.
  • wp-cli/wp-cli-tests#393: This change addresses missing ImageMagick environment settings in launched wp processes, but does not implement external-tool requirement checks.

Suggested labels: bug, scope:testing

Suggested reviewers: swissspidy

Merge Risk: Minimal · up to 91e9c

No actionable merge-blocking risk was identified in this environment-forwarding change.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: forwarding ImageMagick settings to launched WP-CLI processes.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added automated-pr bug Something isn't working scope:testing Related to testing labels Nov 2, 2026
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Context/FeatureContext.php 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@schlessera
schlessera merged commit 5975d9b into main Nov 2, 2026
74 of 75 checks passed
@schlessera
schlessera deleted the fix/forward-imagemagick-env branch November 2, 2026 13:17
@schlessera schlessera added this to the 5.5.1 milestone Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-pr bug Something isn't working scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant