-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Rebuild post type meta capabilities when unregistering a post type #13342
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
Open
westonruter
wants to merge
11
commits into
WordPress:trunk
Choose a base branch
from
westonruter:fix/unregister-post-type-meta-caps
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+186
−44
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1d2f183
Rebuild post type meta capabilities when unregistering a post type
westonruter 4bb60a6
Tidy the `_post_type_meta_capabilities()` signature and documentation
westonruter 8f09def
Document `_post_type_meta_capabilities()` as taking a capability map
westonruter 5a95164
Eliminate redundant call to post_type_exists() by reusing return valu…
westonruter d2e3f4c
Add missing type information for $wp_post_types global
westonruter 6c45343
Inline the meta capability rebuild into `unregister_post_type()`
westonruter ad8cb2a
Remove unnecessary line break
westonruter a47931b
Record the `_post_type_meta_capabilities()` history in its docblock
westonruter e766cb0
Use native type hint for property
westonruter da2cfe2
Note the moved capability cleanup in `remove_rewrite_rules()`
westonruter 1a5aa5f
Reference the Trac ticket from the new tests
westonruter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.
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.
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.
what are the implications here for registering a post type? does this go both-ways, where something gets potentially overwritten that shouldn’t be?
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.
Looking at how this works…
When
register_post_type()is called duringinit, it constructs aWP_Post_Type. The constructor will callWP_Post_Type::set_props()which in turn callsget_post_type_capabilities(). Thisget_post_type_capabilities()function will also call_post_type_meta_capabilities()ifmap_meta_capis true, which results in$post_type_meta_capsbeing populated. So the end result with justregister_post_type()being called multiple times is the$post_type_meta_capsbeing rebuilt from scratch in the same way as this is being done here when one of the post types is unregistered.