Skip to content

Leave psr/log out of the Phar - #1220

Draft
swissspidy wants to merge 1 commit into
mainfrom
fix/make-phar-exclude-psr-log
Draft

swissspidy wants to merge 1 commit into
mainfrom
fix/make-phar-exclude-psr-log

Conversation

@swissspidy

@swissspidy swissspidy commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Companion to wp-cli/wp-cli#6439, which restarts PHP with OPcache's file cache via composer/xdebug-handler. That brings composer/pcre and psr/log back into WP-CLI's runtime dependencies now that composer/composer is gone (wp-cli/package-command#248).

A bundled psr/log v1 is a known source of clashes with plugins that ship psr/log v2/v3 (wp-cli/wp-cli#4632, wp-cli/wp-cli#5920): WP-CLI's autoloader can answer for Psr\Log first. xdebug-handler never has a logger set (setLogger() isn't called), so psr/log isn't needed at runtime.

This leaves vendor/psr/log out of the Phar and strips its entries from the autoload maps, so WP-CLI's autoloader never answers for Psr\Log. Other psr/* packages are kept as before.

Draft until wp-cli/wp-cli#6439 is merged and the bundle picks up composer/xdebug-handler. Until then the bundle has no psr/log, so this changes nothing yet. The autoload strip pattern was checked against sample classmap, PSR-4 and static-loader lines; a full Phar build with psr/log present hasn't been run yet.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Adjusted packaged dependencies so logging support is retained in both CLI and non-CLI builds, while other PSR components are included individually where applicable.

wp-cli/wp-cli#6439 requires composer/xdebug-handler, which pulls in
psr/log. Its logger is never set, so psr/log isn't needed at runtime.
Leaving it and its autoload map entries out means WP-CLI's autoloader
never answers for Psr\Log, so plugins can load their own version (see
wp-cli/wp-cli#4632 and #5920).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UWTd5pwpi2xQfDA6mUYkkx
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Phar build script now strips psr/log entries from both CLI and non-CLI autoload maps. For non-CLI builds, it selects installed psr/* directories individually, excluding log.

Changes: Phar dependency filtering

Layer / File(s) Summary
Update Phar dependency filters
utils/make-phar.php
The CLI and non-CLI autoload-map strip patterns now remove psr/log entries. The non-CLI optional-directory list now includes installed psr/* directories other than log; the CLI optional-directory list is unchanged.

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

Change: Bug fix

Possibly related PRs

  • wp-cli/wp-cli-bundle#1217: Updates the lockfile dependency tree and the Phar build script’s handling of nikic/php-parser/lib, which informs the dependency state relevant to this change.

Suggested reviewers: schlessera

Merge Risk: Minimal · up to 5f48d

This change stops psr/log from being bundled in the Phar so plugins can load their own version. No concrete merge-blocking risk was found. The PR is a draft pending the companion change, so a full Phar build should be run once that lands.

Architecture risk: Low · up to 5f48d

The change affects 1 source area.

Changed areas: utils

Review details

Systems and components

  • observed — 1 changed file mapped to utils.
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 "Leave psr/log out of the Phar" matches the main change in the changeset. The raw summary says the autoload-map stripping rules now include psr/log for both cli and non-cli builds, and the n…
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 "Leave psr/log out of the Phar" matches the main change in the changeset. The raw summary says the autoload-map stripping rules now include psr/log for both cli and non-cli builds, and the non-cli optional-directory list now adds each psr/* directory except log. The title is short, specific, and names the package and the build artifact. It does not cover the companion dependency context from the PR objectives, which is acceptable because the title does not need every detail.

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: 834329ec-0162-4ea7-81b3-c394bfa2f3af
Commits

Reviewing files that changed from the base of the PR and between f7bd113 and 5f48d4d.

Files selected for processing: 1

  • utils/make-phar.php

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

@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy
swissspidy marked this pull request as ready for review November 30, 2026 11:16
@swissspidy
swissspidy requested a review from a team as a code owner November 30, 2026 11:16
Copilot AI balanced review requested due to automatic review settings November 30, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@swissspidy
swissspidy marked this pull request as draft December 1, 2026 14:58
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants