From 4515bbc18ceead948dd4f12d9e099cbbe2318026 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 13:36:48 +0300 Subject: [PATCH 01/28] adding --exclude-group CLI option and adding comma for supporting multiple group definitions --- ...ctionScheduler_WPCLI_Scheduler_command.php | 37 +++++++++++---- classes/abstracts/ActionScheduler_Store.php | 45 ++++++++++++++++--- .../data-stores/ActionScheduler_DBStore.php | 41 ++++++++++++----- 3 files changed, 96 insertions(+), 27 deletions(-) diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php index 6cf27d424..67966c88e 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php @@ -25,6 +25,9 @@ class ActionScheduler_WPCLI_Scheduler_command extends WP_CLI_Command { * [--group=] * : Only run actions from the specified group. Omitting this option runs actions from all groups. * + * [--exclude-group=] + * : Run actions by omiting the specified group. Omitting this option runs actions from all groups. + * * [--free-memory-on=] * : The number of actions to process between freeing memory. 0 disables freeing memory. Default 50. * @@ -42,15 +45,16 @@ class ActionScheduler_WPCLI_Scheduler_command extends WP_CLI_Command { */ public function run( $args, $assoc_args ) { // Handle passed arguments. - $batch = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batch-size', 100 ) ); - $batches = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batches', 0 ) ); - $clean = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'cleanup-batch-size', $batch ) ); - $hooks = explode( ',', WP_CLI\Utils\get_flag_value( $assoc_args, 'hooks', '' ) ); - $hooks = array_filter( array_map( 'trim', $hooks ) ); - $group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'group', '' ); - $free_on = \WP_CLI\Utils\get_flag_value( $assoc_args, 'free-memory-on', 50 ); - $sleep = \WP_CLI\Utils\get_flag_value( $assoc_args, 'pause', 0 ); - $force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force', false ); + $batch = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batch-size', 100 ) ); + $batches = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batches', 0 ) ); + $clean = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'cleanup-batch-size', $batch ) ); + $hooks = explode( ',', WP_CLI\Utils\get_flag_value( $assoc_args, 'hooks', '' ) ); + $hooks = array_filter( array_map( 'trim', $hooks ) ); + $group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'group', '' ); + $exclude_group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'exclude-group', '' ); + $free_on = \WP_CLI\Utils\get_flag_value( $assoc_args, 'free-memory-on', 50 ); + $sleep = \WP_CLI\Utils\get_flag_value( $assoc_args, 'pause', 0 ); + $force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force', false ); ActionScheduler_DataController::set_free_ticks( $free_on ); ActionScheduler_DataController::set_sleep_time( $sleep ); @@ -59,6 +63,21 @@ public function run( $args, $assoc_args ) { $actions_completed = 0; $unlimited = $batches === 0; + if ( $exclude_group ) { + $exclude_group_array = explode( ',', $exclude_group ); + + $exclude_group_array = array_map( + function ( $val ) { + return ( $val ) ? ActionScheduler_DBStore::mark_group_for_exclussion( $val ) : ''; + }, + $exclude_group_array + ); + + if ( count( $exclude_group_array ) ) { + $group .= ',' . implode( ',', $exclude_group_array ); + } + } + try { // Custom queue cleaner instance. $cleaner = new ActionScheduler_QueueCleaner( null, $clean ); diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index 6b71a7793..29d5180d2 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -5,12 +5,13 @@ * @codeCoverageIgnore */ abstract class ActionScheduler_Store extends ActionScheduler_Store_Deprecated { - const STATUS_COMPLETE = 'complete'; - const STATUS_PENDING = 'pending'; - const STATUS_RUNNING = 'in-progress'; - const STATUS_FAILED = 'failed'; - const STATUS_CANCELED = 'canceled'; - const DEFAULT_CLASS = 'ActionScheduler_wpPostStore'; + const STATUS_COMPLETE = 'complete'; + const STATUS_PENDING = 'pending'; + const STATUS_RUNNING = 'in-progress'; + const STATUS_FAILED = 'failed'; + const STATUS_CANCELED = 'canceled'; + const DEFAULT_CLASS = 'ActionScheduler_wpPostStore'; + const EXCLUDED_GROUP_PREFIX = '--'; /** @var ActionScheduler_Store */ private static $store = NULL; @@ -208,6 +209,38 @@ abstract public function get_claim_id( $action_id ); */ abstract public function find_actions_by_claim_id( $claim_id ); + /** + * Check if group name is prefixed for exclussion. + * + * @param string $slug Group slug name. + * @return boolean + */ + protected static function group_has_excluded_prefix( $slug ) { + return self::EXCLUDED_GROUP_PREFIX === substr( $slug, 0, strlen( self::EXCLUDED_GROUP_PREFIX ) ); + } + + /** + * Mark group for exclussion by prefixing with '-'. + * + * @param string $slug Group slug name. + * @return string + */ + public static function mark_group_for_exclussion( $slug ) { + return self::EXCLUDED_GROUP_PREFIX . $slug; + } + + /** + * Sanitize group name. + * + * @param string $slug Group slug name. + * @return string + */ + public static function sanitize_group_name( $slug ) { + // removing the excluded group prefix from slug if present. + $slug = preg_replace( '/(' . preg_quote( self::EXCLUDED_GROUP_PREFIX, null ) . ')?(.*)/m', '$2', $slug ); + return $slug; + } + /** * @param string $comparison_operator * @return string diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index f08376419..f3073bdc2 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -40,7 +40,7 @@ public function init() { * Save an action. * * @param ActionScheduler_Action $action Action object. - * @param DateTime $date Optional schedule date. Default null. + * @param DateTime $date Optional schedule date. Default null. * * @return int Action ID. * @throws RuntimeException Throws exception when saving the action fails. @@ -138,11 +138,18 @@ protected function get_group_id( $slug, $create_if_not_exists = true ) { * @param string $slug Group slug. * * @return int Group ID. + * @throws \InvalidArgumentException Throws exception when the group slug starts with '-'. */ protected function create_group( $slug ) { /** @var \wpdb $wpdb */ global $wpdb; - $wpdb->insert( $wpdb->actionscheduler_groups, array( 'slug' => $slug ) ); + + if ( self::group_has_excluded_prefix( $slug ) ) { + // translators: %s: excluded group name prefix. + throw new InvalidArgumentException( sprintf( __( 'Group names cannot start with %s.', 'action-scheduler' ), self::EXCLUDED_GROUP_PREFIX ) ); + } + + $wpdb->insert( $wpdb->actionscheduler_groups, array( 'slug' => $slug ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery return (int) $wpdb->insert_id; } @@ -622,7 +629,7 @@ protected function generate_claim_id() { * @param int $limit Number of action to include in claim. * @param \DateTime $before_date Should use UTC timezone. * @param array $hooks Hooks to filter for. - * @param string $group Group to filter for. + * @param string $group Group to filter for, adding -- in front of the group will have it excluded. * * @return int The number of actions that were claimed. * @throws \InvalidArgumentException Throws InvalidArgumentException if group doesn't exist. @@ -653,18 +660,28 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu $params = array_merge( $params, array_values( $hooks ) ); } - if ( ! empty( $group ) ) { + $group_array = explode( ',', $group ); - $group_id = $this->get_group_id( $group, false ); + if ( is_array( $group_array ) && count( $group_array ) ) { - // throw exception if no matching group found, this matches ActionScheduler_wpPostStore's behaviour. - if ( empty( $group_id ) ) { - /* translators: %s: group name */ - throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $group ) ); - } + foreach ( $group_array as $group ) { + + $group = self::sanitize_group_name( $group ); + $group_id = $this->get_group_id( $group ); - $where .= ' AND group_id = %d'; - $params[] = $group_id; + // throw exception if no matching group found, this matches ActionScheduler_wpPostStore's behaviour. + if ( empty( $group_id ) ) { + /* translators: %s: group name */ + throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $group ) ); + } + + if ( self::group_has_excluded_prefix( $group ) ) { + $where .= ' AND group_id != %d'; + } else { + $where .= ' AND group_id = %d'; + } + $params[] = $group_id; + } } /** From 56050a2fbbaa62ec2374ddad592315db3421c35f Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 13:51:06 +0300 Subject: [PATCH 02/28] removing empty array values from group array --- classes/data-stores/ActionScheduler_DBStore.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index f3073bdc2..7dc7b713b 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -660,7 +660,7 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu $params = array_merge( $params, array_values( $hooks ) ); } - $group_array = explode( ',', $group ); + $group_array = array_filter( explode( ',', $group ) ); if ( is_array( $group_array ) && count( $group_array ) ) { From 5cd49404a0a506ffefc1bfe202ab2870e3afcbfe Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 15:04:21 +0300 Subject: [PATCH 03/28] renaming EXCLUDED_GROUP_PREFIX const to EXCLUDE_GROUP_FLAG --- classes/data-stores/ActionScheduler_DBStore.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index 7dc7b713b..ed4a0a460 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -146,7 +146,7 @@ protected function create_group( $slug ) { if ( self::group_has_excluded_prefix( $slug ) ) { // translators: %s: excluded group name prefix. - throw new InvalidArgumentException( sprintf( __( 'Group names cannot start with %s.', 'action-scheduler' ), self::EXCLUDED_GROUP_PREFIX ) ); + throw new InvalidArgumentException( sprintf( __( 'Group names cannot start with %s.', 'action-scheduler' ), self::EXCLUDE_GROUP_FLAG ) ); } $wpdb->insert( $wpdb->actionscheduler_groups, array( 'slug' => $slug ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery From 440204c8f5ba348d82e68fc20c853cb4aaddaf41 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 15:10:58 +0300 Subject: [PATCH 04/28] renaming exclude to ignore namings --- .../ActionScheduler_WPCLI_Scheduler_command.php | 16 ++++++++-------- classes/abstracts/ActionScheduler_Store.php | 12 ++++++------ classes/data-stores/ActionScheduler_DBStore.php | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php index 67966c88e..f00018fa0 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php @@ -25,7 +25,7 @@ class ActionScheduler_WPCLI_Scheduler_command extends WP_CLI_Command { * [--group=] * : Only run actions from the specified group. Omitting this option runs actions from all groups. * - * [--exclude-group=] + * [--ignore-group=] * : Run actions by omiting the specified group. Omitting this option runs actions from all groups. * * [--free-memory-on=] @@ -51,7 +51,7 @@ public function run( $args, $assoc_args ) { $hooks = explode( ',', WP_CLI\Utils\get_flag_value( $assoc_args, 'hooks', '' ) ); $hooks = array_filter( array_map( 'trim', $hooks ) ); $group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'group', '' ); - $exclude_group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'exclude-group', '' ); + $ignore_group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'ignore-group', '' ); $free_on = \WP_CLI\Utils\get_flag_value( $assoc_args, 'free-memory-on', 50 ); $sleep = \WP_CLI\Utils\get_flag_value( $assoc_args, 'pause', 0 ); $force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force', false ); @@ -63,18 +63,18 @@ public function run( $args, $assoc_args ) { $actions_completed = 0; $unlimited = $batches === 0; - if ( $exclude_group ) { - $exclude_group_array = explode( ',', $exclude_group ); + if ( $ignore_group ) { + $ignore_group_array = explode( ',', $ignore_group ); - $exclude_group_array = array_map( + $ignore_group_array = array_map( function ( $val ) { return ( $val ) ? ActionScheduler_DBStore::mark_group_for_exclussion( $val ) : ''; }, - $exclude_group_array + $ignore_group_array ); - if ( count( $exclude_group_array ) ) { - $group .= ',' . implode( ',', $exclude_group_array ); + if ( count( $ignore_group_array ) ) { + $group .= ',' . implode( ',', $ignore_group_array ); } } diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index 29d5180d2..add583440 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -11,7 +11,7 @@ abstract class ActionScheduler_Store extends ActionScheduler_Store_Deprecated { const STATUS_FAILED = 'failed'; const STATUS_CANCELED = 'canceled'; const DEFAULT_CLASS = 'ActionScheduler_wpPostStore'; - const EXCLUDED_GROUP_PREFIX = '--'; + const IGNORE_GROUP_FLAG = '--'; /** @var ActionScheduler_Store */ private static $store = NULL; @@ -215,8 +215,8 @@ abstract public function find_actions_by_claim_id( $claim_id ); * @param string $slug Group slug name. * @return boolean */ - protected static function group_has_excluded_prefix( $slug ) { - return self::EXCLUDED_GROUP_PREFIX === substr( $slug, 0, strlen( self::EXCLUDED_GROUP_PREFIX ) ); + protected static function group_has_ignore_prefix( $slug ) { + return self::IGNORE_GROUP_FLAG === substr( $slug, 0, strlen( self::IGNORE_GROUP_FLAG ) ); } /** @@ -226,7 +226,7 @@ protected static function group_has_excluded_prefix( $slug ) { * @return string */ public static function mark_group_for_exclussion( $slug ) { - return self::EXCLUDED_GROUP_PREFIX . $slug; + return self::IGNORE_GROUP_FLAG . $slug; } /** @@ -236,8 +236,8 @@ public static function mark_group_for_exclussion( $slug ) { * @return string */ public static function sanitize_group_name( $slug ) { - // removing the excluded group prefix from slug if present. - $slug = preg_replace( '/(' . preg_quote( self::EXCLUDED_GROUP_PREFIX, null ) . ')?(.*)/m', '$2', $slug ); + // removing the ignored group prefix from slug if present. + $slug = preg_replace( '/(' . preg_quote( self::IGNORE_GROUP_FLAG, null ) . ')?(.*)/m', '$2', $slug ); return $slug; } diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index ed4a0a460..23d04e12f 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -144,9 +144,9 @@ protected function create_group( $slug ) { /** @var \wpdb $wpdb */ global $wpdb; - if ( self::group_has_excluded_prefix( $slug ) ) { + if ( self::group_has_ignore_prefix( $slug ) ) { // translators: %s: excluded group name prefix. - throw new InvalidArgumentException( sprintf( __( 'Group names cannot start with %s.', 'action-scheduler' ), self::EXCLUDE_GROUP_FLAG ) ); + throw new InvalidArgumentException( sprintf( __( 'Group names cannot start with %s.', 'action-scheduler' ), self::IGNORE_GROUP_FLAG ) ); } $wpdb->insert( $wpdb->actionscheduler_groups, array( 'slug' => $slug ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery @@ -675,7 +675,7 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $group ) ); } - if ( self::group_has_excluded_prefix( $group ) ) { + if ( self::group_has_ignore_prefix( $group ) ) { $where .= ' AND group_id != %d'; } else { $where .= ' AND group_id = %d'; From e27831fa6ce0b042262fe8c2f0a281375e4c3b35 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 15:13:09 +0300 Subject: [PATCH 05/28] renaming exclude to ignore namings --- classes/data-stores/ActionScheduler_DBStore.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index 23d04e12f..9b2e1b9e5 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -145,7 +145,7 @@ protected function create_group( $slug ) { global $wpdb; if ( self::group_has_ignore_prefix( $slug ) ) { - // translators: %s: excluded group name prefix. + // translators: %s: ignored group name prefix. throw new InvalidArgumentException( sprintf( __( 'Group names cannot start with %s.', 'action-scheduler' ), self::IGNORE_GROUP_FLAG ) ); } @@ -629,7 +629,7 @@ protected function generate_claim_id() { * @param int $limit Number of action to include in claim. * @param \DateTime $before_date Should use UTC timezone. * @param array $hooks Hooks to filter for. - * @param string $group Group to filter for, adding -- in front of the group will have it excluded. + * @param string $group Group to filter for, adding -- in front of the group will have it ignored. * * @return int The number of actions that were claimed. * @throws \InvalidArgumentException Throws InvalidArgumentException if group doesn't exist. From c75caec5decbb6d703154bc3e8b5267c69b5b890 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 15:46:43 +0300 Subject: [PATCH 06/28] comments fix --- classes/data-stores/ActionScheduler_DBStore.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index 9b2e1b9e5..473f25f8b 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -138,7 +138,7 @@ protected function get_group_id( $slug, $create_if_not_exists = true ) { * @param string $slug Group slug. * * @return int Group ID. - * @throws \InvalidArgumentException Throws exception when the group slug starts with '-'. + * @throws \InvalidArgumentException Throws exception when the group slug starts with IGNORE_GROUP_FLAG. */ protected function create_group( $slug ) { /** @var \wpdb $wpdb */ @@ -629,7 +629,7 @@ protected function generate_claim_id() { * @param int $limit Number of action to include in claim. * @param \DateTime $before_date Should use UTC timezone. * @param array $hooks Hooks to filter for. - * @param string $group Group to filter for, adding -- in front of the group will have it ignored. + * @param string $group Group to filter for, adding IGNORE_GROUP_FLAG in front of the group will have it ignored. * * @return int The number of actions that were claimed. * @throws \InvalidArgumentException Throws InvalidArgumentException if group doesn't exist. From b4a5a526ee7fc837af90ca3169ca8ce6c6ace06f Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 15:50:07 +0300 Subject: [PATCH 07/28] code refactoring if statement --- classes/data-stores/ActionScheduler_DBStore.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index 473f25f8b..8f18e0d24 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -675,11 +675,7 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $group ) ); } - if ( self::group_has_ignore_prefix( $group ) ) { - $where .= ' AND group_id != %d'; - } else { - $where .= ' AND group_id = %d'; - } + $where .= ( self::group_has_ignore_prefix( $group ) ? ' AND group_id != %d' : ' AND group_id = %d' ); $params[] = $group_id; } } From 519036781e37e1c5461d883e1f01254c900a293c Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 15:52:48 +0300 Subject: [PATCH 08/28] code refactoring if statement --- classes/data-stores/ActionScheduler_DBStore.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index 8f18e0d24..de5afe257 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -666,8 +666,7 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu foreach ( $group_array as $group ) { - $group = self::sanitize_group_name( $group ); - $group_id = $this->get_group_id( $group ); + $group_id = $this->get_group_id( self::sanitize_group_name( $group ) ); // throw exception if no matching group found, this matches ActionScheduler_wpPostStore's behaviour. if ( empty( $group_id ) ) { @@ -675,7 +674,7 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $group ) ); } - $where .= ( self::group_has_ignore_prefix( $group ) ? ' AND group_id != %d' : ' AND group_id = %d' ); + $where .= ' AND group_id ' . ( self::group_has_ignore_prefix( $group ) ? '!= %d' : '= %d' ); $params[] = $group_id; } } From d16c50247f384c7eac44b582306fcbb2d99ed652 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 15:55:26 +0300 Subject: [PATCH 09/28] code refactoring if statement --- classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php index f00018fa0..d85cdc8f7 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php @@ -64,13 +64,11 @@ public function run( $args, $assoc_args ) { $unlimited = $batches === 0; if ( $ignore_group ) { - $ignore_group_array = explode( ',', $ignore_group ); - $ignore_group_array = array_map( function ( $val ) { return ( $val ) ? ActionScheduler_DBStore::mark_group_for_exclussion( $val ) : ''; }, - $ignore_group_array + explode( ',', $ignore_group ) ); if ( count( $ignore_group_array ) ) { From 0b31d94c6a9b0928752fa4f687a2444aae01a9a2 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 15:59:30 +0300 Subject: [PATCH 10/28] code refactoring if statement --- classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php | 2 +- classes/abstracts/ActionScheduler_Store.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php index d85cdc8f7..2168acfbe 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php @@ -66,7 +66,7 @@ public function run( $args, $assoc_args ) { if ( $ignore_group ) { $ignore_group_array = array_map( function ( $val ) { - return ( $val ) ? ActionScheduler_DBStore::mark_group_for_exclussion( $val ) : ''; + return ActionScheduler_DBStore::mark_group_for_exclussion( $val ); }, explode( ',', $ignore_group ) ); diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index add583440..3cfb64950 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -226,7 +226,7 @@ protected static function group_has_ignore_prefix( $slug ) { * @return string */ public static function mark_group_for_exclussion( $slug ) { - return self::IGNORE_GROUP_FLAG . $slug; + return $slug ? self::IGNORE_GROUP_FLAG . $slug : $slug; } /** From e8548dc7fe76bfaaf6b3dd085dc6c4525872eb27 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 16:02:26 +0300 Subject: [PATCH 11/28] adding comments --- classes/abstracts/ActionScheduler_Store.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index 3cfb64950..53098ec17 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -238,6 +238,8 @@ public static function mark_group_for_exclussion( $slug ) { public static function sanitize_group_name( $slug ) { // removing the ignored group prefix from slug if present. $slug = preg_replace( '/(' . preg_quote( self::IGNORE_GROUP_FLAG, null ) . ')?(.*)/m', '$2', $slug ); + + // further sanitisation here with `sanitize_title` maybe? return $slug; } From 21de107950a450d054efa9b1b2a5d0a6c76526a0 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 16:06:22 +0300 Subject: [PATCH 12/28] code refactoring --- classes/data-stores/ActionScheduler_DBStore.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index de5afe257..ab486b7cc 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -666,12 +666,13 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu foreach ( $group_array as $group ) { - $group_id = $this->get_group_id( self::sanitize_group_name( $group ) ); + $sanitized_group_name = self::sanitize_group_name( $group ); + $group_id = $this->get_group_id( $sanitized_group_name, false ); // throw exception if no matching group found, this matches ActionScheduler_wpPostStore's behaviour. if ( empty( $group_id ) ) { /* translators: %s: group name */ - throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $group ) ); + throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $sanitized_group_name ) ); } $where .= ' AND group_id ' . ( self::group_has_ignore_prefix( $group ) ? '!= %d' : '= %d' ); From 9f0510450760b56b4c5378f30ecbabca4dace194 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 17:06:48 +0300 Subject: [PATCH 13/28] query fix group selection --- .../data-stores/ActionScheduler_DBStore.php | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index ab486b7cc..0c0dee82d 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -662,6 +662,9 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu $group_array = array_filter( explode( ',', $group ) ); + $ignore_group_ids = array(); + $include_group_ids = array(); + if ( is_array( $group_array ) && count( $group_array ) ) { foreach ( $group_array as $group ) { @@ -675,11 +678,26 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $sanitized_group_name ) ); } - $where .= ' AND group_id ' . ( self::group_has_ignore_prefix( $group ) ? '!= %d' : '= %d' ); - $params[] = $group_id; + if ( self::group_has_ignore_prefix( $group ) ) { + $ignore_group_ids[] = $group_id; + } else { + $include_group_ids[] = $group_id; + } } } + if ( count( $include_group_ids ) ) { + $where .= ' AND group_id IN (%s)'; + $params[] = implode( ',', $include_group_ids ); + } + + if ( count( $ignore_group_ids ) ) { + $where .= ' AND group_id NOT IN (%s)'; + $params[] = implode( ',', $ignore_group_ids ); + } + + echo $where; + print_r($params); /** * Sets the order-by clause used in the action claim query. * From 6685173f32445362d9915e0b9e9d5bf0392ecebd Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 17:07:42 +0300 Subject: [PATCH 14/28] query fix group selection --- classes/data-stores/ActionScheduler_DBStore.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index 0c0dee82d..5298a909e 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -696,8 +696,6 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu $params[] = implode( ',', $ignore_group_ids ); } - echo $where; - print_r($params); /** * Sets the order-by clause used in the action claim query. * From 7d4bf23e11f6a5998e399d5f5867c284eebfb486 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Wed, 27 Oct 2021 17:14:51 +0300 Subject: [PATCH 15/28] cli logic fix --- classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php index 2168acfbe..cb6054b6d 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php @@ -63,7 +63,8 @@ public function run( $args, $assoc_args ) { $actions_completed = 0; $unlimited = $batches === 0; - if ( $ignore_group ) { + if ( ! $group && $ignore_group ) { // there is no need to proceed with the ignore code if $group is set. + $ignore_group_array = array_map( function ( $val ) { return ActionScheduler_DBStore::mark_group_for_exclussion( $val ); From 6066d446033eb63d6a127a77dc2fbcb1349bbc5a Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 28 Oct 2021 09:45:19 +0300 Subject: [PATCH 16/28] adding code logic where query --- classes/data-stores/ActionScheduler_DBStore.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index 5298a909e..ebb7d08bd 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -689,9 +689,7 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu if ( count( $include_group_ids ) ) { $where .= ' AND group_id IN (%s)'; $params[] = implode( ',', $include_group_ids ); - } - - if ( count( $ignore_group_ids ) ) { + } elseif ( count( $ignore_group_ids ) ) { $where .= ' AND group_id NOT IN (%s)'; $params[] = implode( ',', $ignore_group_ids ); } From 82b809684176ae8c205f498f3dd999f81f692541 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 28 Oct 2021 09:57:20 +0300 Subject: [PATCH 17/28] code refactoring --- ...ctionScheduler_WPCLI_Scheduler_command.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php index cb6054b6d..c8d7778a8 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php @@ -45,16 +45,17 @@ class ActionScheduler_WPCLI_Scheduler_command extends WP_CLI_Command { */ public function run( $args, $assoc_args ) { // Handle passed arguments. - $batch = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batch-size', 100 ) ); - $batches = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batches', 0 ) ); - $clean = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'cleanup-batch-size', $batch ) ); - $hooks = explode( ',', WP_CLI\Utils\get_flag_value( $assoc_args, 'hooks', '' ) ); - $hooks = array_filter( array_map( 'trim', $hooks ) ); - $group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'group', '' ); + $batch = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batch-size', 100 ) ); + $batches = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'batches', 0 ) ); + $clean = absint( \WP_CLI\Utils\get_flag_value( $assoc_args, 'cleanup-batch-size', $batch ) ); + $hooks = explode( ',', WP_CLI\Utils\get_flag_value( $assoc_args, 'hooks', '' ) ); + $hooks = array_filter( array_map( 'trim', $hooks ) ); + $group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'group', '' ); + $free_on = \WP_CLI\Utils\get_flag_value( $assoc_args, 'free-memory-on', 50 ); + $sleep = \WP_CLI\Utils\get_flag_value( $assoc_args, 'pause', 0 ); + $force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force', false ); + $ignore_group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'ignore-group', '' ); - $free_on = \WP_CLI\Utils\get_flag_value( $assoc_args, 'free-memory-on', 50 ); - $sleep = \WP_CLI\Utils\get_flag_value( $assoc_args, 'pause', 0 ); - $force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force', false ); ActionScheduler_DataController::set_free_ticks( $free_on ); ActionScheduler_DataController::set_sleep_time( $sleep ); From 28433084381964ee1a463c57b95a4458fb9e053e Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 28 Oct 2021 09:58:18 +0300 Subject: [PATCH 18/28] code refactoring --- classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php index c8d7778a8..72845f11f 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php @@ -55,7 +55,7 @@ public function run( $args, $assoc_args ) { $sleep = \WP_CLI\Utils\get_flag_value( $assoc_args, 'pause', 0 ); $force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force', false ); - $ignore_group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'ignore-group', '' ); + $ignore_group = \WP_CLI\Utils\get_flag_value( $assoc_args, 'ignore-group', '' ); ActionScheduler_DataController::set_free_ticks( $free_on ); ActionScheduler_DataController::set_sleep_time( $sleep ); From 2eb6c04d62651c3459252f944026999121c2b508 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 24 Nov 2022 10:36:19 +0200 Subject: [PATCH 19/28] Update classes/abstracts/ActionScheduler_Store.php Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com> --- classes/abstracts/ActionScheduler_Store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index 53098ec17..71074afb8 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -11,7 +11,7 @@ abstract class ActionScheduler_Store extends ActionScheduler_Store_Deprecated { const STATUS_FAILED = 'failed'; const STATUS_CANCELED = 'canceled'; const DEFAULT_CLASS = 'ActionScheduler_wpPostStore'; - const IGNORE_GROUP_FLAG = '--'; + const IGNORE_GROUP_FLAG = '--*IGNORE*--'; /** @var ActionScheduler_Store */ private static $store = NULL; From c3b2484bcc595b06ee4503f29ac64234e5904fd2 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 24 Nov 2022 10:36:37 +0200 Subject: [PATCH 20/28] Update classes/abstracts/ActionScheduler_Store.php Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com> --- classes/abstracts/ActionScheduler_Store.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index 71074afb8..51d886781 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -220,7 +220,8 @@ protected static function group_has_ignore_prefix( $slug ) { } /** - * Mark group for exclussion by prefixing with '-'. + * Mark group for exclusion by applying a special prefix (by default, the value of + * the IGNORE_GROUP_FLAG property). * * @param string $slug Group slug name. * @return string From e16a17247cb6c74438e9c77fbf6b52cdcb556e61 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 24 Nov 2022 10:36:46 +0200 Subject: [PATCH 21/28] Update classes/abstracts/ActionScheduler_Store.php Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com> --- classes/abstracts/ActionScheduler_Store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index 51d886781..14e6074fa 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -226,7 +226,7 @@ protected static function group_has_ignore_prefix( $slug ) { * @param string $slug Group slug name. * @return string */ - public static function mark_group_for_exclussion( $slug ) { + public static function mark_group_for_exclusion( $slug ) { return $slug ? self::IGNORE_GROUP_FLAG . $slug : $slug; } From 641cf313fa426655a6b1c3587b1a2a5ab219ca1e Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 24 Nov 2022 10:37:02 +0200 Subject: [PATCH 22/28] Update classes/data-stores/ActionScheduler_DBStore.php Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com> --- classes/data-stores/ActionScheduler_DBStore.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index ebb7d08bd..b66c06681 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -146,7 +146,7 @@ protected function create_group( $slug ) { if ( self::group_has_ignore_prefix( $slug ) ) { // translators: %s: ignored group name prefix. - throw new InvalidArgumentException( sprintf( __( 'Group names cannot start with %s.', 'action-scheduler' ), self::IGNORE_GROUP_FLAG ) ); + throw new InvalidArgumentException( sprintf( esc_html__( 'Group names cannot start with %s.', 'action-scheduler' ), self::IGNORE_GROUP_FLAG ) ); } $wpdb->insert( $wpdb->actionscheduler_groups, array( 'slug' => $slug ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery From 33255714e22fdd7273a2b756cf5b4fd94a4f41d2 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 24 Nov 2022 10:37:11 +0200 Subject: [PATCH 23/28] Update classes/data-stores/ActionScheduler_DBStore.php Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com> --- classes/data-stores/ActionScheduler_DBStore.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/data-stores/ActionScheduler_DBStore.php b/classes/data-stores/ActionScheduler_DBStore.php index b66c06681..82cf8bdaa 100644 --- a/classes/data-stores/ActionScheduler_DBStore.php +++ b/classes/data-stores/ActionScheduler_DBStore.php @@ -629,7 +629,7 @@ protected function generate_claim_id() { * @param int $limit Number of action to include in claim. * @param \DateTime $before_date Should use UTC timezone. * @param array $hooks Hooks to filter for. - * @param string $group Group to filter for, adding IGNORE_GROUP_FLAG in front of the group will have it ignored. + * @param string $group Comma-separated list of groups to filter by. Adding IGNORE_GROUP_FLAG in front of a group will cause it to be ignored. * * @return int The number of actions that were claimed. * @throws \InvalidArgumentException Throws InvalidArgumentException if group doesn't exist. From 477373b237cea746437522446878d513f5e1092f Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 24 Nov 2022 10:37:57 +0200 Subject: [PATCH 24/28] renaming mark_group_for_exclussion method --- classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php index 72845f11f..73967987b 100644 --- a/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php +++ b/classes/WP_CLI/ActionScheduler_WPCLI_Scheduler_command.php @@ -68,7 +68,7 @@ public function run( $args, $assoc_args ) { $ignore_group_array = array_map( function ( $val ) { - return ActionScheduler_DBStore::mark_group_for_exclussion( $val ); + return ActionScheduler_DBStore::mark_group_for_exclusion( $val ); }, explode( ',', $ignore_group ) ); From 85bf9fa254be17d59254e02e3ccc246741ef1992 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 24 Nov 2022 11:06:04 +0200 Subject: [PATCH 25/28] esc_sql sanitize_group_name and regex addon ^ --- classes/abstracts/ActionScheduler_Store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/abstracts/ActionScheduler_Store.php b/classes/abstracts/ActionScheduler_Store.php index 14e6074fa..5dd886712 100644 --- a/classes/abstracts/ActionScheduler_Store.php +++ b/classes/abstracts/ActionScheduler_Store.php @@ -238,7 +238,7 @@ public static function mark_group_for_exclusion( $slug ) { */ public static function sanitize_group_name( $slug ) { // removing the ignored group prefix from slug if present. - $slug = preg_replace( '/(' . preg_quote( self::IGNORE_GROUP_FLAG, null ) . ')?(.*)/m', '$2', $slug ); + $slug = preg_replace( '/^(' . preg_quote( self::IGNORE_GROUP_FLAG, null ) . ')?(.*)/m', '$2', esc_sql( $slug ) ); // further sanitisation here with `sanitize_title` maybe? return $slug; From 8699ef1713ee884a16b9a86dda9cbb120185752e Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 24 Nov 2022 11:21:44 +0200 Subject: [PATCH 26/28] adding --ignore-group docs --- docs/wp-cli.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/wp-cli.md b/docs/wp-cli.md index 5a89abcec..b443fab74 100644 --- a/docs/wp-cli.md +++ b/docs/wp-cli.md @@ -29,7 +29,8 @@ These are the commands available to use with Action Scheduler: * `--batch-size` - This is the number of actions to run in a single batch. The default is `100`. * `--batches` - This is the number of batches to run. Using 0 means that batches will continue running until there are no more actions to run. * `--hooks` - Process only actions with specific hook or hooks, like `'woocommerce_scheduled_subscription_payment'`. By default, actions with any hook will be processed. Define multiple hooks as a comma separated string (without spaces), e.g. `--hooks=woocommerce_scheduled_subscription_trial_end,woocommerce_scheduled_subscription_payment,woocommerce_scheduled_subscription_expiration` - * `--group` - Process only actions in a specific group, like `'woocommerce-memberships'`. By default, actions in any group (or no group) will be processed. + * `--group` - Process only actions in a specific group, like `'woocommerce-memberships'`. By default, actions in any group (or no group) will be processed. Accepts comma-separated list of groups to filter by. Adding --*IGNORE*-- in front of a group will cause it to be ignored. + * `-ignore-group` - Ignore processing actions from groups found in the the comma separated list of values. * `--force` - By default, Action Scheduler limits the number of concurrent batches that can be run at once to ensure the server does not get overwhelmed. Using the `--force` flag overrides this behavior to force the WP CLI queue to run. The best way to get a full list of commands and their available options is to use WP CLI itself. This can be done by running `wp action-scheduler` to list all Action Scheduler commands, or by including the `--help` flag with any of the individual commands. This will provide all relevant parameters and flags for the command. From 0f25f0734a45fe492d99b3a270cad8984cb6bcf6 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 24 Nov 2022 11:22:17 +0200 Subject: [PATCH 27/28] Update wp-cli.md --- docs/wp-cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/wp-cli.md b/docs/wp-cli.md index b443fab74..f4643ff4b 100644 --- a/docs/wp-cli.md +++ b/docs/wp-cli.md @@ -30,7 +30,7 @@ These are the commands available to use with Action Scheduler: * `--batches` - This is the number of batches to run. Using 0 means that batches will continue running until there are no more actions to run. * `--hooks` - Process only actions with specific hook or hooks, like `'woocommerce_scheduled_subscription_payment'`. By default, actions with any hook will be processed. Define multiple hooks as a comma separated string (without spaces), e.g. `--hooks=woocommerce_scheduled_subscription_trial_end,woocommerce_scheduled_subscription_payment,woocommerce_scheduled_subscription_expiration` * `--group` - Process only actions in a specific group, like `'woocommerce-memberships'`. By default, actions in any group (or no group) will be processed. Accepts comma-separated list of groups to filter by. Adding --*IGNORE*-- in front of a group will cause it to be ignored. - * `-ignore-group` - Ignore processing actions from groups found in the the comma separated list of values. + * `-ignore-group` - Ignore processing actions from groups found inside the comma separated list of values. * `--force` - By default, Action Scheduler limits the number of concurrent batches that can be run at once to ensure the server does not get overwhelmed. Using the `--force` flag overrides this behavior to force the WP CLI queue to run. The best way to get a full list of commands and their available options is to use WP CLI itself. This can be done by running `wp action-scheduler` to list all Action Scheduler commands, or by including the `--help` flag with any of the individual commands. This will provide all relevant parameters and flags for the command. From b9c9dd7d877bb7845427cebe9e1cfcbcffd42db9 Mon Sep 17 00:00:00 2001 From: Ovidiu Liuta Date: Thu, 24 Nov 2022 11:22:32 +0200 Subject: [PATCH 28/28] Update wp-cli.md --- docs/wp-cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/wp-cli.md b/docs/wp-cli.md index f4643ff4b..8531595c8 100644 --- a/docs/wp-cli.md +++ b/docs/wp-cli.md @@ -30,7 +30,7 @@ These are the commands available to use with Action Scheduler: * `--batches` - This is the number of batches to run. Using 0 means that batches will continue running until there are no more actions to run. * `--hooks` - Process only actions with specific hook or hooks, like `'woocommerce_scheduled_subscription_payment'`. By default, actions with any hook will be processed. Define multiple hooks as a comma separated string (without spaces), e.g. `--hooks=woocommerce_scheduled_subscription_trial_end,woocommerce_scheduled_subscription_payment,woocommerce_scheduled_subscription_expiration` * `--group` - Process only actions in a specific group, like `'woocommerce-memberships'`. By default, actions in any group (or no group) will be processed. Accepts comma-separated list of groups to filter by. Adding --*IGNORE*-- in front of a group will cause it to be ignored. - * `-ignore-group` - Ignore processing actions from groups found inside the comma separated list of values. + * `--ignore-group` - Ignore processing actions from groups found inside the comma separated list of values. * `--force` - By default, Action Scheduler limits the number of concurrent batches that can be run at once to ensure the server does not get overwhelmed. Using the `--force` flag overrides this behavior to force the WP CLI queue to run. The best way to get a full list of commands and their available options is to use WP CLI itself. This can be done by running `wp action-scheduler` to list all Action Scheduler commands, or by including the `--help` flag with any of the individual commands. This will provide all relevant parameters and flags for the command.