Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently it's been discovered that WordCamp events have been moving from
Scheduled
toNeeds Scheduling
automatically. This is confusing, because there's no automation that would result in that.This is a long winded explanation, as I was confused while trying to work it out.
This happened due to c914a9f
Specifically, this:
WordCamps are moved to closed by a cron job.
That cron job obviously runs without a user context. (This shows up as ‘WordCamp Bot’ in the logs, as that’s the text for “no user recorded”)
wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php
Lines 1129 to 1166 in b8dea08
Due to the above code change; that function now works.. it previously only worked when within a wp-admin context, as get_post( null ) would return the proper post, but during cron would return nothing. After the above notice fix, it now returns the proper post in both contexts.
Next; The current user (which is not set) can’t modify the post, as such, when the cron tries to close it, the post_status is reset to the current status of wcpt-scheduled
That’s fine; That should mean zero changes happen, right? Kind of.
wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php
Lines 827 to 831 in b8dea08
When a post is updated, and it’s being moved to scheduled it checks to see if the appropriate post_meta is set, and if not, pushes it back to
needs-scheduling
.That checks
$_POST
and not the post object, because the post_meta might not yet exist.When running as cron,
$_POST
won’t be set with the post meta, so it fails, and it get pushed back to needs-scheduling.wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php
Lines 845 to 893 in b8dea08
And that’s how it’s been going from
wcpt-scheduled
->wcpt-needs-scheduling
, because it’s actually been goingscheduled
-> (closed
->scheduled
->needs-scheduling
)This is a long-winded way to say; The code that enforces the post_status, just needs to acknowledge that during cron, a WordCamp post may change status, and that a user is not required to be present for that.
The alternative option, is that we could
wp_set_current_user( wordcamp )
during theclose wordcamp
routines, but I think checking for cron is enough here, as this isn't the primary authentication, this is just a just-in-case validation check.