Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nav block renderer error with markup for inner blocks #59814

Closed
getdave opened this issue Mar 13, 2024 · 0 comments · Fixed by #59820
Closed

Nav block renderer error with markup for inner blocks #59814

getdave opened this issue Mar 13, 2024 · 0 comments · Fixed by #59820
Labels
[Block] Navigation Affects the Navigation Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@getdave
Copy link
Contributor

getdave commented Mar 13, 2024

Raising a complimentary Issue in Gutenberg repo for https://core.trac.wordpress.org/ticket/60762.

What follows is pasted from that Trac ticket:


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 WordPress/wordpress-develop@1f8bb9f#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;
}
@getdave getdave added [Type] Bug An existing feature does not function as intended [Block] Navigation Affects the Navigation Block labels Mar 13, 2024
afragen added a commit to afragen/gutenberg that referenced this issue Mar 13, 2024
Fixes get_markup_for_inner_block()
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Mar 13, 2024
getdave pushed a commit that referenced this issue Mar 14, 2024
…arkup_for_inner_block()` (#59820)

* Fix for #59814

Fixes get_markup_for_inner_block()

* fix WPCS issues
youknowriad pushed a commit that referenced this issue Mar 18, 2024
…arkup_for_inner_block()` (#59820)

* Fix for #59814

Fixes get_markup_for_inner_block()

* fix WPCS issues
getdave pushed a commit that referenced this issue Mar 18, 2024
…arkup_for_inner_block()` (#59820)

* Fix for #59814

Fixes get_markup_for_inner_block()

* fix WPCS issues
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this issue Mar 27, 2024
…arkup_for_inner_block()` (WordPress#59820)

* Fix for WordPress#59814

Fixes get_markup_for_inner_block()

* fix WPCS issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
No open projects
Status: Done
1 participant