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

Block Hooks API: Remove $post check from Navigation hooked blocks meta fn #58379

Conversation

tjcafferkey
Copy link
Contributor

What?

Remove the check on $post->ID and silent return in block_core_navigation_update_ignore_hooked_blocks_meta since Core guarantees its existence.

Why?

This part of the code was picked up during the package updates for 6.5 here. Core pretty much guarantees this data will be available within the callback as seen here and here.

How?

This removes the code which executes a silent return on an unnecessary check.

Testing Instructions

If required, regression testing steps on this feature can be found on this PR #57754

@youknowriad youknowriad added the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Jan 29, 2024
Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for the fix.

@ockham ockham added the [Block] Navigation Affects the Navigation Block label Jan 29, 2024
@ockham
Copy link
Contributor

ockham commented Jan 29, 2024

Core pretty much guarantees this data will be available within the callback as seen here and here.

As discussed on Slack, this is what convinced me that we should be fine removing the extra check from the filter.

Core even goes out of its way to find out and specify what the error is. Only after that does it call get_post; i.e. it’s assuming that errors have been handled, and as a consequence, we wouldn’t even have any information what it was. (So we could only throw a very generic error anyway.)

@ockham ockham added the [Type] Code Quality Issues or PRs that relate to code quality label Jan 29, 2024
@youknowriad youknowriad merged commit a6f1e4a into WordPress:trunk Jan 29, 2024
55 of 59 checks passed
@github-actions github-actions bot added this to the Gutenberg 17.7 milestone Jan 29, 2024
@ockham ockham modified the milestones: Gutenberg 17.7, Gutenberg 17.6 Jan 29, 2024
cbravobernal pushed a commit that referenced this pull request Jan 30, 2024
@cbravobernal
Copy link
Contributor

I just cherry-picked this PR to the release/17.6 branch to get it included in the next release: f217c68

@cbravobernal cbravobernal removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Jan 30, 2024
youknowriad pushed a commit that referenced this pull request Jan 31, 2024
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 [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants