Opened 5 weeks ago
Last modified 4 weeks ago
#63296 new defect (bug)
array_intersect_key() fatal error in wp_render_layout_support_flag() due to invalid string parentLayout in core/social-links block
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.8 |
Component: | General | Keywords: | needs-screenshots |
Focuses: | Cc: |
Description
When using the core/social-links block, WordPress core may crash with a fatal error:
PHP Fatal error: Uncaught TypeError: array_intersect_key(): Argument #1 ($array) must be of type array, string given in wp-includes/block-supports/layout.php
This occurs because parentLayout is being passed as a string ("flex") instead of an array, likely during automatic layout injection in block rendering. Since wp_render_layout_support_flag() assumes both $blockattrs?style?layout? and $blockparentLayout? are arrays, it causes array_intersect_key() to throw a fatal.
Steps to reproduce:
- Use a block template or block theme with core/social-links
- Enable full site editing or a block-based page layout
- Attempt to render the template or page
- Fatal error occurs on line 600+ in layout.php
Proposed fix:
Core layout support logic should include:
php
Copy
Edit
if ( is_array( $blockparentLayout? ) ) {
only process layout
}
Or handle invalid structures more gracefully (e.g. log + fallback).
Workaround:
We patched layout.php by validating both layout and parentLayout as arrays before calling array_intersect_key().
Impact:
Breaks front-end rendering for many sites using block-based layouts.
Likely triggered by changes in layout-aware blocks like core/social-links or reusable block wrappers.
Change History (3)
#2
@
4 weeks ago
Hello,
Thanks for the prompt reply.
Here’s more detailed evidence:
PHP Fatal error: Uncaught TypeError: array_intersect_key(): Argument #1 ($array) must be of type array, string given in /wp-includes/block-supports/layout.php on line 600
Stack trace:
#0 /wp-includes/block-supports/layout.php(600): array_intersect_key()
#1 /wp-includes/class-wp-hook.php(326): wp_render_layout_support_flag()
#2 /wp-includes/plugin.php(205): WP_Hook->apply_filters()
#3 /wp-includes/class-wp-block.php(638): apply_filters()
...
Debug output showing the invalid structure injected:
[DEBUG] Invalid parentLayout: flex
[DEBUG] Block with bad parentLayout: Array
(
[blockName] => core/social-links
[attrs] => Array
(
[layout] => Array
(
[type] => flex
[orientation] => horizontal
[justifyContent] => space-between
[flexWrap] => nowrap
)
...
)
[parentLayout] => flex
)
Notice parentLayout => flex is passed as a string, not an array.
When WordPress tries to array_intersect_key() this string, the fatal occurs.
What triggered this:
Using core/social-links inside a block theme layout
Site uses full-site editing templates
Running WordPress 6.5.2
No Spectra or third-party block plugin involved in this specific crash
Additional notes:
Manually validating that parentLayout is an array inside layout.php prevents the fatal and allows the page to render normally.
Issue occurs when layout-aware processing (wp_render_layout_support_flag) tries to apply to child blocks automatically.
Would you also like me to provide a copy of the sample template where this happens?
Happy to assist further!
Best regards,
#3
@
4 weeks ago
Hey @devksec, Thanks for the detailed report.
I've been trying to reproduce the issue you've described, but haven't been successful so far despite following several approaches.
- Created templates with various configurations of the core/social-links block using the site editor
- Placed social links inside Group blocks with flex layout
- Tested different nesting levels (Group > Columns > Group > Social Links)
- Configured the social links block with horizontal orientation and space-between justification
- Viewed the templates on the front-end to check for the fatal error
I wasn't able to trigger the array_intersect_key() error you mentioned. Is there something more to be done here?
Hi @devksec, Thanks for the report.
After testing multiple ways and all possibilities, I was still unable to observe any fatal error. I followed the steps you mentioned.
Could you help with any screenshots or screencasts if possible?