From 40103f7dc11265a16aeb7951297297242df30c65 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Wed, 29 Oct 2025 17:59:30 +0900 Subject: [PATCH 01/14] Notes: Add auth_callback for wp_note_status comment meta --- src/wp-includes/comment.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 9399889768e57..74b5568880439 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -4129,6 +4129,9 @@ function wp_create_initial_comment_meta() { 'enum' => array( 'resolved', 'reopen' ), ), ), + 'auth_callback' => function ( $allowed, $meta_key, $object_id ) { + return current_user_can( 'edit_comment', $object_id ); + }, ) ); } From 27bd29d5ff011ae3abe15fb8b84a16fa65d3ec4d Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 08:52:58 -0600 Subject: [PATCH 02/14] Ensure note resolution meta is registered before each test --- .../tests/rest-api/rest-comments-controller.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index e0868bbeca362..a849d92a7a7bb 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -173,6 +173,23 @@ public function set_up() { if ( is_multisite() ) { update_site_option( 'site_admins', array( 'superadmin' ) ); } + // Ensure note resolution meta is registered. + register_meta( + 'comment', + '_wp_note_status', + array( + 'type' => 'string', + 'description' => __( 'Note resolution status' ), + 'single' => true, + 'show_in_rest' => array( + 'schema' => array( + 'type' => 'string', + 'enum' => array( 'resolved', 'reopen' ), + ), + ), + ) + ); + } public function test_register_routes() { From 29c24d7eee143b2cd628b9692508b3ae54d2995b Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 11:35:58 -0600 Subject: [PATCH 03/14] remove test set up register meta --- .../tests/rest-api/rest-comments-controller.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index a849d92a7a7bb..e0868bbeca362 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -173,23 +173,6 @@ public function set_up() { if ( is_multisite() ) { update_site_option( 'site_admins', array( 'superadmin' ) ); } - // Ensure note resolution meta is registered. - register_meta( - 'comment', - '_wp_note_status', - array( - 'type' => 'string', - 'description' => __( 'Note resolution status' ), - 'single' => true, - 'show_in_rest' => array( - 'schema' => array( - 'type' => 'string', - 'enum' => array( 'resolved', 'reopen' ), - ), - ), - ) - ); - } public function test_register_routes() { From 55011513596eebd858824299737eb1926fc97405 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 11:36:34 -0600 Subject: [PATCH 04/14] move wp_create_initial_comment_meta to rest_api_init hook and relocate to src/wp-includes/default-filters.php --- src/wp-includes/comment.php | 1 - src/wp-includes/default-filters.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 74b5568880439..aa841bfda976f 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -4135,4 +4135,3 @@ function wp_create_initial_comment_meta() { ) ); } -add_action( 'init', 'wp_create_initial_comment_meta' ); diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 5dc54c3686b3a..3bac93742bab0 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -531,6 +531,7 @@ add_action( 'rest_api_init', 'register_initial_settings', 10 ); add_action( 'rest_api_init', 'create_initial_rest_routes', 99 ); add_action( 'parse_request', 'rest_api_loaded' ); +add_action( 'rest_api_init', 'wp_create_initial_comment_meta' ); // Abilities API. add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' ); From 334398f90e90165f867c1035022854de1bfb8619 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 12:11:13 -0600 Subject: [PATCH 05/14] Update generated api fixtures --- tests/qunit/fixtures/wp-api-generated.js | 297 ++++++++++++++++++++--- 1 file changed, 259 insertions(+), 38 deletions(-) diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index de83c1248e3db..26da6ccf94c67 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -22,13 +22,7 @@ mockedApiResponse.Schema = { "wp-block-editor/v1", "wp-abilities/v1" ], - "authentication": { - "application-passwords": { - "endpoints": { - "authorization": "http://example.org/wp-admin/authorize-application.php" - } - } - }, + "authentication": [], "routes": { "/": { "namespace": "", @@ -855,7 +849,14 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "sticky": { @@ -1139,7 +1140,14 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "sticky": { @@ -1578,7 +1586,14 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "sticky": { @@ -2054,7 +2069,14 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "template": { @@ -2310,7 +2332,14 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "template": { @@ -2716,7 +2745,14 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "template": { @@ -4879,7 +4915,24 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "wp_pattern_sync_status": { + "type": "string", + "title": "", + "description": "", + "default": "", + "enum": [ + "partial", + "unsynced" + ] + }, + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "template": { @@ -5088,7 +5141,24 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "wp_pattern_sync_status": { + "type": "string", + "title": "", + "description": "", + "default": "", + "enum": [ + "partial", + "unsynced" + ] + }, + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "template": { @@ -5452,7 +5522,24 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "wp_pattern_sync_status": { + "type": "string", + "title": "", + "description": "", + "default": "", + "enum": [ + "partial", + "unsynced" + ] + }, + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "template": { @@ -5853,7 +5940,20 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "is_wp_suggestion": { + "type": "boolean", + "title": "", + "description": "", + "default": false + }, + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "template": { @@ -6251,7 +6351,20 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "is_wp_suggestion": { + "type": "boolean", + "title": "", + "description": "", + "default": false + }, + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "template": { @@ -6478,7 +6591,20 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "is_wp_suggestion": { + "type": "boolean", + "title": "", + "description": "", + "default": false + }, + "footnotes": { + "type": "string", + "title": "", + "description": "", + "default": "" + } + }, "required": false }, "template": { @@ -10917,7 +11043,26 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "persisted_preferences": { + "type": "object", + "title": "", + "description": "", + "default": [], + "context": [ + "edit" + ], + "properties": { + "_modified": { + "description": "The date and time the preferences were updated.", + "type": "string", + "format": "date-time", + "readonly": false + } + }, + "additionalProperties": true + } + }, "required": false } } @@ -11055,7 +11200,26 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "persisted_preferences": { + "type": "object", + "title": "", + "description": "", + "default": [], + "context": [ + "edit" + ], + "properties": { + "_modified": { + "description": "The date and time the preferences were updated.", + "type": "string", + "format": "date-time", + "readonly": false + } + }, + "additionalProperties": true + } + }, "required": false } } @@ -11200,7 +11364,26 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "persisted_preferences": { + "type": "object", + "title": "", + "description": "", + "default": [], + "context": [ + "edit" + ], + "properties": { + "_modified": { + "description": "The date and time the preferences were updated.", + "type": "string", + "format": "date-time", + "readonly": false + } + }, + "additionalProperties": true + } + }, "required": false } } @@ -11654,7 +11837,18 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "_wp_note_status": { + "type": "string", + "title": "", + "description": "Note resolution status", + "default": "", + "enum": [ + "resolved", + "reopen" + ] + } + }, "required": false } } @@ -11801,7 +11995,18 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "_wp_note_status": { + "type": "string", + "title": "", + "description": "Note resolution status", + "default": "", + "enum": [ + "resolved", + "reopen" + ] + } + }, "required": false } } @@ -13880,7 +14085,8 @@ mockedApiResponse.PostsCollection = [ "template": "", "format": "standard", "meta": { - "meta_key": "meta_value" + "meta_key": "meta_value", + "footnotes": "" }, "categories": [ 1 @@ -13998,7 +14204,8 @@ mockedApiResponse.PostModel = { "template": "", "format": "standard", "meta": { - "meta_key": "meta_value" + "meta_key": "meta_value", + "footnotes": "" }, "categories": [ 1 @@ -14038,7 +14245,8 @@ mockedApiResponse.postRevisions = [ "rendered": "" }, "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" }, "_links": { "parent": [ @@ -14070,7 +14278,8 @@ mockedApiResponse.postRevisions = [ "rendered": "

REST API Client Fixture: Post

\n" }, "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" }, "_links": { "parent": [ @@ -14104,7 +14313,8 @@ mockedApiResponse.revision = { "rendered": "

REST API Client Fixture: Post

\n" }, "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" } }; @@ -14131,7 +14341,8 @@ mockedApiResponse.postAutosaves = [ "rendered": "" }, "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" }, "_links": { "parent": [ @@ -14165,7 +14376,8 @@ mockedApiResponse.autosave = { "rendered": "" }, "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" } }; @@ -14202,7 +14414,8 @@ mockedApiResponse.PagesCollection = [ "ping_status": "closed", "template": "", "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" }, "class_list": [ "post-7", @@ -14302,7 +14515,8 @@ mockedApiResponse.PageModel = { "ping_status": "closed", "template": "", "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" }, "class_list": [ "post-7", @@ -14336,7 +14550,8 @@ mockedApiResponse.pageRevisions = [ "rendered": "" }, "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" }, "_links": { "parent": [ @@ -14368,7 +14583,8 @@ mockedApiResponse.pageRevisions = [ "rendered": "

REST API Client Fixture: Page

\n" }, "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" }, "_links": { "parent": [ @@ -14402,7 +14618,8 @@ mockedApiResponse.pageRevision = { "rendered": "

REST API Client Fixture: Page

\n" }, "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" } }; @@ -14429,7 +14646,8 @@ mockedApiResponse.pageAutosaves = [ "rendered": "" }, "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" }, "_links": { "parent": [ @@ -14463,7 +14681,8 @@ mockedApiResponse.pageAutosave = { "rendered": "" }, "meta": { - "meta_key": "" + "meta_key": "", + "footnotes": "" } }; @@ -15480,6 +15699,7 @@ mockedApiResponse.CommentsCollection = [ "96": "https://secure.gravatar.com/avatar/9ca51ced0b389ffbeba3d269c6d824be664c84fa1b35503282abdd302e1f417c?s=96&d=mm&r=g" }, "meta": { + "_wp_note_status": null, "meta_key": "meta_value" }, "_links": { @@ -15534,6 +15754,7 @@ mockedApiResponse.CommentModel = { "96": "https://secure.gravatar.com/avatar/9ca51ced0b389ffbeba3d269c6d824be664c84fa1b35503282abdd302e1f417c?s=96&d=mm&r=g" }, "meta": { + "_wp_note_status": null, "meta_key": "meta_value" } }; From 4887e1bc4a7295c206a6801d62b622bea5d98ff3 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 12:43:15 -0600 Subject: [PATCH 06/14] revert fixture change --- tests/qunit/fixtures/wp-api-generated.js | 297 +++-------------------- 1 file changed, 38 insertions(+), 259 deletions(-) diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index 26da6ccf94c67..de83c1248e3db 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -22,7 +22,13 @@ mockedApiResponse.Schema = { "wp-block-editor/v1", "wp-abilities/v1" ], - "authentication": [], + "authentication": { + "application-passwords": { + "endpoints": { + "authorization": "http://example.org/wp-admin/authorize-application.php" + } + } + }, "routes": { "/": { "namespace": "", @@ -849,14 +855,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "sticky": { @@ -1140,14 +1139,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "sticky": { @@ -1586,14 +1578,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "sticky": { @@ -2069,14 +2054,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "template": { @@ -2332,14 +2310,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "template": { @@ -2745,14 +2716,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "template": { @@ -4915,24 +4879,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "wp_pattern_sync_status": { - "type": "string", - "title": "", - "description": "", - "default": "", - "enum": [ - "partial", - "unsynced" - ] - }, - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "template": { @@ -5141,24 +5088,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "wp_pattern_sync_status": { - "type": "string", - "title": "", - "description": "", - "default": "", - "enum": [ - "partial", - "unsynced" - ] - }, - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "template": { @@ -5522,24 +5452,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "wp_pattern_sync_status": { - "type": "string", - "title": "", - "description": "", - "default": "", - "enum": [ - "partial", - "unsynced" - ] - }, - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "template": { @@ -5940,20 +5853,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "is_wp_suggestion": { - "type": "boolean", - "title": "", - "description": "", - "default": false - }, - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "template": { @@ -6351,20 +6251,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "is_wp_suggestion": { - "type": "boolean", - "title": "", - "description": "", - "default": false - }, - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "template": { @@ -6591,20 +6478,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "is_wp_suggestion": { - "type": "boolean", - "title": "", - "description": "", - "default": false - }, - "footnotes": { - "type": "string", - "title": "", - "description": "", - "default": "" - } - }, + "properties": [], "required": false }, "template": { @@ -11043,26 +10917,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "persisted_preferences": { - "type": "object", - "title": "", - "description": "", - "default": [], - "context": [ - "edit" - ], - "properties": { - "_modified": { - "description": "The date and time the preferences were updated.", - "type": "string", - "format": "date-time", - "readonly": false - } - }, - "additionalProperties": true - } - }, + "properties": [], "required": false } } @@ -11200,26 +11055,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "persisted_preferences": { - "type": "object", - "title": "", - "description": "", - "default": [], - "context": [ - "edit" - ], - "properties": { - "_modified": { - "description": "The date and time the preferences were updated.", - "type": "string", - "format": "date-time", - "readonly": false - } - }, - "additionalProperties": true - } - }, + "properties": [], "required": false } } @@ -11364,26 +11200,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "persisted_preferences": { - "type": "object", - "title": "", - "description": "", - "default": [], - "context": [ - "edit" - ], - "properties": { - "_modified": { - "description": "The date and time the preferences were updated.", - "type": "string", - "format": "date-time", - "readonly": false - } - }, - "additionalProperties": true - } - }, + "properties": [], "required": false } } @@ -11837,18 +11654,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "_wp_note_status": { - "type": "string", - "title": "", - "description": "Note resolution status", - "default": "", - "enum": [ - "resolved", - "reopen" - ] - } - }, + "properties": [], "required": false } } @@ -11995,18 +11801,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "_wp_note_status": { - "type": "string", - "title": "", - "description": "Note resolution status", - "default": "", - "enum": [ - "resolved", - "reopen" - ] - } - }, + "properties": [], "required": false } } @@ -14085,8 +13880,7 @@ mockedApiResponse.PostsCollection = [ "template": "", "format": "standard", "meta": { - "meta_key": "meta_value", - "footnotes": "" + "meta_key": "meta_value" }, "categories": [ 1 @@ -14204,8 +13998,7 @@ mockedApiResponse.PostModel = { "template": "", "format": "standard", "meta": { - "meta_key": "meta_value", - "footnotes": "" + "meta_key": "meta_value" }, "categories": [ 1 @@ -14245,8 +14038,7 @@ mockedApiResponse.postRevisions = [ "rendered": "" }, "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" }, "_links": { "parent": [ @@ -14278,8 +14070,7 @@ mockedApiResponse.postRevisions = [ "rendered": "

REST API Client Fixture: Post

\n" }, "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" }, "_links": { "parent": [ @@ -14313,8 +14104,7 @@ mockedApiResponse.revision = { "rendered": "

REST API Client Fixture: Post

\n" }, "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" } }; @@ -14341,8 +14131,7 @@ mockedApiResponse.postAutosaves = [ "rendered": "" }, "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" }, "_links": { "parent": [ @@ -14376,8 +14165,7 @@ mockedApiResponse.autosave = { "rendered": "" }, "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" } }; @@ -14414,8 +14202,7 @@ mockedApiResponse.PagesCollection = [ "ping_status": "closed", "template": "", "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" }, "class_list": [ "post-7", @@ -14515,8 +14302,7 @@ mockedApiResponse.PageModel = { "ping_status": "closed", "template": "", "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" }, "class_list": [ "post-7", @@ -14550,8 +14336,7 @@ mockedApiResponse.pageRevisions = [ "rendered": "" }, "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" }, "_links": { "parent": [ @@ -14583,8 +14368,7 @@ mockedApiResponse.pageRevisions = [ "rendered": "

REST API Client Fixture: Page

\n" }, "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" }, "_links": { "parent": [ @@ -14618,8 +14402,7 @@ mockedApiResponse.pageRevision = { "rendered": "

REST API Client Fixture: Page

\n" }, "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" } }; @@ -14646,8 +14429,7 @@ mockedApiResponse.pageAutosaves = [ "rendered": "" }, "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" }, "_links": { "parent": [ @@ -14681,8 +14463,7 @@ mockedApiResponse.pageAutosave = { "rendered": "" }, "meta": { - "meta_key": "", - "footnotes": "" + "meta_key": "" } }; @@ -15699,7 +15480,6 @@ mockedApiResponse.CommentsCollection = [ "96": "https://secure.gravatar.com/avatar/9ca51ced0b389ffbeba3d269c6d824be664c84fa1b35503282abdd302e1f417c?s=96&d=mm&r=g" }, "meta": { - "_wp_note_status": null, "meta_key": "meta_value" }, "_links": { @@ -15754,7 +15534,6 @@ mockedApiResponse.CommentModel = { "96": "https://secure.gravatar.com/avatar/9ca51ced0b389ffbeba3d269c6d824be664c84fa1b35503282abdd302e1f417c?s=96&d=mm&r=g" }, "meta": { - "_wp_note_status": null, "meta_key": "meta_value" } }; From 05e386cbbff046adf03f8ddc2028738fde457e39 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 14:54:26 -0600 Subject: [PATCH 07/14] `get_post_embed_html()` used in fixture generation assumes `wp-includes/js/wp-embed.js` exists --- tests/phpunit/tests/rest-api/rest-schema-setup.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/phpunit/tests/rest-api/rest-schema-setup.php b/tests/phpunit/tests/rest-api/rest-schema-setup.php index bf3d0d4703f37..80181b2a04365 100644 --- a/tests/phpunit/tests/rest-api/rest-schema-setup.php +++ b/tests/phpunit/tests/rest-api/rest-schema-setup.php @@ -22,6 +22,9 @@ public function set_up() { do_action( 'rest_api_init', $wp_rest_server ); add_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10, 3 ); + + // `get_post_embed_html()` used in fixture generation assumes `wp-includes/js/wp-embed.js` exists. + self::touch( ABSPATH . WPINC . '/js/wp-embed.js' ); } public function tear_down() { From 9643a5e066d7406c8dac9cd83e19cb1749b630c2 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 15:11:59 -0600 Subject: [PATCH 08/14] Revert "move wp_create_initial_comment_meta to rest_api_init hook" This reverts commit 55011513596eebd858824299737eb1926fc97405. --- src/wp-includes/comment.php | 1 + src/wp-includes/default-filters.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index aa841bfda976f..74b5568880439 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -4135,3 +4135,4 @@ function wp_create_initial_comment_meta() { ) ); } +add_action( 'init', 'wp_create_initial_comment_meta' ); diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 3bac93742bab0..5dc54c3686b3a 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -531,7 +531,6 @@ add_action( 'rest_api_init', 'register_initial_settings', 10 ); add_action( 'rest_api_init', 'create_initial_rest_routes', 99 ); add_action( 'parse_request', 'rest_api_loaded' ); -add_action( 'rest_api_init', 'wp_create_initial_comment_meta' ); // Abilities API. add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' ); From 1cba83918cbff0a8a60bfcb758b0ea50719a16c5 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 17:02:28 -0600 Subject: [PATCH 09/14] Hook meta registration on rest_api_init so it is included for tests --- src/wp-includes/comment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 74b5568880439..acc3379bbe3be 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -4135,4 +4135,4 @@ function wp_create_initial_comment_meta() { ) ); } -add_action( 'init', 'wp_create_initial_comment_meta' ); +add_action( 'rest_api_init', 'wp_create_initial_comment_meta' ); From a9ffe5c84aaafc0d10b7c24303ab119cf980872e Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 17:02:53 -0600 Subject: [PATCH 10/14] Expand test to check that meta is successfully set --- tests/phpunit/tests/rest-api/rest-comments-controller.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index e0868bbeca362..d1e1de901215c 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -3888,6 +3888,11 @@ public function test_create_empty_note_with_resolution_meta( $status ) { $response = rest_get_server()->dispatch( $request ); $this->assertSame( 201, $response->get_status() ); + + $data = $response->get_data(); + $this->assertArrayHasKey( 'meta', $data ); + $this->assertArrayHasKey( '_wp_note_status', $data['meta'] ); + $this->assertSame( $status, $data['meta']['_wp_note_status'] ); } /** From 2188f3e556431ed7dd1932581a54828944be5a0e Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 17:03:52 -0600 Subject: [PATCH 11/14] Fix generation of wp-api fixtures and regnerate with new meta present --- .../tests/rest-api/rest-schema-setup.php | 2 +- tests/qunit/fixtures/wp-api-generated.js | 28 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-schema-setup.php b/tests/phpunit/tests/rest-api/rest-schema-setup.php index 80181b2a04365..d5390afbeff1d 100644 --- a/tests/phpunit/tests/rest-api/rest-schema-setup.php +++ b/tests/phpunit/tests/rest-api/rest-schema-setup.php @@ -23,7 +23,7 @@ public function set_up() { add_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10, 3 ); - // `get_post_embed_html()` used in fixture generation assumes `wp-includes/js/wp-embed.js` exists. + // `get_post_embed_html()` assumes `wp-includes/js/wp-embed.js` is present: self::touch( ABSPATH . WPINC . '/js/wp-embed.js' ); } diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index de83c1248e3db..ad92345619fe0 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -11654,7 +11654,18 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "_wp_note_status": { + "type": "string", + "title": "", + "description": "Note resolution status", + "default": "", + "enum": [ + "resolved", + "reopen" + ] + } + }, "required": false } } @@ -11801,7 +11812,18 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": [], + "properties": { + "_wp_note_status": { + "type": "string", + "title": "", + "description": "Note resolution status", + "default": "", + "enum": [ + "resolved", + "reopen" + ] + } + }, "required": false } } @@ -15480,6 +15502,7 @@ mockedApiResponse.CommentsCollection = [ "96": "https://secure.gravatar.com/avatar/9ca51ced0b389ffbeba3d269c6d824be664c84fa1b35503282abdd302e1f417c?s=96&d=mm&r=g" }, "meta": { + "_wp_note_status": null, "meta_key": "meta_value" }, "_links": { @@ -15534,6 +15557,7 @@ mockedApiResponse.CommentModel = { "96": "https://secure.gravatar.com/avatar/9ca51ced0b389ffbeba3d269c6d824be664c84fa1b35503282abdd302e1f417c?s=96&d=mm&r=g" }, "meta": { + "_wp_note_status": null, "meta_key": "meta_value" } }; From 31d9ef95e1aff4ced0f9a14a9f3cf5f8cee3e6b0 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 17:04:38 -0600 Subject: [PATCH 12/14] iInclude _wp_note_status in expected meta when testing comment meta --- tests/qunit/wp-includes/js/wp-api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qunit/wp-includes/js/wp-api.js b/tests/qunit/wp-includes/js/wp-api.js index be0249462d398..14ad7ec89cac9 100644 --- a/tests/qunit/wp-includes/js/wp-api.js +++ b/tests/qunit/wp-includes/js/wp-api.js @@ -404,6 +404,9 @@ if ( 'Tags' === modelType ) { expectedMetas = '{"test_single":"","test_multi":[],"meta_key":"meta_value","test_tag_meta":""}'; } + if ( 'Comments' === modelType ) { + expectedMetas = '{"_wp_note_status":null,"meta_key":"meta_value"}'; + } // Verify the meta object returned correctly from `getMetas()`. assert.equal( JSON.stringify( endpoint.getMetas() ), expectedMetas, 'Full meta key/values object should be readable.' ); From 713c73cf5c05a176266745c2c19bf0125467b69f Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Thu, 30 Oct 2025 13:27:16 +0900 Subject: [PATCH 13/14] Explicitly register comment meta in unit tests and revert the action hook back to init --- src/wp-includes/comment.php | 1 - src/wp-includes/default-filters.php | 1 + tests/phpunit/tests/rest-api/rest-comments-controller.php | 2 ++ 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index acc3379bbe3be..aa841bfda976f 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -4135,4 +4135,3 @@ function wp_create_initial_comment_meta() { ) ); } -add_action( 'rest_api_init', 'wp_create_initial_comment_meta' ); diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 5dc54c3686b3a..f59d25b4fd0e3 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -151,6 +151,7 @@ add_action( 'added_comment_meta', 'wp_cache_set_comments_last_changed' ); add_action( 'updated_comment_meta', 'wp_cache_set_comments_last_changed' ); add_action( 'deleted_comment_meta', 'wp_cache_set_comments_last_changed' ); +add_action( 'init', 'wp_create_initial_comment_meta' ); // Places to balance tags on input. foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) { diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index d1e1de901215c..7a5109b25d909 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -170,6 +170,8 @@ public static function wpTearDownAfterClass() { public function set_up() { parent::set_up(); $this->endpoint = new WP_REST_Comments_Controller(); + wp_create_initial_comment_meta(); + if ( is_multisite() ) { update_site_option( 'site_admins', array( 'superadmin' ) ); } From 1c75fb910d14ce9c2daea3f072bd2d5b7008f109 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Thu, 30 Oct 2025 13:29:20 +0900 Subject: [PATCH 14/14] Revert some changes --- .../tests/rest-api/rest-schema-setup.php | 3 -- tests/qunit/fixtures/wp-api-generated.js | 28 ++----------------- tests/qunit/wp-includes/js/wp-api.js | 3 -- 3 files changed, 2 insertions(+), 32 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-schema-setup.php b/tests/phpunit/tests/rest-api/rest-schema-setup.php index d5390afbeff1d..bf3d0d4703f37 100644 --- a/tests/phpunit/tests/rest-api/rest-schema-setup.php +++ b/tests/phpunit/tests/rest-api/rest-schema-setup.php @@ -22,9 +22,6 @@ public function set_up() { do_action( 'rest_api_init', $wp_rest_server ); add_filter( 'pre_http_request', array( $this, 'mock_embed_request' ), 10, 3 ); - - // `get_post_embed_html()` assumes `wp-includes/js/wp-embed.js` is present: - self::touch( ABSPATH . WPINC . '/js/wp-embed.js' ); } public function tear_down() { diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index ad92345619fe0..de83c1248e3db 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -11654,18 +11654,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "_wp_note_status": { - "type": "string", - "title": "", - "description": "Note resolution status", - "default": "", - "enum": [ - "resolved", - "reopen" - ] - } - }, + "properties": [], "required": false } } @@ -11812,18 +11801,7 @@ mockedApiResponse.Schema = { "meta": { "description": "Meta fields.", "type": "object", - "properties": { - "_wp_note_status": { - "type": "string", - "title": "", - "description": "Note resolution status", - "default": "", - "enum": [ - "resolved", - "reopen" - ] - } - }, + "properties": [], "required": false } } @@ -15502,7 +15480,6 @@ mockedApiResponse.CommentsCollection = [ "96": "https://secure.gravatar.com/avatar/9ca51ced0b389ffbeba3d269c6d824be664c84fa1b35503282abdd302e1f417c?s=96&d=mm&r=g" }, "meta": { - "_wp_note_status": null, "meta_key": "meta_value" }, "_links": { @@ -15557,7 +15534,6 @@ mockedApiResponse.CommentModel = { "96": "https://secure.gravatar.com/avatar/9ca51ced0b389ffbeba3d269c6d824be664c84fa1b35503282abdd302e1f417c?s=96&d=mm&r=g" }, "meta": { - "_wp_note_status": null, "meta_key": "meta_value" } }; diff --git a/tests/qunit/wp-includes/js/wp-api.js b/tests/qunit/wp-includes/js/wp-api.js index 14ad7ec89cac9..be0249462d398 100644 --- a/tests/qunit/wp-includes/js/wp-api.js +++ b/tests/qunit/wp-includes/js/wp-api.js @@ -404,9 +404,6 @@ if ( 'Tags' === modelType ) { expectedMetas = '{"test_single":"","test_multi":[],"meta_key":"meta_value","test_tag_meta":""}'; } - if ( 'Comments' === modelType ) { - expectedMetas = '{"_wp_note_status":null,"meta_key":"meta_value"}'; - } // Verify the meta object returned correctly from `getMetas()`. assert.equal( JSON.stringify( endpoint.getMetas() ), expectedMetas, 'Full meta key/values object should be readable.' );