From 40103f7dc11265a16aeb7951297297242df30c65 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Wed, 29 Oct 2025 17:59:30 +0900 Subject: [PATCH 01/16] 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/16] 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/16] 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/16] 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/16] 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/16] 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 779e3fb90ccedfb09f1574865b12d4c11f35d74e Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 13:52:10 -0600 Subject: [PATCH 07/16] revert generated change --- tests/qunit/fixtures/wp-api-generated.js | 41 ++++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index de83c1248e3db..a1846e383ca5a 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": "", @@ -11544,7 +11538,10 @@ mockedApiResponse.Schema = { "status": { "default": "approve", "description": "Limit result set to comments assigned a specific status. Requires authorization.", - "type": "string", + "type": [ + "string", + "array" + ], "required": false }, "type": { @@ -11654,7 +11651,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 +11809,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 +15499,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 +15554,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 33a13ac722233ca0760ddf8b3b1828215723f177 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 13:52:29 -0600 Subject: [PATCH 08/16] revert hook change --- src/wp-includes/comment.php | 2 ++ src/wp-includes/default-filters.php | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index aa841bfda976f..4bfb47d3a6f95 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -4135,3 +4135,5 @@ 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 64e80e1216ee65605202f1e8f7d123574f5846eb Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 14:00:16 -0600 Subject: [PATCH 09/16] Ensure schema generation works --- 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..d5390afbeff1d 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()` assumes `wp-includes/js/wp-embed.js` is present: + self::touch( ABSPATH . WPINC . '/js/wp-embed.js' ); } public function tear_down() { From 5c9ffead8028ca34f56c303e9ea566d8d72e22b3 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 14:02:49 -0600 Subject: [PATCH 10/16] whitespace --- src/wp-includes/comment.php | 1 - tests/qunit/fixtures/wp-api-generated.js | 33 +++--------------------- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 4bfb47d3a6f95..74b5568880439 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -4136,4 +4136,3 @@ function wp_create_initial_comment_meta() { ); } add_action( 'init', 'wp_create_initial_comment_meta' ); - diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index a1846e383ca5a..cb6a5960da458 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -11538,10 +11538,7 @@ mockedApiResponse.Schema = { "status": { "default": "approve", "description": "Limit result set to comments assigned a specific status. Requires authorization.", - "type": [ - "string", - "array" - ], + "type": "string", "required": false }, "type": { @@ -11651,18 +11648,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 } } @@ -11809,18 +11795,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 } } @@ -15499,7 +15474,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": { @@ -15554,7 +15528,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 061d8beb8ff7e996a1f7bace7c78832df59356ef Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 14:03:59 -0600 Subject: [PATCH 11/16] revert fixture change --- tests/qunit/fixtures/wp-api-generated.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index cb6a5960da458..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": "", From f52eedbe5c9945105616745d7933027d2109b6d8 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 16:03:31 -0600 Subject: [PATCH 12/16] Ensure the note status meta is set correctly --- 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 c2fc10cab7d2e827c70ff9c616d5a64b18b7a6f3 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 16:04:07 -0600 Subject: [PATCH 13/16] Hook meta setup on rest_api_init to ensure called 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 17ff108cffc065768a01147996890b654deb09fd Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 16:14:55 -0600 Subject: [PATCH 14/16] Update wp-api fixture --- tests/qunit/fixtures/wp-api-generated.js | 28 ++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) 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 b0daecffc23205bf82fc6cdfaa3c1c980ef3c1e7 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 16:30:55 -0600 Subject: [PATCH 15/16] Adjust meta support for Comments test expected meta to include _wp_note_status --- tests/qunit/wp-includes/js/wp-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qunit/wp-includes/js/wp-api.js b/tests/qunit/wp-includes/js/wp-api.js index be0249462d398..4e0b8bf65c5d2 100644 --- a/tests/qunit/wp-includes/js/wp-api.js +++ b/tests/qunit/wp-includes/js/wp-api.js @@ -400,7 +400,7 @@ // Get the main endpoint. var endpoint = theModels.at(0); - var expectedMetas = '{"meta_key":"meta_value"}'; + var expectedMetas = '{"_wp_note_status":null,"meta_key":"meta_value"}'; if ( 'Tags' === modelType ) { expectedMetas = '{"test_single":"","test_multi":[],"meta_key":"meta_value","test_tag_meta":""}'; } From 791eb7cef9b194caf82086a65884cfa261fb3c32 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 29 Oct 2025 16:43:05 -0600 Subject: [PATCH 16/16] Only adjust expected metas for Comments --- tests/qunit/wp-includes/js/wp-api.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/qunit/wp-includes/js/wp-api.js b/tests/qunit/wp-includes/js/wp-api.js index 4e0b8bf65c5d2..14ad7ec89cac9 100644 --- a/tests/qunit/wp-includes/js/wp-api.js +++ b/tests/qunit/wp-includes/js/wp-api.js @@ -400,10 +400,13 @@ // Get the main endpoint. var endpoint = theModels.at(0); - var expectedMetas = '{"_wp_note_status":null,"meta_key":"meta_value"}'; + var expectedMetas = '{"meta_key":"meta_value"}'; 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.' );