Fix Gutenberg_REST_View_Config_Controller_7_1 PHP warnings#77290
Fix Gutenberg_REST_View_Config_Controller_7_1 PHP warnings#77290ntsekouras merged 3 commits intotrunkfrom
Conversation
|
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. |
| 'grid' => array( | ||
| 'layout' => array(), | ||
| ), |
There was a problem hiding this comment.
This should fix it, thanks. Are the other changes necessary given the data will be always defined?
There was a problem hiding this comment.
Add defensive ?? array() fallback at all $default_layouts access sites to prevent similar issues in the future
They won't prevent the issue in the future, as the issue was trying to access an undefined key (layout)?
There was a problem hiding this comment.
Not really. It's defensive programming as I wasn't sure if they will be always defined. Is that the case? If yes, I can remove them.
There was a problem hiding this comment.
They won't prevent the issue in the future, as the issue was trying to access an undefined key (layout)?
It seems they would due to the warning suppression of ?? operator. That said, I'll remove them for now and only keep the layout fix.
There was a problem hiding this comment.
It seems they would due to the warning suppression of
??operator
Correct, they would.
I recommend still thinking about failure modes in this endpoint. Since $default_layouts is a dynamic value and not some pseudo-constant that we can easily verify, and since we don't have any meaningful static typechecking, it seems like these warnings can easily pop up again. And this will be all the more important once filters enter the scene.
|
Flaky tests detected in 569c5f9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24388852316
|
|
Can you backport this to the corresponding core PR? |
What?
Follow up of: #76734
wp_template_part — get_default_layouts_for_wp_template_part() was missing the layout key
in its grid entry
similar issues in the future
Testing Instructions
patternsmenu item) works as beforeUse of AI Tools
Opus 4.6