Skip to content

Include command assets and exclude dev-only Symfony packages in Phar builds - #1219

Merged
schlessera merged 2 commits into
mainfrom
fix/make-phar-assets-and-symfony
Nov 27, 2026
Merged

schlessera merged 2 commits into
mainfrom
fix/make-phar-assets-and-symfony

Conversation

@schlessera

@schlessera schlessera commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Fixes two Phar packaging issues exposed after releasing wp-cli/i18n-command v3.1.0 and wp-cli/package-command v3.1.0:

  1. Include bundled command assets/ directories in non-CLI Phar builds

    • wp-cli/i18n-command relies on assets/block-i18n.json and assets/theme-i18n.json as offline fallbacks when remote schemas cannot be downloaded (tested in wp-cli/i18n-command#519).
    • utils/make-phar.php previously only packaged vendor/wp-cli/*-command/templates, causing all three i18n-command Phar jobs in wp-cli/automated-tests to fail on makepot.feature:3476.
    • Adds vendor/wp-cli/*-command/assets (guarded via glob( ..., GLOB_ONLYDIR )) for non-CLI builds.
  2. Exclude dev-only vendor/symfony/* from the Phar when composer/composer is absent

    • With wp-cli/package-command v3.1.0 (wp-cli/package-command#248), no runtime package in wp-cli/wp-cli-bundle depends on any symfony/* package anymore — all 20 locked symfony/* packages are in packages-dev only.
    • utils/make-phar.php was still unconditionally bundling 209 dev-only files from vendor/symfony/ (console, filesystem, finder, string, polyfill-*, etc.) into the Phar.
    • Guards ->in( WP_CLI_VENDOR_DIR . '/symfony' ) behind is_dir( WP_CLI_VENDOR_DIR . '/composer/composer' ) and strips all /symfony/ entries from autoload_*.php when composer/composer is absent, shrinking the built Phar from ~6.8 MB to ~5.6 MB while preserving backwards compatibility with older package-command <3.1.0.

Adds regression scenarios to features/make-phar.feature covering both changes.

Summary by CodeRabbit

  • Bug Fixes
    • Phar packaging now includes bundled internationalization command assets and avoids including files from the Symfony vendor directory.
    • Non-CLI builds now include assets directories from command packages.

@schlessera
schlessera requested a review from a team as a code owner November 26, 2026 18:36
@schlessera schlessera added the scope:distribution Related to distribution label Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Phar builder now adjusts Symfony vendor handling based on the Composer installation and includes command asset directories in non-CLI builds. New feature scenarios check for bundled i18n JSON assets and the absence of Symfony vendor paths.

Changes: Phar packaging

Layer / File(s) Summary
Conditional Symfony vendor handling
utils/make-phar.php, features/make-phar.feature
The builder adjusts Symfony autoload-map filtering based on whether composer/composer exists. It replaces the unconditional Composer vendor scan with a Symfony scan that runs only when both required directories exist. A scenario checks that the Phar contains no /vendor/symfony/ paths.
Non-CLI command assets
utils/make-phar.php, features/make-phar.feature
Non-CLI builds add existing assets directories matched under wp-cli/*-command to the Finder. A scenario checks that the Phar contains block-i18n.json and theme-i18n.json.

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

Change: Bug fix

Possibly related PRs

Suggested labels: bug

Suggested reviewers: swissspidy, brianhenryie

Merge Risk: Minimal · up to 515c7

The change adjusts which files go into the Phar: it bundles command assets and drops dev-only Symfony packages when Composer is absent. No actionable merge-blocking risk was found, and the regression scenarios cover both changes.

Architecture risk: Low · up to 515c7

The change affects 2 systems.

Changed systems: utils, features

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — utils (service) was modified; 1 changed file maps to changed impact.
  • observed — features (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in features/make-phar.feature: Adds a scenario that creates a Phar and checks that both block-i18n.json and theme-i18n.json exist in its bundled i18n-command assets; the expected output is present.
  • observed — Modified behavior in features/make-phar.feature: Adds a scenario that iterates through the Phar contents, counts paths containing /vendor/symfony/, and expects the count to be 0.
  • observed — Modified behavior in utils/make-phar.php: The CLI-build autoload-map filter now uses a narrower Symfony pattern when composer/composer exists, and the broader Symfony-wide pattern otherwise.
  • observed — Modified behavior in utils/make-phar.php: The non-CLI autoload-map filter now uses a narrower Symfony pattern when composer/composer exists, and the broader Symfony-wide pattern otherwise.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names both main changes in the PR: adding command assets to non-CLI Phar builds and excluding dev-only Symfony packages when composer/composer is absent. The summary and objectives confirm b…
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: Title check

Explanation

The title names both main changes in the PR: adding command assets to non-CLI Phar builds and excluding dev-only Symfony packages when composer/composer is absent. The summary and objectives confirm both changes, and the regression scenarios in features/make-phar.feature cover them. The title is specific and concise.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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: 65c50a47-9cd7-4efb-8eff-a3d1bc78bf04
Commits

Reviewing files that changed from the base of the PR and between 4bc3ca0 and 515c7d9.

Files selected for processing: 2

  • features/make-phar.feature
  • utils/make-phar.php

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

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

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@schlessera
schlessera merged commit f7bd113 into main Nov 27, 2026
64 checks passed
@schlessera
schlessera deleted the fix/make-phar-assets-and-symfony branch November 27, 2026 08:14
@github-actions github-actions Bot added this to the 3.0.0 milestone Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working scope:distribution Related to distribution scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant