Skip to content

Plugin: fix activation warning#77908

Merged
t-hamano merged 1 commit into
trunkfrom
gutenberg-activate-warning
May 5, 2026
Merged

Plugin: fix activation warning#77908
t-hamano merged 1 commit into
trunkfrom
gutenberg-activate-warning

Conversation

@t-hamano
Copy link
Copy Markdown
Contributor

@t-hamano t-hamano commented May 4, 2026

What?

Fix the "unexpected output during activation" warning emitted when activating the Gutenberg plugin.

image

Why?

build/constants.php returns an array and is loaded via plain require from several build/*.php files. When lib/load.php then used require_once, PHP returned true (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.php to require so the array is returned on every call, matching the other consumers.

Testing Instructions

  1. Activate the Gutenberg plugin on a fresh install.
  2. Confirm no "unexpected output during activation" notice appears.

Use of AI Tools

Diagnosis and patch were drafted with Claude Code; the change was reviewed and committed by the author.

`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>
@t-hamano t-hamano changed the title Plugin loader: fix activation warning from require_once on constants.php Plugin: fix activation warning May 4, 2026
@t-hamano t-hamano added the [Type] Code Quality Issues or PRs that relate to code quality label May 4, 2026
@t-hamano t-hamano self-assigned this May 4, 2026
@t-hamano t-hamano marked this pull request as ready for review May 4, 2026 10:23
@t-hamano t-hamano requested a review from spacedmonkey as a code owner May 4, 2026 10:23
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>

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

@t-hamano t-hamano added the Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts label May 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

Flaky tests detected in 501740b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25313682117
📝 Reported issues:

@t-hamano
Copy link
Copy Markdown
Contributor Author

t-hamano commented May 5, 2026

I would like to merge this PR as it is a very minor code quality improvement.

@t-hamano t-hamano merged commit 5b04b1b into trunk May 5, 2026
51 checks passed
@t-hamano t-hamano deleted the gutenberg-activate-warning branch May 5, 2026 06:12
@github-actions github-actions Bot added this to the Gutenberg 23.2 milestone May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant