Opened 2 years ago
Closed 2 years ago
#60762 closed defect (bug) (reported-upstream)
WP_Navigation_Block_Renderer::get_markup_for_inner_block() can return null causing PHP8 error
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | high | |
| Severity: | normal | Version: | 6.5 |
| Component: | Editor | Keywords: | has-patch |
| Focuses: | Cc: |
Description (last modified by )
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 instead of an empty string.
If the function is changed from
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>';
}
return $inner_block_content;
}
}
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;
}
Change History (9)
#5
@
2 years ago
Thanks for catching this and reporting.
I went ahead and raised and Issue in the Gutenberg repo as all blocks are maintained there:
#6
@
2 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 6.5
- Priority changed from highest omg bbq to high
- Severity changed from major to normal
#7
@
2 years ago
- Keywords has-patch added; needs-patch removed
There's a PR in progress on the Gutenberg repo, so adding has-patch
This ticket was mentioned in Slack in #core by afragen. View the logs.
2 years ago
#9
@
2 years ago
- Milestone 6.5 deleted
- Resolution set to reported-upstream
- Status changed from new to closed
Now that your upstream PR is merged and https://github.com/WordPress/gutenberg/issues/59814 is closed, the fix will be automatically included in the next package update for WP 6.5 RC3 (see #60315). Therefore closing as reported-upstream since no further action is required here.
Probably a better fix.
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>'; } } return $inner_block_content; }