Opened 3 years ago
Closed 3 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: | afragen | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | Editor | Version: | 6.5 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
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
@
3 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
@
3 years ago
- Keywords needs-patch added
- Milestone Awaiting Review → 6.5
- Priority highest omg bbq → high
- Severity major → normal
#7
@
3 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.
3 years ago
#9
@
3 years ago
- Milestone 6.5
- Resolution → reported-upstream
- Status new → 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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; }