-
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
Double gutenberg_ prefix given to some PHP functions during the build #40938
Comments
I initially thought of replacing The only other solution I can think if is checking each match for the presence of |
Lol nice. Could we use a negative lookahead? Haven't tested it but something like this.
|
@noisysocks that would work, we'd just have to stop precomputing all the matches first: Array.from(
content.matchAll(
/^\s*function ([^\(]+)/gm
)
)
.reduce( ( result, [ , functionName ] ) => {
// Prepend the Gutenberg prefix
}, content ) And start matching and replacing in batches of one: while ( true ) {
const match = content.match(
/^\s*function (?!gutenberg_)([^\(]+)/gm
);
if ( ! match ) break;
// Prepend the Gutenberg prefix
} |
Also happening to |
Alternatively, we might be able to keep the batch processing if we made sure we're only replacing full function names, i.e. tweak this part so that gutenberg/tools/webpack/blocks.js Lines 190 to 193 in 6c47fe2
Finally, a quick-and-dirty fix might be to remove diff --git a/tools/webpack/blocks.js b/tools/webpack/blocks.js
index 080ee2e0124..329510e9fba 100644
--- a/tools/webpack/blocks.js
+++ b/tools/webpack/blocks.js
@@ -194,7 +194,7 @@ module.exports = [
( match ) =>
prefix +
match.replace(
- /^wp_/,
+ /^(wp_|gutenberg_)/,
''
)
); |
Moving the rewriting to PHP and using the built-in tokenizer would make this much easier. |
Description
Add the following code to
packages/block-library/blocks/navigation.php
and run the build:It gets bundled in
build/block-library/blocks/navigation.php
as:This is caused by the following webpack transform:
gutenberg/tools/webpack/blocks.js
Lines 122 to 169 in 7c9286a
In short:
block_core_navigation_get_post_ids
gutenberg_block_core_navigation_get_post_ids
block_core_navigation_get_post_ids_from_block
also gets affectedblock_core_navigation_get_post_ids_from_block
separatelyAnd we end up with a double prefix.
Initially seen in #40752 (comment)
Related: #40657
cc @spacedmonkey @gziolo @youknowriad @ellatrix @noisysocks @getdave
The text was updated successfully, but these errors were encountered: