Infinite number of core/navigation-link variations upon many locale switch #59300
Labels
[Block] Navigation Link
Affects the Navigation Link Block
[Type] Bug
An existing feature does not function as intended
[Type] Performance
Related to performance efforts
Description
When WordPress switches between locales, part of this involves re-registering the post types as the
$labels
has changed.The
core/navigation-link
block is hooked toregistered_post_type
which is fired as part of this re-registration, to add a new variation to the link of the Post type.Unfortunately, there's no check to see if the variation already exists before adding it.
When a script is switching between locales often (As is done on WordPress.org in some places), this causes the block to gain an infinite number of vatiations until it runs out of memory.
For most sites which switch the locale once, maybe twice, this isn't an issue, and will probably never be noticed.
This was noticed within a script which switched between ~200 locales, and processed ~1800 posts. It started running out of memory after as few less than 10 posts.
(note: This also applies to the
registered_taxonomy
hook)Step-by-step reproduction instructions
The simplest way to visualise this, is to run the following code, and observe the output. The memory usage will increase and the number of variations will too.
Screenshots, screen recording, code snippet
example output of the above script:
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: