Repository navigation
Conversation
…y_Fields_Registry. Refusing mutations once read keeps the registry immutable even when wp_entity_fields_api_init is fired again with do_action(), matching WP_Entity_Actions_Registry. Fixes #66703.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
@propsbot refresh |
…s docblock. The guard now checks that the registry itself is firing wp_entity_fields_api_init, not just that the action is firing. Update the class docblock to match, and list register_collection() among the guarded methods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oandregal
left a comment
There was a problem hiding this comment.
I just pushed a docblock update, but the change looks good to me.
|
As Gutenberg maintains these classes as well, I've ported these changes over there as well at WordPress/gutenberg#87387 |
|
@oandregal @ntsekouras @jorgefilipecosta, do you have the bandwidth to finalize this PR and also merge WordPress/gutenberg#87387 so that the fix can be included in 7.2 RC4? |
|
Noting that this should be also committed to |
I'll likely be unable to do it today, but can do tomorrow morning if @ntsekouras or @jorgefilipecosta don't beat me to it. Though I understand we need two separate core committers (one from trunk other for the 7.2 branch). |
I guess that's fine to commit to 7.2 since this PR has already two approvals? --cc @Mamaduka |
|
Yes, this should be good to commit. |
|
I'll start with the commits. |
…n fires again. `WP_Entity_Fields_Registry` checked `doing_action( 'wp_entity_fields_api_init' )` to allow `register()`, `update()`, `unregister()`, and `register_collection()`. So firing the action again with `do_action()` after the registry had been read reopened it to changes. The registry now records when it fires the action itself, as `WP_Entity_Actions_Registry` already does. Developed in #16009. Props banghamid, oandregal, abhishekfdd, wildworks, mamaduka, ntsekouras. Fixes #66703. git-svn-id: https://develop.svn.wordpress.org/trunk@65781 602fd350-edb4-49c9-b593-d223f7449a82
…n fires again. `WP_Entity_Fields_Registry` checked `doing_action( 'wp_entity_fields_api_init' )` to allow `register()`, `update()`, `unregister()`, and `register_collection()`. So firing the action again with `do_action()` after the registry had been read reopened it to changes. The registry now records when it fires the action itself, as `WP_Entity_Actions_Registry` already does. Developed in WordPress/wordpress-develop#16009. Props banghamid, oandregal, abhishekfdd, wildworks, mamaduka, ntsekouras. Fixes #66703. Built from https://develop.svn.wordpress.org/trunk@65781 git-svn-id: http://core.svn.wordpress.org/trunk@64810 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…n fires again. `WP_Entity_Fields_Registry` checked `doing_action( 'wp_entity_fields_api_init' )` to allow `register()`, `update()`, `unregister()`, and `register_collection()`. So firing the action again with `do_action()` after the registry had been read reopened it to changes. The registry now records when it fires the action itself, as `WP_Entity_Actions_Registry` already does. Developed in #16009. Reviewed by oandregal. Merges [65781] to the 7.2 branch. Props banghamid, oandregal, abhishekfdd, wildworks, mamaduka, ntsekouras. Fixes #66703. git-svn-id: https://develop.svn.wordpress.org/branches/7.2@65782 602fd350-edb4-49c9-b593-d223f7449a82
…n fires again. `WP_Entity_Fields_Registry` checked `doing_action( 'wp_entity_fields_api_init' )` to allow `register()`, `update()`, `unregister()`, and `register_collection()`. So firing the action again with `do_action()` after the registry had been read reopened it to changes. The registry now records when it fires the action itself, as `WP_Entity_Actions_Registry` already does. Developed in WordPress/wordpress-develop#16009. Reviewed by oandregal. Merges [65781] to the 7.2 branch. Props banghamid, oandregal, abhishekfdd, wildworks, mamaduka, ntsekouras. Fixes #66703. Built from https://develop.svn.wordpress.org/branches/7.2@65782 git-svn-id: http://core.svn.wordpress.org/branches/7.2@64811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…he registry (#87387) * Entity Fields: Track wp_entity_fields_api_init firing internally in the registry register(), update(), unregister(), and register_collection() checked doing_action( 'wp_entity_fields_api_init' ), so any do_action() call of the hook from outside the registry let them run: firing it again once the registry had been read reopened it, after the REST controller and the import map of the editor script were built from its fields. The registry now sets an internal flag while it fires the action on the first read, and the guard checks that flag instead. The plugin subclass overrides initialize() and doing_entity_fields_api_init() so the fix applies on WordPress versions whose registry predates it. Port of WordPress/wordpress-develop#16009. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Add backport changelog entry for wordpress-develop#16009 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: oandregal <oandregal@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
…he registry (#87387) * Entity Fields: Track wp_entity_fields_api_init firing internally in the registry register(), update(), unregister(), and register_collection() checked doing_action( 'wp_entity_fields_api_init' ), so any do_action() call of the hook from outside the registry let them run: firing it again once the registry had been read reopened it, after the REST controller and the import map of the editor script were built from its fields. The registry now sets an internal flag while it fires the action on the first read, and the guard checks that flag instead. The plugin subclass overrides initialize() and doing_entity_fields_api_init() so the fix applies on WordPress versions whose registry predates it. Port of WordPress/wordpress-develop#16009. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Add backport changelog entry for wordpress-develop#16009 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: oandregal <oandregal@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Source: WordPress/gutenberg@95d4da9
|
Thank you @ntsekouras for going ahead and taking care of this! 🙏 ❤️ |
Track
wp_entity_fields_api_initexecution via an internal$initializingflag inWP_Entity_Fields_Registryinstead of relying on WordPress'doing_action( 'wp_entity_fields_api_init' ).Previously, calling
do_action( 'wp_entity_fields_api_init' )again after the registry had already been initialized and read causeddoing_entity_fields_api_init()to returntrue, allowingregister(),update(),unregister(), andregister_collection()to mutate the registry and violating its immutability guarantee. This alignsWP_Entity_Fields_RegistrywithWP_Entity_Actions_Registry, and adds a PHPUnit regression test.Trac ticket: https://core.trac.wordpress.org/ticket/66703
Use of AI Tools
AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini 3.8 Flash, Gemini 4 Argon, Gemini 4 Hydrogen, Orchestrator (Argon)
Used for: Root cause analysis, patch implementation, and regression test drafting; all changes were reviewed and verified locally.