Skip to content

Heartbeat: Fix post lock detection race when wp_check_post_lock_window falls below the background heartbeat interval#11732

Open
Sukhendu2002 wants to merge 3 commits into
WordPress:trunkfrom
Sukhendu2002:fix/post-lock-heartbeat-background-tab-race
Open

Heartbeat: Fix post lock detection race when wp_check_post_lock_window falls below the background heartbeat interval#11732
Sukhendu2002 wants to merge 3 commits into
WordPress:trunkfrom
Sukhendu2002:fix/post-lock-heartbeat-background-tab-race

Conversation

@Sukhendu2002
Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/65171


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@Sukhendu2002 Sukhendu2002 marked this pull request as ready for review May 6, 2026 10:28
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sukhendu2002, adamsilverstein.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Copy Markdown
Member

@adamsilverstein adamsilverstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Adding some tests would be good.

@adamsilverstein
Copy link
Copy Markdown
Member

Thanks for working on this @Sukhendu2002 — nice fix.

To help land this, I drafted PHPUnit coverage for the new post_lock_window setting in wp_heartbeat_set_suspension() on top of your branch (rebased on current trunk so the test file added in r60520 / 7938204 is present):

https://github.com/adamsilverstein/wordpress-develop/tree/trac-65171-tests

The single test commit is:
adamsilverstein@2139778d90

It adds three cases to Tests_Admin_Includes_Misc_WpHeartbeatSetSuspension_Test:

  • post_lock_window is exposed as 150 on post.php and post-new.php.
  • post_lock_window is omitted on non-post screens (index.php, edit.php).
  • post_lock_window honors the wp_check_post_lock_window filter (verified with a custom value of 60).

Locally: OK (9 tests, 11 assertions).

Feel free to fold these into this PR if you'd like — happy to push to your branch directly if that's easier. Let me know.

Sukhendu2002 and others added 2 commits May 14, 2026 16:36
Add coverage for the heartbeat setting exposed in [r/PR WordPress#11732]:

- post_lock_window is set to the default 150 on post.php and post-new.php.
- post_lock_window is omitted on non-post screens (index.php, edit.php).
- post_lock_window reflects the wp_check_post_lock_window filter value.

See #65171.
@Sukhendu2002
Copy link
Copy Markdown
Author

Thanks @adamsilverstein! I've cherry-picked your test commit into my branch. All tests passing. Appreciate the coverage!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants