Opened 5 years ago
Last modified 4 weeks ago
#53417 new defect (bug)
The revisions endpoints provide an incorrect JSON schema
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 4.7 |
| Component: | Revisions | Keywords: | has-patch has-unit-tests |
| Focuses: | rest-api | Cc: |
Description (last modified by )
The schema provided by the REST API endpoints for revisions at wp/v2/posts/{id}/revisions and wp/v2/pages/{id}/revisions is incorrect. The schema states that content.protected and excerpt.protected properties exist for each revision, but these properties do not exist.
- The schema is constructed here from the parent controller for posts, which does include this property
- When the content data is prepared here the
protectedproperty is not included - When the excerpt data is prepared here the
protectedproperty is not included
Two options:
- Remove the
content.protectedandexcerpt.protectedproperties from the schema - Add the
content.protectedandexcerpt.protectedproperties to the response
Here is the content property from the schema. Note the protected.context property states that the property exists for all three contexts.
"content": {
"description": "The content for the post.",
"type": "object",
"context": [
"view",
"edit"
],
"properties": {
"raw": {
"description": "Content for the post, as it exists in the database.",
"type": "string",
"context": [
"edit"
]
},
"rendered": {
"description": "HTML content for the post, transformed for display.",
"type": "string",
"context": [
"view",
"edit"
],
"readonly": true
},
"block_version": {
"description": "Version of the content block format used by the post.",
"type": "integer",
"context": [
"edit"
],
"readonly": true
},
"protected": {
"description": "Whether the content is protected with a password.",
"type": "boolean",
"context": [
"view",
"edit",
"embed"
],
"readonly": true
}
}
},
Change History (4)
This ticket was mentioned in PR #11569 on WordPress/wordpress-develop by @lakshyajeet.
4 weeks ago
#4
- Keywords has-patch has-unit-tests added; needs-patch removed
Trac ticket: https://core.trac.wordpress.org/ticket/53417
The schema provided by the REST API endpoints for revisions at wp/v2/posts/{id}/revisions and wp/v2/pages/{id}/revisions incorrectly states that content.protected and excerpt.protected properties exist. Revisions do not inherently support password protection in their response payloads, as they belong to the parent post.
This PR fixes the issue by removing the protected property from the revision schema for both the content and excerpt fields within WP_REST_Revisions_Controller::get_item_schema().
### Use of AI Tools
AI assistance: Yes
Tool(s): Github Copilot (Claude 4.6 Sonnet, Gemini 3.1 Pro)
Used for: Discussing the implementation approach and refining the PHPUnit tests for schema validation. Final code and tests were reviewed and verified locally by me.
Update: the same applies to
excerpt.protectedtoo.