Opened 12 years ago
Last modified 2 weeks ago
#28288 new defect (bug)
New Post overwriting a previously published post
| Reported by: | jackreichert | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Posts, Post Types | Version: | 2.5 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: | administration |
Description
This was seen on wordpress.com, a user had multiple draft windows open. At one point when saving one draft, it wrote over another previously published post.
I believe that it was caused by a race condition that has to do with the environment being hosted on multiple servers.
To reproduce:
- Open in quick succession multiple draft windows.
- Check in developer tools for post_id duplicate.
I believe that a possible solution would be to enhance post-locking to include if a post is open in duplicate windows by the same user.
Attachments (3)
Change History (14)
#3
@
12 years ago
I think this fix makes sense!
Since we are doing post locking you shouldn't be able to edit the same post from two locations, even you are the same user. The whole point of post locking is to prevent the strange things that happen when two sessions edit the same post (autosaves esp. - see #28378) - being the same user doesn't help the situation.
Am I missing a use case where one user should be able to edit a post from two windows or locations?
This ticket was mentioned in IRC in #wordpress-dev by DrewAPicture. View the logs.
12 years ago
#6
@
12 years ago
- Keywords dev-feedback added
The patch still applies cleanly and I think is good to go for 4.0.
Maybe @azaozz can review to verify sanity of change?
#7
@
12 years ago
After some discussion with azaozz and some further testing, its clear this will not work - the post lock is never cleared and when saving, auto-saving or even reloading you are locked out.
Here is a screencast showing the issue (with the patch applied).
#9
@
12 years ago
- Keywords close removed
- Milestone 4.0 → Awaiting Review
Probably still an issue worth investigating, but a punt for 4.0, given that we don't have a viable approach.
This ticket was mentioned in PR #12330 on WordPress/wordpress-develop by @arkaprabhachowdhury.
2 weeks ago
#11
- Keywords has-patch has-unit-tests added; needs-patch removed
## Summary
- treat a stale same-user ctive_post_lock as a lock conflict while still allowing the current editing session to keep its lock
- pass the active post lock through classic autosave requests and use it during heartbeat refresh checks
- add PHPUnit coverage for current-session and stale same-user lock behavior, plus the autosave fallback path
Fixes https://core.trac.wordpress.org/ticket/28288
## Testing
- php -l src/wp-admin/includes/post.php
- php -l src/wp-admin/includes/misc.php
- php -l tests/phpunit/tests/admin/includesPost.php
- php -l tests/phpunit/tests/ajax/wpAjaxHeartbeat.php
- php ./vendor/bin/phpcs src/wp-admin/includes/post.php src/wp-admin/includes/misc.php tests/phpunit/tests/admin/includesPost.php tests/phpunit/tests/ajax/wpAjaxHeartbeat.php
## Notes
- Full PHPUnit execution is not included here because the repo's Docker-backed test environment was unavailable locally (./pipe/dockerDesktopLinuxEngine not found).
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Removes user check so that filelock will happen if the same post is opened in two separate windows.