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

Downgrade Action scheduler to 3.9.0 #7263

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"psr/container": "1.1.1",
"roave/security-advisories": "dev-master",
"szepeviktor/phpstan-wordpress": "^1.3",
"woocommerce/action-scheduler": "^3.9",
"woocommerce/action-scheduler": "3.9.0",
"wp-coding-standards/wpcs": "^3",
"wp-media/background-processing": "^1.3",
"wp-media/monolog": "^0.0",
Expand Down
16 changes: 8 additions & 8 deletions inc/Dependencies/ActionScheduler/action-scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand All @@ -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).
Expand All @@ -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();
}
Expand Down
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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>',
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ class ActionScheduler_Versions {
*/
private $versions = array();

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

/**
* Register version's callback.
*
Expand All @@ -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;
}

Expand All @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Up @@ -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 );
}

/**
Expand All @@ -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 );
}

/**
Expand Down
Loading
Loading