-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
[Feature] BlocksOverall functionality of blocksOverall functionality of blocks[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
Description
In some custom blocks, where we use useInnerBlocksProps
with layout
support and place any tag without className
in save function before tag with inner blocks, we get this warning:
PHP Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /wp-includes/block-supports/layout.php on line 837
Step-by-step reproduction instructions
- Create a block with
layout
supports and with InnerBlocks - Add the similar output for Save function:
function BlockSave() {
const blockProps = useBlockProps.save();
const innerBlocksProps = useInnerBlocksProps.save({ className: 'test-inner-blocks' });
return (
<div {...blockProps}>
<div>Test</div>
<div {...innerBlocksProps} />
</div>
);
}
- Just place the block on the page, save and check the frontend output. Everything will be rendered correctly, but we will also see the deprecation notice
- The reason is simple. This code part is trying to check the 'class' attribute of the block, which doesn't contains a class:
gutenberg/lib/block-supports/layout.php
Line 819 in e131e6e
if ( false !== strpos( $processor->get_attribute( 'class' ), $inner_block_wrapper_classes ) ) {
Screenshots, screen recording, code snippet
Related topic, created by the user of Ghost Kit plugin - https://wordpress.org/support/topic/php-warning-under-php-8-1/
Environment info
- PHP 8.2.8
- WordPress 6.4
- Gutenberg 17.0.2
- theme is 2024
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Metadata
Metadata
Assignees
Labels
[Feature] BlocksOverall functionality of blocksOverall functionality of blocks[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended