Skip to content

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

Merged
youknowriad merged 1 commit into
WordPress:trunkfrom
tjcafferkey:update/remove-post-id-check-from-navigation-hooked-blocks-meta
Jan 29, 2024
Merged

Block Hooks API: Remove $post check from Navigation hooked blocks meta fn#58379
youknowriad merged 1 commit into
WordPress:trunkfrom
tjcafferkey:update/remove-post-id-check-from-navigation-hooked-blocks-meta

Conversation

@tjcafferkey

Copy link
Copy Markdown
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 requested a review from costdev January 29, 2024 13:06
@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

@ockham ockham left a comment

Copy link
Copy Markdown
Contributor

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

ockham commented Jan 29, 2024

Copy link
Copy Markdown
Contributor

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
@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
Copy Markdown
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.

4 participants