-
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
Blocks: Fix double gutenberg_
prefix in built dynamic blocks PHP
#60288
Blocks: Fix double gutenberg_
prefix in built dynamic blocks PHP
#60288
Conversation
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: 0 B Total Size: 1.72 MB ℹ️ View Unchanged
|
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.
Thank you, @ockham! The fix works as expected 👍
…dPress#60288) Co-authored-by: ockham <bernhard-reiter@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: noisysocks <noisysocks@git.wordpress.org> Co-authored-by: adamziel <zieladam@git.wordpress.org>
What?
During the build step of the block-library package, function names found in dynamic blocks' PHP code are prefixed with
gutenberg_
(to avoid collisions with their unprefixed counterparts in Core).If a function name is fully included in another function's name -- e.g.
block_core_navigation_insert_hooked_blocks
andblock_core_navigation_insert_hooked_blocks_into_rest_response
-- the latter is prefixed twice, due to the way the function name is searched for. In the example above, this results in the function being named ingutenberg_gutenberg_block_core_navigation_insert_hooked_blocks_into_rest_response
inbuild/block-library/blocks/navigation.php
.This PR fixes this problem.
Why?
To fix #40938.
How?
By making sure a function call is only replaced if the matched string isn't part of a longer function name.
Testing Instructions
rm -rf build && npm run build
build/block-library/blocks/navigation.php
.gutenberg_block_core_navigation_insert_hooked_blocks_into_rest_response
.