Fix map_meta_cap notice by deferring migration until post types are registered - #3639
Open
faisalahammad wants to merge 1 commit into
Open
Fix map_meta_cap notice by deferring migration until post types are registered#3639faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Migration::init runs at init priority 1, before ActivityPub's custom post types are registered at init priority 11. On fresh installs this caused maybe_migrate to insert extra-field posts before the ap_extrafield CPTs existed, triggering a map_meta_cap doing_it_wrong notice. Defer maybe_migrate to init priority 20 (after CPT registration at 11). Scheduler callback registration stays synchronous at priority 1 because register_async_batch_callback warns if called after init. Fixes Automattic#3332
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3332
Proposed changes:
Migration::maybe_migratetoinitpriority 20 so migration runs after ActivityPub's custom post types are registered at priority 11. On fresh installs the old priority-1 timing inserted extra-field posts before theap_extrafieldCPTs existed, which fired a WordPressmap_meta_cap_doing_it_wrongnotice.Other information:
Testing instructions:
map_meta_cap"post type is not registered" PHP notice appears during migrationnpm run env-test -- --filter=class-test-migrationChangelog entry
Changelog Entry Details
Significance
Type
Message
Fixed a PHP notice that could appear when ActivityPub migration ran before custom post types were registered.