-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Gallery: Fix block registration hook priority #37409
Conversation
Pinging @ramonjd in case this priority was intentional. |
In b844345 I removed duplicated entries for block registration. If there is a PHP file we use it to register blocks, otherwise we execute Sidenote: PHP logic for the Gallery and Image block got added in #35975. |
Thanks for the heads up. No it wasn't intentional, I took the priority argument from existing blocks and forgot (or didn't know) to remove the gallery from the registration list. Thanks for discovering this one @Mamaduka 🙇 I just retested this change and the gallery behaves as intended. I can't see the PHP notices. For the record, I tested the navigation block in the editor as well. Links and sub-menus work as I'd expect too. |
b844345
to
22f6831
Compare
Sorry, I think my comment there might have stemmed from a misunderstanding on my part about the way we register core blocks in blocks.php. I see that if a block is in the In #35975 I was calling
The outcome we're looking for is to see the I just ran this branch again and it's showing for me consistently. 👍 Thanks again for fixing this!! |
I see a commit that removes duplicated entries for block registrations, including the gallery and image entries I added 😇 : b844345#diff-4167605a44440d5cfb787398fed6a2c0e85f2d83d358d57b9d9dba29ecb50734
Oh, I just read the latest update to the PR description under |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for looking at this @Mamaduka
This needs to be backported to the core for proper testing. Meanwhile, you can temporarily edit the WP core file and match changes in this PR.
I edited the WP core file to match the changes in this PR and can confirm that the PHP notice Notice: WP_Block_Type_Registry::register was called incorrectly. Block type "core/gallery" is already registered.
no longer appears.
The gallery works as expected, that is, the data-id is added to Image Blocks within a Gallery.
👍
Description
Fixes #37391.
All core blocks use the default (
10
)init
hook priority for registration. Using higher priority causesgutenberg_reregister_core_block_types
(which also uses default priority) to incorrectly re-register blocks.@gziolo's flow summary:
Testing
This needs to be backported to the core for proper testing. Meanwhile, you can temporarily edit the WP core file and match changes in this PR.
The following PHP notice shouldn't be visible:
Types of changes
Bugfix
Checklist:
*.native.js
files for terms that need renaming or removal).