Make WordPress Core

Opened 6 years ago

Last modified 6 years ago

#44835 reviewing defect (bug)

Add a hidden input for 'original_post_status' to the inline-edit rows so it's available on the $_POST in save_post

Reported by: garrett-eclipse's profile garrett-eclipse Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch needs-refresh needs-testing
Focuses: administration Cc:

Description (last modified by garrett-eclipse)

Hello,

Can we add a hidden input for 'original_post_status' into the '.inline-edit-save' div found in the inline-edit rows so that it's available on the $_POST object form save_post as it is when you save a post from the post edit screen.

Background: I am writing a plugin for a client to introduce Draft Revisions on published posts. I have a cleanup function tied to save_post which purges the Draft Revisions if the post being saved has a status of 'publish' or was previously 'publish'. From normal post submission the original_post_status is available on the $_POST as it's a hidden input on the post editor. From inline-edits this fails as there's no hidden input for original_post_status.

I searched for some time to come up with a solution and settled on a jquery trigger which injected the missing input when the inline-edit row opens. With it present the existing ajax/etc fires properly and populated the missing $_POST['original_post_status'] that I required.

Proposition: Add the hidden input for original_post_status onto the inline edit rows to make that information available to save_post.

Thank you

Attachments (1)

44835.diff (1.8 KB) - added by jojotjebaby 6 years ago.
Added the hidden field next to the other fields. Now the original_post_status is available in the POST data

Download all attachments as: .zip

Change History (12)

#1 @garrett-eclipse
6 years ago

  • Description modified (diff)

#2 @mukesh27
6 years ago

  • Focuses administration added
  • Keywords has-patch added

#3 @garrett-eclipse
6 years ago

  • Keywords needs-patch good-first-bug added; has-patch removed

@jojotjebaby
6 years ago

Added the hidden field next to the other fields. Now the original_post_status is available in the POST data

#4 @jojotjebaby
6 years ago

  • Keywords has-patch added; needs-patch removed

I added a patch in order to make available the $_POSToriginal_post_status?. I also had to change some code in the JS file for changing the value of this field after updating. Without the JS, the field would only reflect the old post status upon pageload. And would not change after saving changes in the inline editor.

Please review my submission :)

#5 @SergeyBiryukov
6 years ago

  • Milestone changed from Awaiting Review to 4.9.9
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#6 @pento
6 years ago

  • Milestone changed from 4.9.9 to 5.0.1

#7 @pento
6 years ago

  • Milestone changed from 5.0.1 to 5.0.2

#8 @pento
6 years ago

  • Milestone changed from 5.0.2 to 5.0.3

#9 @audrasjb
6 years ago

  • Keywords dev-feedback added
  • Milestone changed from 5.0.3 to 5.1

5.0.3 is going to be released in a couple of weeks. We are currently sorting the remaining tickets in the milestone. It doesn't appear that ticket can be handled in the next couple of weeks (still needs review from component maintainers). Let's address that in 5.1 which is coming in February. Feel free to change/ask to change the milestone if you think the issue can be quickly resolved.

#10 @garrett-eclipse
6 years ago

  • Keywords good-first-bug removed

#11 @garrett-eclipse
6 years ago

  • Keywords needs-refresh needs-testing added; dev-feedback removed
  • Milestone changed from 5.1 to Future Release

Hi @jojotjebaby thanks for putting a patch forward for this.

After testing I found an issue with the javascript update as it wasn't specific to the row being edited so when a change was made ALL rows were updated with the new original_post_status. We'll have to ensure it's specific to the row being edited.

Also in one test I have a Draft and a Published post but both of their original_post_status hidden inputs on load were set to draft, and if I flipped them so publish was the first post then both end up with an original_post_status of publish. So it seems the first post in the loop will be used to set the original_post_status for all that follow.

Are you able to investigate? As there's need of a refresh and 5.1 is being cut today I'm going to punt this to Future Release until a fix can be implemented and tested.

Thank you

Note: See TracTickets for help on using tickets.