[wp-trac] [WordPress Trac] #61550: Template contents are wiped out on rename
WordPress Trac
noreply at wordpress.org
Tue Jul 23 13:41:29 UTC 2024
#61550: Template contents are wiped out on rename
-------------------------------------------------+-------------------------
Reporter: alshakero | Owner: Bernhard
| Reiter
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.6.2
Component: Editor | Version: 6.6
Severity: minor | Resolution: fixed
Keywords: has-patch needs-testing needs- | Focuses:
testing-info |
-------------------------------------------------+-------------------------
Changes (by Bernhard Reiter):
* owner: (none) => Bernhard Reiter
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"58785" 58785]:
{{{
#!CommitTicketReference repository="" revision="58785"
Block Hooks: Don't erase post content if it isn't changed by client.
The `inject_ignored_hooked_blocks_metadata_attributes` filter that is
attached to both the `rest_pre_insert_wp_template` and
`rest_pre_insert_wp_template_part` hooks receives a `stdClass` object from
the Templates REST API controller that contains all fields that the client
would like to modify when making a `POST` request (plus the `id` to
identify the relevant template or template part, respectively).
There are cases when the `post_content` field is not set, e.g. when the
client would like to rename an existing template (in which case it would
only set the `title` field).
Prior to this changeset, the filter would erroneously apply the Block
Hooks algorithm to the non-existent `post_content` field regardless, which
would result in it being set to the empty string `''`. As a consequence,
renaming a template would have the unwanted side effect of wiping its
contents.
This changeset fixes the issue by returning early from the filter if the
`post_content` field is not set.
Props alshakero, bernhard-reiter.
Fixes #61550.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61550#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list