Repository navigation
Repair wp/5.9 branch Actions: Check for a current screen before reading its ID in the global styles settings - #84424
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
bcdbaab to
4df58e4
Compare
|
Size Change: 0 B Total Size: 1.11 MB ℹ️ View Unchanged
|
|
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. |
rejaulalomkhan
left a comment
There was a problem hiding this comment.
Thanks for working on this, @desrosj!
Checking is_object( get_current_screen() ) before reading get_current_screen()->id cleanly avoids the PHP 8.0+ Attempt to read property "id" on null warning during test runs when $current_screen is null. The short-circuit evaluation preserves existing behavior when a screen exists. Matches trunk's fix in #39543. LGTM!
AI Review: Gemini 2.5 Pro (Antigravity)
4df58e4 to
88a5c02
Compare
88a5c02 to
4495c9d
Compare
…l styles settings.
4495c9d to
c239115
Compare
Part of #82934.
What?
In
gutenberg_experimental_global_styles_settings()(lib/global-styles.php), checks thatget_current_screen()returns a screen before reading itsid.Why?
The function checks that
get_current_screenis callable, but not that a screen has been set, and then readsget_current_screen()->id. When the block editor settings are built without a current screen, as inWP_Test_Block_Editor, that reads a property onnull. On PHP 8 this is a warning, which PHPUnit turns into an error, sotest_get_block_editor_settings_overrides_default_settings_all_editorsandtest_get_block_editor_settings_deprecated_filter_post_editorfail withAttempt to read property "id" on nullatlib/global-styles.php:21.How?
Adds
is_object( get_current_screen() ) &&to the condition, as trunk did in #39543 (3f19397). That commit doesn't cherry-pick here because the code had moved tolib/compat/wordpress-6.0/block-editor-settings.phpon trunk, so the same one-line change is applied tolib/global-styles.php.wp/6.0already has the check.Use of AI Tools
This PR was created by Claude Code under my supervision. All code should be treated as AI-produced and not yet reviewed by a human until this PR is marked Ready for Review.
🤖 Generated with Claude Code