Make WordPress Core

Opened 11 years ago

Closed 9 years ago

Last modified 8 years ago

#23691 closed defect (bug) (fixed)

Visiting post-new.php using the back button overwrites an existing post

Reported by: jkudish's profile jkudish Owned by: azaozz's profile azaozz
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch needs-testing
Focuses: Cc:


1) visit post-new.php
2) write a post
3) publish it
4) click back in your browser
5) write a new post
6) if you save it as draft or publish it, it will overwrite the old post

Reproducable in Firefox, Chrome and Safari.

Attachments (2)

post.php.patch (785 bytes) - added by utkarshd_42 10 years ago.
23691.patch (1.7 KB) - added by azaozz 9 years ago.

Download all attachments as: .zip

Change History (13)

#1 @c3mdigital
11 years ago

I can confirm.

I think we should add an admin notice here. The title div gets cleared but the content is still there.

#2 @DrewAPicture
11 years ago

So maybe it would be better to add an AYS (are you sure) if you're trying to navigate away.

#3 @helen
11 years ago

I guess it's happening because post-new.php makes an auto-draft and already has a post ID in a hidden input. Not sure an admin notice or an AYS can be added in this situation.

#4 @nacin
11 years ago

Maybe there is a way to block this and/or force a refresh?

#5 @helen
11 years ago

Probably some combination of headers would help, but not sure how universally reliable it is.

10 years ago


#6 @iseulde
9 years ago

  • Component changed from Autosave to Editor

#7 @azaozz
9 years ago

  • Milestone changed from Awaiting Review to 4.4

We can try using cookies or sessionStorage to detect when the back button was pressed, then do window.location.reload(true);.

Version 0, edited 9 years ago by azaozz (next)

#8 @azaozz
9 years ago

This also happens in Press This. To reproduce:

  1. Go to press this url (e,g. site.domain/wp-admin/press-this.php).
  2. Enter some content.
  3. Publish. It redirects you to the new post.
  4. Click the back button in your browser.
  5. Enter some new content.
  6. Publish.

The previous post is overwritten.
Also reported by jkudish.

9 years ago

#9 @azaozz
9 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

Adding a query string to the current location (23691.patch) seems to force the browser to reload the page on pressing the back button.

#10 @azaozz
9 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 33836:

Editor, Press This: force a page reload when the user publishes a post and then clicks the back button.
Fixes #23691.

This ticket was mentioned in Slack in #core-editor by iseulde. View the logs.

8 years ago

Note: See TracTickets for help on using tickets.