Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around race condition when publishing local only posts #959

Merged
merged 7 commits into from
Oct 30, 2024

Conversation

pfefferle
Copy link
Member

It seems that the meta-information might not always be stored when saving a new post.

See discussion here: https://sueden.social/@freuwesen/113378039196820044 (it is in german but mastodon can translate).

Proposed changes:

  • clear audience fields, so that post will not be listed in any timeline when accidentally shared
  • check a second time, right before federating it

@pfefferle pfefferle self-assigned this Oct 28, 2024
Copy link
Contributor

@mattwiebe mattwiebe left a comment

Choose a reason for hiding this comment

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

Could we also maybe add a slight delay to the scheduler to give more time for the race condition to resolve?

includes/functions.php Outdated Show resolved Hide resolved
@pfefferle
Copy link
Member Author

Could we also maybe add a slight delay to the scheduler to give more time for the race condition to resolve?

with a "hacky" sleep(2)?

do have an idea if there is a better hook to use?

maybe #668 ???

@mattwiebe
Copy link
Contributor

Could we also maybe add a slight delay to the scheduler to give more time for the race condition to resolve?

with a "hacky" sleep(2)?

do have an idea if there is a better hook to use?

maybe #668 ???

I'm thinking about where we schedule the cron job here. When the first arg is time() it's a near-instant cron job that is possibly running out ahead of the process that's trying to update postmeta to set private visibility. So we add 30 seconds:

\wp_schedule_single_event( \time() + 30, $hook, $args );

Or even less, maybe 5-10, something like that. Just gives all the saving processes a little more time to settle before blasting out the post.

@pfefferle
Copy link
Member Author

I See! Makes sense!

@pfefferle
Copy link
Member Author

@mattwiebe added all changes!

@pfefferle pfefferle merged commit a080976 into trunk Oct 30, 2024
21 checks passed
@pfefferle pfefferle deleted the fix/visibility-race-condition branch October 30, 2024 07:29
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