Skip to content

Commit

Permalink
phpstan: fix wrong invocation of cron scheduling
Browse files Browse the repository at this point in the history
* documents scheduler code
  • Loading branch information
datengraben committed Dec 23, 2024
1 parent b98cc3b commit b771e60
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Service/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,15 @@ public static function clearCache( array $tags = [] ) {
* Calls clearCache using WP Cron.
* Why? ClearCache can be resource intensive on larger instances and should be offloaded.
*
* @param array $tags
* @param array $tags to clear cache for
*
* @return void
*/
public static function scheduleClearCache( array $tags = [] ) {
$event = wp_schedule_single_event( time(), self::$clearCacheHook, [ $tags ] );
$event = wp_schedule_single_event( time(), self::$clearCacheHook, [ $tags ], true );
// TODO document why only on wp-error, why this can fail, why we don't re-try or do other things, instead of forcing the execution of this resource intensive task?
if ( is_wp_error( $event ) ) {
//run the event right away when scheduling fails
// runs the event right away, when scheduling fails
self::clearCache( $tags );
}
}
Expand Down

0 comments on commit b771e60

Please sign in to comment.