Changeset 2542151
- Timestamp:
- 06/03/2021 04:42:57 PM (5 years ago)
- Location:
- action-scheduler
- Files:
-
- 2 added
- 24 edited
- 1 copied
-
tags/3.2.0 (copied) (copied from action-scheduler/trunk)
-
tags/3.2.0/action-scheduler.php (modified) (4 diffs)
-
tags/3.2.0/changelog.txt (added)
-
tags/3.2.0/classes/ActionScheduler_QueueCleaner.php (modified) (3 diffs)
-
tags/3.2.0/classes/ActionScheduler_wcSystemStatus.php (modified) (2 diffs)
-
tags/3.2.0/classes/abstracts/ActionScheduler_Abstract_ListTable.php (modified) (2 diffs)
-
tags/3.2.0/classes/abstracts/ActionScheduler_Store.php (modified) (3 diffs)
-
tags/3.2.0/classes/actions/ActionScheduler_Action.php (modified) (1 diff)
-
tags/3.2.0/classes/data-stores/ActionScheduler_DBStore.php (modified) (6 diffs)
-
tags/3.2.0/classes/data-stores/ActionScheduler_wpPostStore.php (modified) (3 diffs)
-
tags/3.2.0/classes/migration/Controller.php (modified) (1 diff)
-
tags/3.2.0/classes/schema/ActionScheduler_StoreSchema.php (modified) (2 diffs)
-
tags/3.2.0/functions.php (modified) (1 diff)
-
tags/3.2.0/readme.txt (modified) (2 diffs)
-
trunk/action-scheduler.php (modified) (4 diffs)
-
trunk/changelog.txt (added)
-
trunk/classes/ActionScheduler_QueueCleaner.php (modified) (3 diffs)
-
trunk/classes/ActionScheduler_wcSystemStatus.php (modified) (2 diffs)
-
trunk/classes/abstracts/ActionScheduler_Abstract_ListTable.php (modified) (2 diffs)
-
trunk/classes/abstracts/ActionScheduler_Store.php (modified) (3 diffs)
-
trunk/classes/actions/ActionScheduler_Action.php (modified) (1 diff)
-
trunk/classes/data-stores/ActionScheduler_DBStore.php (modified) (6 diffs)
-
trunk/classes/data-stores/ActionScheduler_wpPostStore.php (modified) (3 diffs)
-
trunk/classes/migration/Controller.php (modified) (1 diff)
-
trunk/classes/schema/ActionScheduler_StoreSchema.php (modified) (2 diffs)
-
trunk/functions.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
action-scheduler/tags/3.2.0/action-scheduler.php
r2340383 r2542151 6 6 * Author: Automattic 7 7 * Author URI: https://automattic.com/ 8 * Version: 3. 1.68 * Version: 3.2.0 9 9 * License: GPLv3 10 10 * … … 26 26 */ 27 27 28 if ( ! function_exists( 'action_scheduler_register_3_dot_ 1_dot_6' ) ) {28 if ( ! function_exists( 'action_scheduler_register_3_dot_2_dot_0' ) ) { 29 29 30 30 if ( ! class_exists( 'ActionScheduler_Versions' ) ) { … … 33 33 } 34 34 35 add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_ 1_dot_6', 0, 0 );35 add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_2_dot_0', 0, 0 ); 36 36 37 function action_scheduler_register_3_dot_ 1_dot_6() {37 function action_scheduler_register_3_dot_2_dot_0() { 38 38 $versions = ActionScheduler_Versions::instance(); 39 $versions->register( '3. 1.6', 'action_scheduler_initialize_3_dot_1_dot_6' );39 $versions->register( '3.2.0', 'action_scheduler_initialize_3_dot_2_dot_0' ); 40 40 } 41 41 42 function action_scheduler_initialize_3_dot_ 1_dot_6() {42 function action_scheduler_initialize_3_dot_2_dot_0() { 43 43 require_once( 'classes/abstracts/ActionScheduler.php' ); 44 44 ActionScheduler::init( __FILE__ ); … … 47 47 // Support usage in themes - load this version if no plugin has loaded a version yet. 48 48 if ( did_action( 'plugins_loaded' ) && ! class_exists( 'ActionScheduler' ) ) { 49 action_scheduler_initialize_3_dot_ 1_dot_6();49 action_scheduler_initialize_3_dot_2_dot_0(); 50 50 do_action( 'action_scheduler_pre_theme_init' ); 51 51 ActionScheduler_Versions::initialize_latest_version(); -
action-scheduler/tags/3.2.0/classes/ActionScheduler_QueueCleaner.php
r2340383 r2542151 45 45 'modified_compare' => '<=', 46 46 'per_page' => $this->get_batch_size(), 47 'orderby' => 'none', 47 48 ) ); 48 49 … … 91 92 'claimed' => true, 92 93 'per_page' => $this->get_batch_size(), 94 'orderby' => 'none', 93 95 ) ); 94 96 … … 119 121 'modified_compare' => '<=', 120 122 'per_page' => $this->get_batch_size(), 123 'orderby' => 'none', 121 124 ) ); 122 125 -
action-scheduler/tags/3.2.0/classes/ActionScheduler_wcSystemStatus.php
r2340383 r2542151 94 94 protected function get_template( $status_labels, $action_counts, $oldest_and_newest ) { 95 95 $as_version = ActionScheduler_Versions::instance()->latest_version(); 96 $as_datastore = get_class( ActionScheduler_Store::instance() ); 96 97 ?> 97 98 … … 99 100 <thead> 100 101 <tr> 101 <th colspan="5" data-export-label="Action Scheduler"><h2><?php esc_html_e( 'Action Scheduler', 'action-scheduler' ); ?><?php echo wc_help_tip( esc_html__( 'This section shows scheduled action counts.', 'action-scheduler' ) ); ?></h2></th>102 <th colspan="5" data-export-label="Action Scheduler"><h2><?php esc_html_e( 'Action Scheduler', 'action-scheduler' ); ?><?php echo wc_help_tip( esc_html__( 'This section shows details of Action Scheduler.', 'action-scheduler' ) ); ?></h2></th> 102 103 </tr> 103 104 <tr> 104 105 <td colspan="2" data-export-label="Version"><?php esc_html_e( 'Version:', 'action-scheduler' ); ?></td> 105 106 <td colspan="3"><?php echo esc_html( $as_version ); ?></td> 107 </tr> 108 <tr> 109 <td colspan="2" data-export-label="Data store"><?php esc_html_e( 'Data store:', 'action-scheduler' ); ?></td> 110 <td colspan="3"><?php echo esc_html( $as_datastore ); ?></td> 106 111 </tr> 107 112 <tr> -
action-scheduler/tags/3.2.0/classes/abstracts/ActionScheduler_Abstract_ListTable.php
r2340383 r2542151 106 106 * Makes translation easier, it basically just wraps 107 107 * `_x` with some default (the package name). 108 * 108 * 109 109 * @deprecated 3.0.0 110 110 */ … … 626 626 echo '<form id="' . esc_attr( $this->_args['plural'] ) . '-filter" method="get">'; 627 627 foreach ( $_GET as $key => $value ) { 628 if ( '_' === $key[0] || 'paged' === $key ) {628 if ( '_' === $key[0] || 'paged' === $key || 'ID' === $key ) { 629 629 continue; 630 630 } -
action-scheduler/tags/3.2.0/classes/abstracts/ActionScheduler_Store.php
r2340383 r2542151 243 243 $action_ids = $this->query_actions( 244 244 array( 245 'hook' => $hook,246 'status' => self::STATUS_PENDING,245 'hook' => $hook, 246 'status' => self::STATUS_PENDING, 247 247 'per_page' => 1000, 248 'orderby' => 'action_id', 248 249 ) 249 250 ); … … 267 268 $action_ids = $this->query_actions( 268 269 array( 269 'group' => $group,270 'status' => self::STATUS_PENDING,270 'group' => $group, 271 'status' => self::STATUS_PENDING, 271 272 'per_page' => 1000, 273 'orderby' => 'action_id', 272 274 ) 273 275 ); … … 316 318 public function has_pending_actions_due() { 317 319 $pending_actions = $this->query_actions( array( 318 'date' => as_get_datetime_object(), 319 'status' => ActionScheduler_Store::STATUS_PENDING, 320 'date' => as_get_datetime_object(), 321 'status' => ActionScheduler_Store::STATUS_PENDING, 322 'orderby' => 'none', 320 323 ) ); 321 324 -
action-scheduler/tags/3.2.0/classes/actions/ActionScheduler_Action.php
r2340383 r2542151 20 20 21 21 public function execute() { 22 return do_action_ref_array( $this->get_hook(), $this->get_args());22 return do_action_ref_array( $this->get_hook(), array_values( $this->get_args() ) ); 23 23 } 24 24 -
action-scheduler/tags/3.2.0/classes/data-stores/ActionScheduler_DBStore.php
r2340383 r2542151 9 9 */ 10 10 class ActionScheduler_DBStore extends ActionScheduler_Store { 11 12 /** 13 * Used to share information about the before_date property of claims internally. 14 * 15 * This is used in preference to passing the same information as a method param 16 * for backwards-compatibility reasons. 17 * 18 * @var DateTime|null 19 */ 20 private $claim_before_date = null; 11 21 12 22 /** @var int */ … … 359 369 360 370 if ( 'select' === $select_or_count ) { 371 if ( 'ASC' === strtoupper( $query['order'] ) ) { 372 $order = 'ASC'; 373 } else { 374 $order = 'DESC'; 375 } 361 376 switch ( $query['orderby'] ) { 362 377 case 'hook': 363 $ orderby = 'a.hook';378 $sql .= " ORDER BY a.hook $order"; 364 379 break; 365 380 case 'group': 366 $ orderby = 'g.slug';381 $sql .= " ORDER BY g.slug $order"; 367 382 break; 368 383 case 'modified': 369 $orderby = 'a.last_attempt_gmt'; 384 $sql .= " ORDER BY a.last_attempt_gmt $order"; 385 break; 386 case 'none': 387 break; 388 case 'action_id': 389 $sql .= " ORDER BY a.action_id $order"; 370 390 break; 371 391 case 'date': 372 392 default: 373 $ orderby = 'a.scheduled_date_gmt';393 $sql .= " ORDER BY a.scheduled_date_gmt $order"; 374 394 break; 375 395 } 376 if ( strtoupper( $query[ 'order' ] ) == 'ASC' ) { 377 $order = 'ASC'; 378 } else { 379 $order = 'DESC'; 380 } 381 $sql .= " ORDER BY $orderby $order"; 396 382 397 if ( $query[ 'per_page' ] > 0 ) { 383 398 $sql .= " LIMIT %d, %d"; … … 510 525 [ 511 526 'per_page' => 1000, 512 'status' => self::STATUS_PENDING, 527 'status' => self::STATUS_PENDING, 528 'orderby' => 'action_id', 513 529 ] 514 530 ); … … 597 613 public function stake_claim( $max_actions = 10, \DateTime $before_date = null, $hooks = array(), $group = '' ) { 598 614 $claim_id = $this->generate_claim_id(); 615 616 $this->claim_before_date = $before_date; 599 617 $this->claim_actions( $claim_id, $max_actions, $before_date, $hooks, $group ); 600 618 $action_ids = $this->find_actions_by_claim_id( $claim_id ); 619 $this->claim_before_date = null; 601 620 602 621 return new ActionScheduler_ActionClaim( $claim_id, $action_ids ); … … 712 731 * Retrieve the action IDs of action in a claim. 713 732 * 714 * @param string $claim_id Claim ID.715 *716 733 * @return int[] 717 734 */ … … 720 737 global $wpdb; 721 738 722 $sql = "SELECT action_id FROM {$wpdb->actionscheduler_actions} WHERE claim_id=%d"; 723 $sql = $wpdb->prepare( $sql, $claim_id ); 724 725 $action_ids = $wpdb->get_col( $sql ); 726 727 return array_map( 'intval', $action_ids ); 739 $action_ids = array(); 740 $before_date = isset( $this->claim_before_date ) ? $this->claim_before_date : as_get_datetime_object(); 741 $cut_off = $before_date->format( 'Y-m-d H:i:s' ); 742 743 $sql = $wpdb->prepare( 744 "SELECT action_id, scheduled_date_gmt FROM {$wpdb->actionscheduler_actions} WHERE claim_id = %d", 745 $claim_id 746 ); 747 748 // Verify that the scheduled date for each action is within the expected bounds (in some unusual 749 // cases, we cannot depend on MySQL to honor all of the WHERE conditions we specify). 750 foreach ( $wpdb->get_results( $sql ) as $claimed_action ) { 751 if ( $claimed_action->scheduled_date_gmt <= $cut_off ) { 752 $action_ids[] = absint( $claimed_action->action_id ); 753 } 754 } 755 756 return $action_ids; 728 757 } 729 758 -
action-scheduler/tags/3.2.0/classes/data-stores/ActionScheduler_wpPostStore.php
r2340383 r2542151 9 9 const SCHEDULE_META_KEY = '_action_manager_schedule'; 10 10 const DEPENDENCIES_MET = 'as-post-store-dependencies-met'; 11 12 /** 13 * Used to share information about the before_date property of claims internally. 14 * 15 * This is used in preference to passing the same information as a method param 16 * for backwards-compatibility reasons. 17 * 18 * @var DateTime|null 19 */ 20 private $claim_before_date = null; 11 21 12 22 /** @var DateTimeZone */ … … 513 523 */ 514 524 public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' ) { 525 $this->claim_before_date = $before_date; 515 526 $claim_id = $this->generate_claim_id(); 516 527 $this->claim_actions( $claim_id, $max_actions, $before_date, $hooks, $group ); 517 528 $action_ids = $this->find_actions_by_claim_id( $claim_id ); 529 $this->claim_before_date = null; 518 530 519 531 return new ActionScheduler_ActionClaim( $claim_id, $action_ids ); … … 668 680 /** @var wpdb $wpdb */ 669 681 global $wpdb; 670 $sql = "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_password = %s"; 682 683 $sql = "SELECT ID, post_date_gmt FROM {$wpdb->posts} WHERE post_type = %s AND post_password = %s"; 671 684 $sql = $wpdb->prepare( $sql, array( self::POST_TYPE, $claim_id ) ); 672 $action_ids = $wpdb->get_col( $sql ); 685 686 $action_ids = array(); 687 $before_date = isset( $this->claim_before_date ) ? $this->claim_before_date : as_get_datetime_object(); 688 $cut_off = $before_date->format( 'Y-m-d H:i:s' ); 689 690 // Verify that the scheduled date for each action is within the expected bounds (in some unusual 691 // cases, we cannot depend on MySQL to honor all of the WHERE conditions we specify). 692 foreach ( $wpdb->get_results( $sql ) as $claimed_action ) { 693 if ( $claimed_action->post_date_gmt <= $cut_off ) { 694 $action_ids[] = absint( $claimed_action->ID ); 695 } 696 } 697 673 698 return $action_ids; 674 699 } -
action-scheduler/tags/3.2.0/classes/migration/Controller.php
r2340383 r2542151 140 140 */ 141 141 public function display_migration_notice() { 142 printf( '<div class="notice notice-warning"><p>%s</p></div>', __( 'Action Scheduler migration in progress. The list of scheduled actions may be incomplete.', 'action-scheduler' ) );142 printf( '<div class="notice notice-warning"><p>%s</p></div>', esc_html__( 'Action Scheduler migration in progress. The list of scheduled actions may be incomplete.', 'action-scheduler' ) ); 143 143 } 144 144 -
action-scheduler/tags/3.2.0/classes/schema/ActionScheduler_StoreSchema.php
r2340383 r2542151 16 16 * @var int Increment this value to trigger a schema update. 17 17 */ 18 protected $schema_version = 3;18 protected $schema_version = 4; 19 19 20 20 public function __construct() { … … 56 56 KEY group_id (group_id), 57 57 KEY last_attempt_gmt (last_attempt_gmt), 58 KEY claim_id (claim_id) 58 KEY claim_id (claim_id), 59 KEY `claim_id_status_scheduled_date_gmt` (`claim_id`, `status`, `scheduled_date_gmt`) 59 60 ) $charset_collate"; 60 61 -
action-scheduler/tags/3.2.0/functions.php
r2340383 r2542151 210 210 * 'per_page' => 5 - Number of results to return 211 211 * 'offset' => 0 212 * 'orderby' => 'date' - accepted values are 'hook', 'group', 'modified', or 'date'212 * 'orderby' => 'date' - accepted values are 'hook', 'group', 'modified', 'date' or 'none' 213 213 * 'order' => 'ASC' 214 214 * -
action-scheduler/tags/3.2.0/readme.txt
r2340433 r2542151 1 1 === Action Scheduler === 2 Contributors: Automattic, wpmuguru 2 Contributors: Automattic, wpmuguru, claudiosanches, peterfabian1000, vedjain, jamosova, obliviousharmony, konamiman, sadowski, royho, barryhughes-1 3 3 Tags: scheduler, cron 4 4 Requires at least: 4.7 5 Tested up to: 5. 46 Stable tag: 3. 1.65 Tested up to: 5.7 6 Stable tag: 3.2.0 7 7 License: GPLv3 8 8 Requires PHP: 5.3 … … 46 46 Collaboration is cool. We'd love to work with you to improve Action Scheduler. [Pull Requests](https://github.com/woocommerce/action-scheduler/pulls) welcome. 47 47 48 == Changelog == 48 49 50 = 3.2.0 - 2021-06-03 = 51 * Fix - Add "no ordering" option to as_next_scheduled_action(). 52 * Fix - Add secondary scheduled date checks when claiming actions (DBStore) | #634. 53 * Fix - Add secondary scheduled date checks when claiming actions (wpPostStore) | #634. 54 * Fix - Adds a new index to the action table, reducing the potential for deadlocks (props: @glagonikas). 55 * Fix - Fix unit tests infrastructure and adapt tests to PHP 8. 56 * Fix - Identify in-use data store. 57 * Fix - Improve test_migration_is_scheduled. 58 * Fix - PHP notice on list table. 59 * Fix - Speed up clean up and batch selects. 60 * Fix - Update pending dependencies. 61 * Fix - [PHP 8.0] Only pass action arg values through to do_action_ref_array(). 62 * Fix - [PHP 8] Set the PHP version to 7.1 in composer.json for PHP 8 compatibility. 63 * Fix - add is_initialized() to docs. 64 * Fix - fix file permissions. 65 * Fix - fixes #664 by replacing __ with esc_html__. -
action-scheduler/trunk/action-scheduler.php
r2340383 r2542151 6 6 * Author: Automattic 7 7 * Author URI: https://automattic.com/ 8 * Version: 3. 1.68 * Version: 3.2.0 9 9 * License: GPLv3 10 10 * … … 26 26 */ 27 27 28 if ( ! function_exists( 'action_scheduler_register_3_dot_ 1_dot_6' ) ) {28 if ( ! function_exists( 'action_scheduler_register_3_dot_2_dot_0' ) ) { 29 29 30 30 if ( ! class_exists( 'ActionScheduler_Versions' ) ) { … … 33 33 } 34 34 35 add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_ 1_dot_6', 0, 0 );35 add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_2_dot_0', 0, 0 ); 36 36 37 function action_scheduler_register_3_dot_ 1_dot_6() {37 function action_scheduler_register_3_dot_2_dot_0() { 38 38 $versions = ActionScheduler_Versions::instance(); 39 $versions->register( '3. 1.6', 'action_scheduler_initialize_3_dot_1_dot_6' );39 $versions->register( '3.2.0', 'action_scheduler_initialize_3_dot_2_dot_0' ); 40 40 } 41 41 42 function action_scheduler_initialize_3_dot_ 1_dot_6() {42 function action_scheduler_initialize_3_dot_2_dot_0() { 43 43 require_once( 'classes/abstracts/ActionScheduler.php' ); 44 44 ActionScheduler::init( __FILE__ ); … … 47 47 // Support usage in themes - load this version if no plugin has loaded a version yet. 48 48 if ( did_action( 'plugins_loaded' ) && ! class_exists( 'ActionScheduler' ) ) { 49 action_scheduler_initialize_3_dot_ 1_dot_6();49 action_scheduler_initialize_3_dot_2_dot_0(); 50 50 do_action( 'action_scheduler_pre_theme_init' ); 51 51 ActionScheduler_Versions::initialize_latest_version(); -
action-scheduler/trunk/classes/ActionScheduler_QueueCleaner.php
r2340383 r2542151 45 45 'modified_compare' => '<=', 46 46 'per_page' => $this->get_batch_size(), 47 'orderby' => 'none', 47 48 ) ); 48 49 … … 91 92 'claimed' => true, 92 93 'per_page' => $this->get_batch_size(), 94 'orderby' => 'none', 93 95 ) ); 94 96 … … 119 121 'modified_compare' => '<=', 120 122 'per_page' => $this->get_batch_size(), 123 'orderby' => 'none', 121 124 ) ); 122 125 -
action-scheduler/trunk/classes/ActionScheduler_wcSystemStatus.php
r2340383 r2542151 94 94 protected function get_template( $status_labels, $action_counts, $oldest_and_newest ) { 95 95 $as_version = ActionScheduler_Versions::instance()->latest_version(); 96 $as_datastore = get_class( ActionScheduler_Store::instance() ); 96 97 ?> 97 98 … … 99 100 <thead> 100 101 <tr> 101 <th colspan="5" data-export-label="Action Scheduler"><h2><?php esc_html_e( 'Action Scheduler', 'action-scheduler' ); ?><?php echo wc_help_tip( esc_html__( 'This section shows scheduled action counts.', 'action-scheduler' ) ); ?></h2></th>102 <th colspan="5" data-export-label="Action Scheduler"><h2><?php esc_html_e( 'Action Scheduler', 'action-scheduler' ); ?><?php echo wc_help_tip( esc_html__( 'This section shows details of Action Scheduler.', 'action-scheduler' ) ); ?></h2></th> 102 103 </tr> 103 104 <tr> 104 105 <td colspan="2" data-export-label="Version"><?php esc_html_e( 'Version:', 'action-scheduler' ); ?></td> 105 106 <td colspan="3"><?php echo esc_html( $as_version ); ?></td> 107 </tr> 108 <tr> 109 <td colspan="2" data-export-label="Data store"><?php esc_html_e( 'Data store:', 'action-scheduler' ); ?></td> 110 <td colspan="3"><?php echo esc_html( $as_datastore ); ?></td> 106 111 </tr> 107 112 <tr> -
action-scheduler/trunk/classes/abstracts/ActionScheduler_Abstract_ListTable.php
r2340383 r2542151 106 106 * Makes translation easier, it basically just wraps 107 107 * `_x` with some default (the package name). 108 * 108 * 109 109 * @deprecated 3.0.0 110 110 */ … … 626 626 echo '<form id="' . esc_attr( $this->_args['plural'] ) . '-filter" method="get">'; 627 627 foreach ( $_GET as $key => $value ) { 628 if ( '_' === $key[0] || 'paged' === $key ) {628 if ( '_' === $key[0] || 'paged' === $key || 'ID' === $key ) { 629 629 continue; 630 630 } -
action-scheduler/trunk/classes/abstracts/ActionScheduler_Store.php
r2340383 r2542151 243 243 $action_ids = $this->query_actions( 244 244 array( 245 'hook' => $hook,246 'status' => self::STATUS_PENDING,245 'hook' => $hook, 246 'status' => self::STATUS_PENDING, 247 247 'per_page' => 1000, 248 'orderby' => 'action_id', 248 249 ) 249 250 ); … … 267 268 $action_ids = $this->query_actions( 268 269 array( 269 'group' => $group,270 'status' => self::STATUS_PENDING,270 'group' => $group, 271 'status' => self::STATUS_PENDING, 271 272 'per_page' => 1000, 273 'orderby' => 'action_id', 272 274 ) 273 275 ); … … 316 318 public function has_pending_actions_due() { 317 319 $pending_actions = $this->query_actions( array( 318 'date' => as_get_datetime_object(), 319 'status' => ActionScheduler_Store::STATUS_PENDING, 320 'date' => as_get_datetime_object(), 321 'status' => ActionScheduler_Store::STATUS_PENDING, 322 'orderby' => 'none', 320 323 ) ); 321 324 -
action-scheduler/trunk/classes/actions/ActionScheduler_Action.php
r2340383 r2542151 20 20 21 21 public function execute() { 22 return do_action_ref_array( $this->get_hook(), $this->get_args());22 return do_action_ref_array( $this->get_hook(), array_values( $this->get_args() ) ); 23 23 } 24 24 -
action-scheduler/trunk/classes/data-stores/ActionScheduler_DBStore.php
r2340383 r2542151 9 9 */ 10 10 class ActionScheduler_DBStore extends ActionScheduler_Store { 11 12 /** 13 * Used to share information about the before_date property of claims internally. 14 * 15 * This is used in preference to passing the same information as a method param 16 * for backwards-compatibility reasons. 17 * 18 * @var DateTime|null 19 */ 20 private $claim_before_date = null; 11 21 12 22 /** @var int */ … … 359 369 360 370 if ( 'select' === $select_or_count ) { 371 if ( 'ASC' === strtoupper( $query['order'] ) ) { 372 $order = 'ASC'; 373 } else { 374 $order = 'DESC'; 375 } 361 376 switch ( $query['orderby'] ) { 362 377 case 'hook': 363 $ orderby = 'a.hook';378 $sql .= " ORDER BY a.hook $order"; 364 379 break; 365 380 case 'group': 366 $ orderby = 'g.slug';381 $sql .= " ORDER BY g.slug $order"; 367 382 break; 368 383 case 'modified': 369 $orderby = 'a.last_attempt_gmt'; 384 $sql .= " ORDER BY a.last_attempt_gmt $order"; 385 break; 386 case 'none': 387 break; 388 case 'action_id': 389 $sql .= " ORDER BY a.action_id $order"; 370 390 break; 371 391 case 'date': 372 392 default: 373 $ orderby = 'a.scheduled_date_gmt';393 $sql .= " ORDER BY a.scheduled_date_gmt $order"; 374 394 break; 375 395 } 376 if ( strtoupper( $query[ 'order' ] ) == 'ASC' ) { 377 $order = 'ASC'; 378 } else { 379 $order = 'DESC'; 380 } 381 $sql .= " ORDER BY $orderby $order"; 396 382 397 if ( $query[ 'per_page' ] > 0 ) { 383 398 $sql .= " LIMIT %d, %d"; … … 510 525 [ 511 526 'per_page' => 1000, 512 'status' => self::STATUS_PENDING, 527 'status' => self::STATUS_PENDING, 528 'orderby' => 'action_id', 513 529 ] 514 530 ); … … 597 613 public function stake_claim( $max_actions = 10, \DateTime $before_date = null, $hooks = array(), $group = '' ) { 598 614 $claim_id = $this->generate_claim_id(); 615 616 $this->claim_before_date = $before_date; 599 617 $this->claim_actions( $claim_id, $max_actions, $before_date, $hooks, $group ); 600 618 $action_ids = $this->find_actions_by_claim_id( $claim_id ); 619 $this->claim_before_date = null; 601 620 602 621 return new ActionScheduler_ActionClaim( $claim_id, $action_ids ); … … 712 731 * Retrieve the action IDs of action in a claim. 713 732 * 714 * @param string $claim_id Claim ID.715 *716 733 * @return int[] 717 734 */ … … 720 737 global $wpdb; 721 738 722 $sql = "SELECT action_id FROM {$wpdb->actionscheduler_actions} WHERE claim_id=%d"; 723 $sql = $wpdb->prepare( $sql, $claim_id ); 724 725 $action_ids = $wpdb->get_col( $sql ); 726 727 return array_map( 'intval', $action_ids ); 739 $action_ids = array(); 740 $before_date = isset( $this->claim_before_date ) ? $this->claim_before_date : as_get_datetime_object(); 741 $cut_off = $before_date->format( 'Y-m-d H:i:s' ); 742 743 $sql = $wpdb->prepare( 744 "SELECT action_id, scheduled_date_gmt FROM {$wpdb->actionscheduler_actions} WHERE claim_id = %d", 745 $claim_id 746 ); 747 748 // Verify that the scheduled date for each action is within the expected bounds (in some unusual 749 // cases, we cannot depend on MySQL to honor all of the WHERE conditions we specify). 750 foreach ( $wpdb->get_results( $sql ) as $claimed_action ) { 751 if ( $claimed_action->scheduled_date_gmt <= $cut_off ) { 752 $action_ids[] = absint( $claimed_action->action_id ); 753 } 754 } 755 756 return $action_ids; 728 757 } 729 758 -
action-scheduler/trunk/classes/data-stores/ActionScheduler_wpPostStore.php
r2340383 r2542151 9 9 const SCHEDULE_META_KEY = '_action_manager_schedule'; 10 10 const DEPENDENCIES_MET = 'as-post-store-dependencies-met'; 11 12 /** 13 * Used to share information about the before_date property of claims internally. 14 * 15 * This is used in preference to passing the same information as a method param 16 * for backwards-compatibility reasons. 17 * 18 * @var DateTime|null 19 */ 20 private $claim_before_date = null; 11 21 12 22 /** @var DateTimeZone */ … … 513 523 */ 514 524 public function stake_claim( $max_actions = 10, DateTime $before_date = null, $hooks = array(), $group = '' ) { 525 $this->claim_before_date = $before_date; 515 526 $claim_id = $this->generate_claim_id(); 516 527 $this->claim_actions( $claim_id, $max_actions, $before_date, $hooks, $group ); 517 528 $action_ids = $this->find_actions_by_claim_id( $claim_id ); 529 $this->claim_before_date = null; 518 530 519 531 return new ActionScheduler_ActionClaim( $claim_id, $action_ids ); … … 668 680 /** @var wpdb $wpdb */ 669 681 global $wpdb; 670 $sql = "SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND post_password = %s"; 682 683 $sql = "SELECT ID, post_date_gmt FROM {$wpdb->posts} WHERE post_type = %s AND post_password = %s"; 671 684 $sql = $wpdb->prepare( $sql, array( self::POST_TYPE, $claim_id ) ); 672 $action_ids = $wpdb->get_col( $sql ); 685 686 $action_ids = array(); 687 $before_date = isset( $this->claim_before_date ) ? $this->claim_before_date : as_get_datetime_object(); 688 $cut_off = $before_date->format( 'Y-m-d H:i:s' ); 689 690 // Verify that the scheduled date for each action is within the expected bounds (in some unusual 691 // cases, we cannot depend on MySQL to honor all of the WHERE conditions we specify). 692 foreach ( $wpdb->get_results( $sql ) as $claimed_action ) { 693 if ( $claimed_action->post_date_gmt <= $cut_off ) { 694 $action_ids[] = absint( $claimed_action->ID ); 695 } 696 } 697 673 698 return $action_ids; 674 699 } -
action-scheduler/trunk/classes/migration/Controller.php
r2340383 r2542151 140 140 */ 141 141 public function display_migration_notice() { 142 printf( '<div class="notice notice-warning"><p>%s</p></div>', __( 'Action Scheduler migration in progress. The list of scheduled actions may be incomplete.', 'action-scheduler' ) );142 printf( '<div class="notice notice-warning"><p>%s</p></div>', esc_html__( 'Action Scheduler migration in progress. The list of scheduled actions may be incomplete.', 'action-scheduler' ) ); 143 143 } 144 144 -
action-scheduler/trunk/classes/schema/ActionScheduler_StoreSchema.php
r2340383 r2542151 16 16 * @var int Increment this value to trigger a schema update. 17 17 */ 18 protected $schema_version = 3;18 protected $schema_version = 4; 19 19 20 20 public function __construct() { … … 56 56 KEY group_id (group_id), 57 57 KEY last_attempt_gmt (last_attempt_gmt), 58 KEY claim_id (claim_id) 58 KEY claim_id (claim_id), 59 KEY `claim_id_status_scheduled_date_gmt` (`claim_id`, `status`, `scheduled_date_gmt`) 59 60 ) $charset_collate"; 60 61 -
action-scheduler/trunk/functions.php
r2340383 r2542151 210 210 * 'per_page' => 5 - Number of results to return 211 211 * 'offset' => 0 212 * 'orderby' => 'date' - accepted values are 'hook', 'group', 'modified', or 'date'212 * 'orderby' => 'date' - accepted values are 'hook', 'group', 'modified', 'date' or 'none' 213 213 * 'order' => 'ASC' 214 214 * -
action-scheduler/trunk/readme.txt
r2340433 r2542151 1 1 === Action Scheduler === 2 Contributors: Automattic, wpmuguru 2 Contributors: Automattic, wpmuguru, claudiosanches, peterfabian1000, vedjain, jamosova, obliviousharmony, konamiman, sadowski, royho, barryhughes-1 3 3 Tags: scheduler, cron 4 4 Requires at least: 4.7 5 Tested up to: 5. 46 Stable tag: 3. 1.65 Tested up to: 5.7 6 Stable tag: 3.2.0 7 7 License: GPLv3 8 8 Requires PHP: 5.3 … … 46 46 Collaboration is cool. We'd love to work with you to improve Action Scheduler. [Pull Requests](https://github.com/woocommerce/action-scheduler/pulls) welcome. 47 47 48 == Changelog == 48 49 50 = 3.2.0 - 2021-06-03 = 51 * Fix - Add "no ordering" option to as_next_scheduled_action(). 52 * Fix - Add secondary scheduled date checks when claiming actions (DBStore) | #634. 53 * Fix - Add secondary scheduled date checks when claiming actions (wpPostStore) | #634. 54 * Fix - Adds a new index to the action table, reducing the potential for deadlocks (props: @glagonikas). 55 * Fix - Fix unit tests infrastructure and adapt tests to PHP 8. 56 * Fix - Identify in-use data store. 57 * Fix - Improve test_migration_is_scheduled. 58 * Fix - PHP notice on list table. 59 * Fix - Speed up clean up and batch selects. 60 * Fix - Update pending dependencies. 61 * Fix - [PHP 8.0] Only pass action arg values through to do_action_ref_array(). 62 * Fix - [PHP 8] Set the PHP version to 7.1 in composer.json for PHP 8 compatibility. 63 * Fix - add is_initialized() to docs. 64 * Fix - fix file permissions. 65 * Fix - fixes #664 by replacing __ with esc_html__.
Note: See TracChangeset
for help on using the changeset viewer.