Plugin: fix activation warning#77908
Conversation
`constants.php` returns an array of build metadata, and other consumers (build/scripts.php, build/widgets.php, etc.) load it via `require` so the array is returned on every call. `lib/load.php` was the only caller using `require_once`, which returns `true` once the file has already been included by one of those earlier consumers. That made `$build_constants['version']` evaluate as `true['version']` and emitted a warning during plugin activation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in 501740b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25313682117
|
|
I would like to merge this PR as it is a very minor code quality improvement. |
What?
Fix the "unexpected output during activation" warning emitted when activating the Gutenberg plugin.
Why?
build/constants.phpreturns an array and is loaded via plainrequirefrom severalbuild/*.phpfiles. Whenlib/load.phpthen usedrequire_once, PHP returnedtrue(because the file had already been included), and$build_constants['version']triggered a "Trying to access array offset on true" warning during activation.How?
Switch
lib/load.phptorequireso the array is returned on every call, matching the other consumers.Testing Instructions
Use of AI Tools
Diagnosis and patch were drafted with Claude Code; the change was reviewed and committed by the author.