[wp-trac] [WordPress Trac] #61550: Template contents are wiped out on rename

WordPress Trac noreply at wordpress.org
Wed Jul 24 14:38:39 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 fixed-major dev-reviewed  |     Focuses:
------------------------------------------------+--------------------------
Changes (by Bernhard Reiter):

 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 In [changeset:"58802" 58802]:
 {{{
 #!CommitTicketReference repository="" revision="58802"
 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.

 Reviewed by gziolo.
 Merges [58785] to the 6.6 branch.

 Props alshakero, bernhard-reiter.
 Fixes #61550.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61550#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list