Skip to content

Fix Gutenberg_REST_View_Config_Controller_7_1 PHP warnings#77290

Merged
ntsekouras merged 3 commits intotrunkfrom
fix-Gutenberg_REST_View_Config_Controller_7_1-warnings
Apr 14, 2026
Merged

Fix Gutenberg_REST_View_Config_Controller_7_1 PHP warnings#77290
ntsekouras merged 3 commits intotrunkfrom
fix-Gutenberg_REST_View_Config_Controller_7_1-warnings

Conversation

@ntsekouras
Copy link
Copy Markdown
Contributor

What?

Follow up of: #76734

  • Fix PHP warning Undefined array key "layout" when requesting view config for
    wp_template_part — get_default_layouts_for_wp_template_part() was missing the layout key
    in its grid entry
  • Add defensive ?? array() fallback at all $default_layouts access sites to prevent
    similar issues in the future

Testing Instructions

  1. Verify templates parts page in site editor (through patterns menu item) works as before
  2. No PHP warnings

Use of AI Tools

Opus 4.6

@ntsekouras ntsekouras requested a review from oandregal April 14, 2026 07:47
@ntsekouras ntsekouras self-assigned this Apr 14, 2026
@ntsekouras ntsekouras added [Type] Bug An existing feature does not function as intended [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Apr 14, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 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: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>

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

Comment on lines +964 to +966
'grid' => array(
'layout' => array(),
),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should fix it, thanks. Are the other changes necessary given the data will be always defined?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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.

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.

@ntsekouras ntsekouras enabled auto-merge (squash) April 14, 2026 08:31
@github-actions
Copy link
Copy Markdown

Flaky tests detected in 569c5f9.
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/24388852316
📝 Reported issues:

@ntsekouras ntsekouras merged commit 6d4534e into trunk Apr 14, 2026
40 checks passed
@ntsekouras ntsekouras deleted the fix-Gutenberg_REST_View_Config_Controller_7_1-warnings branch April 14, 2026 09:09
@github-actions github-actions bot added this to the Gutenberg 23.0 milestone Apr 14, 2026
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Apr 14, 2026
@oandregal
Copy link
Copy Markdown
Member

Can you backport this to the corresponding core PR?

@ocean90 ocean90 removed their assignment Apr 14, 2026
@ocean90 ocean90 removed the [Status] In Progress Tracking issues with work in progress label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants