Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#42175 closed defect (bug) (fixed)

Customize: Remove call to `wp_trash_post()`

Reported by: dlh's profile dlh Owned by: westonruter's profile westonruter
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.9
Component: Customize Keywords: has-patch
Focuses: Cc:

Description

WP_Customize_Manager::handle_changeset_trash_request() includes a call to wp_trash_post(), which was purposefully not called in _wp_customize_publish_changeset() because it "will mutate the post_content and the post_name."

As discussed in Slack, the logic for trashing a changeset could be moved to a method in WP_Customize_Manager that both functions can use: https://wordpress.slack.com/archives/C0381N237/p1507503461000055.

Note that it might make sense for this logic to one day be moved again to a dedicated WP_Customize_Changeset class. The method in the attached patch is largely borrowed from the latest patch in #40527.

The patch also adds the 'pre_trash_post' filter from [41638].

Attachments (1)

42175.diff (5.9 KB) - added by dlh 7 years ago.

Download all attachments as: .zip

Change History (3)

@dlh
7 years ago

#1 @westonruter
7 years ago

  • Milestone changed from Awaiting Review to 4.9
  • Owner set to westonruter
  • Status changed from new to accepted

#2 @westonruter
7 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 41824:

Customize: Introduce WP_Customize_Manager::trash_changeset_post() to reduce duplication and ensure proper changeset trashing logic.

Trashing a changeset via wp_trash_post() does not have the desired result since it mutates post_content (via Kses) and the post_name (even though it is a UUID).

Props dlh.
See #39896, #42030.
Fixes #42175.

Note: See TracTickets for help on using tickets.