Meta: Add support for site meta in get_object_subtype() - #12612
SainathPoojary wants to merge 8 commits into
Conversation
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. |
There was a problem hiding this comment.
Pull request overview
This PR extends the metadata API’s get_object_subtype() to recognize multisite “site meta” objects (meta type 'blog'), enabling subtype-aware behavior for site meta and adding PHPUnit coverage for the new behavior.
Changes:
- Add a
'blog'branch toget_object_subtype()that returns'blog'for valid sites on multisite installs. - Update meta registration tests to create/delete a site in multisite and add new multisite-only assertions for blog/site subtype handling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/wp-includes/meta.php |
Adds 'blog' handling to get_object_subtype() by checking multisite and validating the site via get_site(). |
tests/phpunit/tests/meta/registerMeta.php |
Adds multisite setup/teardown for a created site and new tests targeting subtype behavior for 'blog' meta. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the 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. |
spacedmonkey
left a comment
There was a problem hiding this comment.
This PR needs rebasing. It also need site meta functions adding like this.
/**
* Registers a meta key for sites.
*
* @since 7.2.0
*
* @param string $meta_key The meta key to register.
* @param array $args Data used to describe the meta key when registered. See
* {@see register_meta()} for a list of supported arguments.
* @return bool True if the meta key was successfully registered, false if not.
*/
function register_site_meta( $meta_key, array $args ) {
return register_meta( 'blog', $meta_key, $args );
}
/**
* Unregisters a meta key for sites.
*
* @since 7.2.0
*
* @param string $meta_key The meta key to unregister.
* @return bool True on success, false if the meta key was not previously registered.
*/
function unregister_site_meta( $meta_key ) {
return unregister_meta_key( 'blog', $meta_key );
}
58ecc92 to
fd6d2d3
Compare
|
Commited in https://core.trac.wordpress.org/changeset/63603 |
This PR adds subtype support for site meta to
register_meta()by updatingget_object_subtype().Since site meta was introduced, it has lacked subtype awareness. This change adds a
blogcase toget_object_subtype(), which validates that multisite is active and the given site ID actually exists before returning the subtype. It also includes an explicit guard for$object_id <= 0to preventget_site()from incorrectly resolving to the current site.Includes unit tests for validation and integration with
get_registered_metadata().Trac ticket: #44387
Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Gemini, Claude
Used for: Checking for potential edge cases, drafting the PR description, and assisting with local code review. The final implementation and testing were written and executed manually by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.