WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 4 years ago

Last modified 3 years ago

#23691 closed defect (bug) (fixed)

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

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

Description

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 6 years ago.
wp-includes/post.php
23691.patch (1.7 KB) - added by azaozz 4 years ago.

Download all attachments as: .zip

Change History (13)

#1 @c3mdigital
6 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
6 years ago

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

#3 @helen
6 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
6 years ago

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

#5 @helen
6 years ago

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

@utkarshd_42
6 years ago

wp-includes/post.php

#6 @iseulde
5 years ago

  • Component changed from Autosave to Editor

#7 @azaozz
4 years ago

  • Milestone changed from Awaiting Review to 4.4

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

Last edited 4 years ago by azaozz (previous) (diff)

#8 @azaozz
4 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.

@azaozz
4 years ago

#9 @azaozz
4 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
4 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.


3 years ago

Note: See TracTickets for help on using tickets.