Conversation
|
Build files for a889481 are ready:
|
benbowler
left a comment
There was a problem hiding this comment.
A few inline comments.
After doing this I noticed that the plugin is still showing the difference in timings in the tester plugin:
I found a few bugs in date/timezone shifting in the tester plugin, so I've fixed it, as well as updated it to pass the timestamp, and will share it in Slack for testing.
| self::factory()->user->create(), | ||
| ); | ||
|
|
||
| $scheduled_timestamp = 1_700_010_000; |
There was a problem hiding this comment.
It's worth adding a comment for readability here or using strtotime to make this readable.
| } | ||
|
|
||
| public function test_handle_callback_action_without_subscribers_still_schedules_follow_up_events() { | ||
| $scheduled_timestamp = 1_700_020_000; |
| return; | ||
| } | ||
|
|
||
| $next = $this->frequency_planner->next_occurrence( $frequency, time(), wp_timezone() ); |
There was a problem hiding this comment.
This code is adding wp_timezone calls, which are not compatible with WP 5.2. Can this be updated here to us BC_Functions so that it doesn't need to be captured in #12311
There was a problem hiding this comment.
That's a good point, it will be faster to include it here
| @@ -93,7 +93,59 @@ public function schedule_initiator_once( $frequency ) { | |||
| public function schedule_next_initiator( $frequency, $timestamp ) { | |||
| $next = $this->frequency_planner->next_occurrence( $frequency, $timestamp, wp_timezone() ); | |||
📦 Build files for 50da565:
🎭 Playwright reports for 50da565: |
tofumatt
left a comment
There was a problem hiding this comment.
This looks good, but I have concerns about the private API usage 😅
| * @return int|false Timestamp if found, otherwise false. | ||
| */ | ||
| public function get_initiator_timestamp( $frequency ) { | ||
| $cron = _get_cron_array(); |
There was a problem hiding this comment.
🤔 This is a private function (clearly marked as such with the leading underscore) and is explicitly marked as not being for third-parties to use/rely on: https://developer.wordpress.org/reference/functions/_get_cron_array/
Using private functions like this could cause Site Kit to break unexpectedly in the future—I know we test nightly versions of WordPress right now to check on this sort of thing, but is there any way we can get this data without relying on a private API?
I'd really rather us not use APIs like this, and it wasn't mentioned in the IB.
If we do need to use this, at the absolute minimum, we should thoroughly document our reasoning for using this private API (why public APIs can't provide the data we need).
I can see we have tests for this function so that's good 😄.
There was a problem hiding this comment.
We are using it here because of dynamic timestamp argument, so default wp_next_scheduled check won;t do as we don't have static arguments for hook to be correctly identified. The reasoning is explained in detail already in the method header doc:
/**
* Gets the timestamp of the next initiator event for a frequency.
*
* We intentionally scan cron entries instead of usingwp_next_scheduled()
* because initiators are scheduled with dynamic args:
*[ $frequency, $scheduled_timestamp ].wp_next_scheduled()requires an
* exact args match, but here we only need to know whether any initiator
* exists for a given frequency regardless of its scheduled timestamp.
*
* @SInCE n.e.x.t
*
* @param string $frequency Frequency slug.
* @return int|false Timestamp if found, otherwise false.
*/
Similar reason we also use this internal check on uninstallation hook:
site-kit-wp/includes/Core/Util/Uninstallation.php
Lines 160 to 173 in 424e7e4
tofumatt
left a comment
There was a problem hiding this comment.
Cool, makes sense, thanks! 👍🏻
Summary
Addresses issue:
Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist