Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
download Action scheduler to 3.9.0
Browse files Browse the repository at this point in the history
wordpressfan committed Jan 30, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 98a0575 commit ac54560
Showing 21 changed files with 25 additions and 1,856 deletions.
16 changes: 8 additions & 8 deletions inc/Dependencies/ActionScheduler/action-scheduler.php
Original file line number Diff line number Diff line change
@@ -5,10 +5,10 @@
* Description: A robust scheduling library for use in WordPress plugins.
* Author: Automattic
* Author URI: https://automattic.com/
* Version: 3.9.1
* Version: 3.9.0
* License: GPLv3
* Requires at least: 6.5
* Tested up to: 6.5
* Tested up to: 6.7
* Requires PHP: 7.1
*
* Copyright 2019 Automattic, Inc. (https://automattic.com/contact/)
@@ -29,29 +29,29 @@
* @package ActionScheduler
*/

if ( ! function_exists( 'action_scheduler_register_3_dot_9_dot_1' ) && function_exists( 'add_action' ) ) { // WRCS: DEFINED_VERSION.
if ( ! function_exists( 'action_scheduler_register_3_dot_9_dot_0' ) && function_exists( 'add_action' ) ) { // WRCS: DEFINED_VERSION.

if ( ! class_exists( 'ActionScheduler_Versions', false ) ) {
require_once __DIR__ . '/classes/ActionScheduler_Versions.php';
add_action( 'plugins_loaded', array( 'ActionScheduler_Versions', 'initialize_latest_version' ), 1, 0 );
}

add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_9_dot_1', 0, 0 ); // WRCS: DEFINED_VERSION.
add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_9_dot_0', 0, 0 ); // WRCS: DEFINED_VERSION.

// phpcs:disable Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace
/**
* Registers this version of Action Scheduler.
*/
function action_scheduler_register_3_dot_9_dot_1() { // WRCS: DEFINED_VERSION.
function action_scheduler_register_3_dot_9_dot_0() { // WRCS: DEFINED_VERSION.
$versions = ActionScheduler_Versions::instance();
$versions->register( '3.9.1', 'action_scheduler_initialize_3_dot_9_dot_1' ); // WRCS: DEFINED_VERSION.
$versions->register( '3.9.0', 'action_scheduler_initialize_3_dot_9_dot_0' ); // WRCS: DEFINED_VERSION.
}

// phpcs:disable Generic.Functions.OpeningFunctionBraceKernighanRitchie.ContentAfterBrace
/**
* Initializes this version of Action Scheduler.
*/
function action_scheduler_initialize_3_dot_9_dot_1() { // WRCS: DEFINED_VERSION.
function action_scheduler_initialize_3_dot_9_dot_0() { // WRCS: DEFINED_VERSION.
// A final safety check is required even here, because historic versions of Action Scheduler
// followed a different pattern (in some unusual cases, we could reach this point and the
// ActionScheduler class is already defined—so we need to guard against that).
@@ -63,7 +63,7 @@ function action_scheduler_initialize_3_dot_9_dot_1() { // WRCS: DEFINED_VERSION.

// Support usage in themes - load this version if no plugin has loaded a version yet.
if ( did_action( 'plugins_loaded' ) && ! doing_action( 'plugins_loaded' ) && ! class_exists( 'ActionScheduler', false ) ) {
action_scheduler_initialize_3_dot_9_dot_1(); // WRCS: DEFINED_VERSION.
action_scheduler_initialize_3_dot_9_dot_0(); // WRCS: DEFINED_VERSION.
do_action( 'action_scheduler_pre_theme_init' );
ActionScheduler_Versions::initialize_latest_version();
}
7 changes: 0 additions & 7 deletions inc/Dependencies/ActionScheduler/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
*** Changelog ***

= 3.9.1 - 2025-01-21 =
* A number of new WP CLI commands have been added, making it easier to manage actions in the terminal and from scripts.
* New wp action-scheduler source command to help determine how Action Scheduler is being loaded.
* Additional information about the active instance of Action Scheduler is now available in the Help pull-down drawer.
* Make some other nullable parameters explicitly nullable.
* Set option value to `no` rather than deleting.

= 3.9.0 - 2024-11-14 =
* Minimum required version of PHP is now 7.1.
* Performance improvements for the `as_pending_actions_due()` function.
Original file line number Diff line number Diff line change
@@ -8,17 +8,17 @@ class ActionScheduler_ActionFactory {
/**
* Return stored actions for given params.
*
* @param string $status The action's status in the data store.
* @param string $hook The hook to trigger when this action runs.
* @param array $args Args to pass to callbacks when the hook is triggered.
* @param ActionScheduler_Schedule|null $schedule The action's schedule.
* @param string $group A group to put the action in.
* @param string $status The action's status in the data store.
* @param string $hook The hook to trigger when this action runs.
* @param array $args Args to pass to callbacks when the hook is triggered.
* @param ActionScheduler_Schedule $schedule The action's schedule.
* @param string $group A group to put the action in.
* phpcs:ignore Squiz.Commenting.FunctionComment.ExtraParamComment
* @param int $priority The action priority.
* @param int $priority The action priority.
*
* @return ActionScheduler_Action An instance of the stored action.
*/
public function get_stored_action( $status, $hook, array $args = array(), ?ActionScheduler_Schedule $schedule = null, $group = '' ) {
public function get_stored_action( $status, $hook, array $args = array(), ActionScheduler_Schedule $schedule = null, $group = '' ) {
// The 6th parameter ($priority) is not formally declared in the method signature to maintain compatibility with
// third-party subclasses created before this param was added.
$priority = func_num_args() >= 6 ? (int) func_get_arg( 5 ) : 10;
Original file line number Diff line number Diff line change
@@ -250,20 +250,7 @@ public function add_help_tabs() {
return;
}

$as_version = ActionScheduler_Versions::instance()->latest_version();
$as_source = ActionScheduler_Versions::instance()->active_source();
$as_source_path = ActionScheduler_Versions::instance()->active_source_path();
$as_source_markup = sprintf( '<code>%s</code>', esc_html( $as_source_path ) );

if ( ! empty( $as_source ) ) {
$as_source_markup = sprintf(
'%s: <abbr title="%s">%s</abbr>',
ucfirst( $as_source['type'] ),
esc_attr( $as_source_path ),
esc_html( $as_source['name'] )
);
}

$as_version = ActionScheduler_Versions::instance()->latest_version();
$screen->add_help_tab(
array(
'id' => 'action_scheduler_about',
@@ -273,19 +260,6 @@ public function add_help_tabs() {
'<h2>' . sprintf( __( 'About Action Scheduler %s', 'action-scheduler' ), $as_version ) . '</h2>' .
'<p>' .
__( 'Action Scheduler is a scalable, traceable job queue for background processing large sets of actions. Action Scheduler works by triggering an action hook to run at some time in the future. Scheduled actions can also be scheduled to run on a recurring schedule.', 'action-scheduler' ) .
'</p>' .
'<h3>' . esc_html__( 'Source', 'action-scheduler' ) . '</h3>' .
'<p>' .
esc_html__( 'Action Scheduler is currently being loaded from the following location. This can be useful when debugging, or if requested by the support team.', 'action-scheduler' ) .
'</p>' .
'<p>' . $as_source_markup . '</p>' .
'<h3>' . esc_html__( 'WP CLI', 'action-scheduler' ) . '</h3>' .
'<p>' .
sprintf(
/* translators: %1$s is WP CLI command (not translatable) */
esc_html__( 'WP CLI commands are available: execute %1$s for a list of available commands.', 'action-scheduler' ),
'<code>wp help action-scheduler</code>'
) .
'</p>',
)
);
Original file line number Diff line number Diff line change
@@ -18,13 +18,6 @@ class ActionScheduler_Versions {
*/
private $versions = array();

/**
* Registered sources.
*
* @var array<string, string>
*/
private $sources = array();

/**
* Register version's callback.
*
@@ -35,13 +28,7 @@ public function register( $version_string, $initialization_callback ) {
if ( isset( $this->versions[ $version_string ] ) ) {
return false;
}

// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
$backtrace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS );
$source = $backtrace[0]['file'];

$this->versions[ $version_string ] = $initialization_callback;
$this->sources[ $source ] = $version_string;
return true;
}

@@ -52,15 +39,6 @@ public function get_versions() {
return $this->versions;
}

/**
* Get registered sources.
*
* @return array<string, string>
*/
public function get_sources() {
return $this->sources;
}

/**
* Get latest version registered.
*/
@@ -108,79 +86,4 @@ public static function initialize_latest_version() {
$self = self::instance();
call_user_func( $self->latest_version_callback() );
}

/**
* Returns information about the plugin or theme which contains the current active version
* of Action Scheduler.
*
* If this cannot be determined, or if Action Scheduler is being loaded via some other
* method, then it will return an empty array. Otherwise, if populated, the array will
* look like the following:
*
* [
* 'type' => 'plugin', # or 'theme'
* 'name' => 'Name',
* ]
*
* @return array
*/
public function active_source(): array {
$file = __FILE__;
$dir = __DIR__;
$plugins = get_plugins();
$plugin_files = array_keys( $plugins );

foreach ( $plugin_files as $plugin_file ) {
$plugin_path = trailingslashit( WP_PLUGIN_DIR ) . dirname( $plugin_file );
$plugin_file = trailingslashit( WP_PLUGIN_DIR ) . $plugin_file;

if ( 0 !== strpos( dirname( $dir ), $plugin_path ) ) {
continue;
}

$plugin_data = get_plugin_data( $plugin_file );

if ( ! is_array( $plugin_data ) || empty( $plugin_data['Name'] ) ) {
continue;
}

return array(
'type' => 'plugin',
'name' => $plugin_data['Name'],
);
}

$themes = (array) search_theme_directories();

foreach ( $themes as $slug => $data ) {
$needle = trailingslashit( $data['theme_root'] ) . $slug . '/';

if ( 0 !== strpos( $file, $needle ) ) {
continue;
}

$theme = wp_get_theme( $slug );

if ( ! is_object( $theme ) || ! is_a( $theme, \WP_Theme::class ) ) {
continue;
}

return array(
'type' => 'theme',
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
'name' => $theme->Name,
);
}

return array();
}

/**
* Returns the directory path for the currently active installation of Action Scheduler.
*
* @return string
*/
public function active_source_path(): string {
return trailingslashit( dirname( __DIR__ ) );
}
}
Original file line number Diff line number Diff line change
@@ -66,23 +66,19 @@ public static function has_logs() {
* Attached to the migration complete hook 'action_scheduler/migration_complete'.
*/
public static function maybe_schedule_cleanup() {
$has_logs = 'no';

$args = array(
'type' => ActionScheduler_wpCommentLogger::TYPE,
'number' => 1,
'fields' => 'ids',
);

if ( (bool) get_comments( $args ) ) {
$has_logs = 'yes';
update_option( self::$has_logs_option_key, 'yes' );

if ( ! as_next_scheduled_action( self::$cleanup_hook ) ) {
as_schedule_single_action( gmdate( 'U' ) + ( 6 * MONTH_IN_SECONDS ), self::$cleanup_hook );
}
}

update_option( self::$has_logs_option_key, $has_logs, true );
}

/**
@@ -99,7 +95,7 @@ public static function delete_all_action_comments() {
)
);

update_option( self::$has_logs_option_key, 'no', true );
delete_option( self::$has_logs_option_key );
}

/**

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

194 changes: 0 additions & 194 deletions inc/Dependencies/ActionScheduler/classes/WP_CLI/Action/Run_Command.php

This file was deleted.

353 changes: 0 additions & 353 deletions inc/Dependencies/ActionScheduler/classes/WP_CLI/Action_Command.php

This file was deleted.

276 changes: 0 additions & 276 deletions inc/Dependencies/ActionScheduler/classes/WP_CLI/System_Command.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -240,8 +240,6 @@ function () {
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'action-scheduler', 'ActionScheduler_WPCLI_Scheduler_command' );
WP_CLI::add_command( 'action-scheduler', 'ActionScheduler_WPCLI_Clean_Command' );
WP_CLI::add_command( 'action-scheduler action', '\Action_Scheduler\WP_CLI\Action_Command' );
WP_CLI::add_command( 'action-scheduler', '\Action_Scheduler\WP_CLI\System_Command' );
if ( ! ActionScheduler_DataController::is_migration_complete() && Controller::instance()->allow_migration() ) {
$command = new Migration_Command();
$command->register();
@@ -298,7 +296,6 @@ protected static function is_class_abstract( $class ) {
'ActionScheduler_Abstract_Schema' => true,
'ActionScheduler_Store' => true,
'ActionScheduler_TimezoneHelper' => true,
'ActionScheduler_WPCLI_Command' => true,
);

return isset( $abstracts[ $class ] ) && $abstracts[ $class ];
@@ -343,11 +340,9 @@ protected static function is_class_migration( $class ) {
*/
protected static function is_class_cli( $class ) {
static $cli_segments = array(
'QueueRunner' => true,
'Command' => true,
'ProgressBar' => true,
'\Action_Scheduler\WP_CLI\Action_Command' => true,
'\Action_Scheduler\WP_CLI\System_Command' => true,
'QueueRunner' => true,
'Command' => true,
'ProgressBar' => true,
);

$segments = explode( '_', $class );

This file was deleted.

Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ abstract class ActionScheduler_Schedule_Deprecated implements ActionScheduler_Sc
*
* @return DateTime|null
*/
public function next( ?DateTime $after = null ) {
public function next( DateTime $after = null ) {
if ( empty( $after ) ) {
$return_value = $this->get_date();
$replacement_method = 'get_date()';
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ class CronExpression
*
* @return CronExpression
*/
public static function factory($expression, ?CronExpression_FieldFactory $fieldFactory = null)
public static function factory($expression, CronExpression_FieldFactory $fieldFactory = null)
{
$mappings = array(
'@yearly' => '0 0 1 1 *',
11 changes: 2 additions & 9 deletions inc/Dependencies/ActionScheduler/readme.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
=== Action Scheduler ===
Contributors: Automattic, wpmuguru, claudiosanches, peterfabian1000, vedjain, jamosova, obliviousharmony, konamiman, sadowski, royho, barryhughes-1
Tags: scheduler, cron
Stable tag: 3.9.1
Stable tag: 3.9.0
License: GPLv3
Requires at least: 6.5
Tested up to: 6.5
Tested up to: 6.7
Requires PHP: 7.1

Action Scheduler - Job Queue for WordPress
@@ -47,13 +47,6 @@ Collaboration is cool. We'd love to work with you to improve Action Scheduler. [

== Changelog ==

= 3.9.1 - 2025-01-21 =
* A number of new WP CLI commands have been added, making it easier to manage actions in the terminal and from scripts.
* New wp action-scheduler source command to help determine how Action Scheduler is being loaded.
* Additional information about the active instance of Action Scheduler is now available in the Help pull-down drawer.
* Make some other nullable parameters explicitly nullable.
* Set option value to `no` rather than deleting.

= 3.9.0 - 2024-11-14 =
* Minimum required version of PHP is now 7.1.
* Performance improvements for the `as_pending_actions_due()` function.

0 comments on commit ac54560

Please sign in to comment.