[wp-trac] [WordPress Trac] #60762: WP_Navigation_Block_Renderer::get_markup_for_inner_block() can return null causing PHP8 error
WordPress Trac
noreply at wordpress.org
Tue Mar 12 19:28:07 UTC 2024
#60762: WP_Navigation_Block_Renderer::get_markup_for_inner_block() can return null
causing PHP8 error
-----------------------------+------------------------------
Reporter: afragen | Owner: (none)
Type: defect (bug) | Status: new
Priority: highest omg bbq | Milestone: Awaiting Review
Component: Editor | Version: trunk
Severity: major | Resolution:
Keywords: | Focuses:
-----------------------------+------------------------------
Description changed by afragen:
Old description:
> `class-wp-html-tag-processor.php on line 876` can have an null value
> passed to `strlen()` as $this->html resulting in a PHP8 error.
>
> This seems to have originated from a change in
> https://github.com/WordPress/wordpress-
> develop/commit/1f8bb9fb333f5a5fb955d1a2298a00b6443eacc8#diff-
> 1bea3165bce53d53ac51db1b623291fcd75ca59e08ec124df652312329160685L143-R169
> where static::get_markup_for_inner_block( $inner_block ) can return null.
>
> If the function is changed to the following this is mitigated.
>
> {{{
> private static function get_markup_for_inner_block( $inner_block
> ) {
> $inner_block_content = $inner_block->render();
> if ( ! empty( $inner_block_content ) ) {
> if ( static::does_block_need_a_list_item_wrapper(
> $inner_block ) ) {
> return '<li class="wp-block-navigation-
> item">' . $inner_block_content . '</li>';
> }
> } else {
> $inner_block_content = '';
> }
>
> return $inner_block_content;
> }
> }}}
New description:
`class-wp-html-tag-processor.php on line 876` can have an null value
passed to `strlen()` as `$this->html` resulting in a PHP8 error.
This seems to have originated from a change in
https://github.com/WordPress/wordpress-
develop/commit/1f8bb9fb333f5a5fb955d1a2298a00b6443eacc8#diff-
1bea3165bce53d53ac51db1b623291fcd75ca59e08ec124df652312329160685L143-R169
where static::get_markup_for_inner_block( $inner_block ) can return null.
If the function is changed to the following this is mitigated.
{{{
private static function get_markup_for_inner_block( $inner_block )
{
$inner_block_content = $inner_block->render();
if ( ! empty( $inner_block_content ) ) {
if ( static::does_block_need_a_list_item_wrapper(
$inner_block ) ) {
return '<li class="wp-block-navigation-
item">' . $inner_block_content . '</li>';
}
} else {
$inner_block_content = '';
}
return $inner_block_content;
}
}}}
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60762#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list