Skip to content

Commit 53b8b5e

Browse files
authored
Merge pull request #9 from iamsayan/develop
Develop
2 parents 7b3f7cc + 78cc9df commit 53b8b5e

File tree

10 files changed

+129
-65
lines changed

10 files changed

+129
-65
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ If you like Advanced Cron Scheduler plugin, please take a moment to [give a 5-st
44

55
All notable changes to this project will be documented in this file.
66

7+
## 1.0.9
8+
Release Date: 15th November, 2022
9+
10+
* Updated: Action Scheduler library to v3.5.3.
11+
* Tested with WordPress 6.1.
12+
713
## 1.0.8
814
Release Date: 28th August, 2022
915

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

languages/migrate-wp-cron-to-action-scheduler.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# This file is distributed under the GPLv3.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Advanced Cron Scheduler 1.0.8\n"
5+
"Project-Id-Version: Advanced Cron Scheduler 1.0.9\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/migrate-wp-cron-to-action-scheduler\n"
77
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
88
"Language-Team: LANGUAGE <LL@li.org>\n"
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=UTF-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
12-
"POT-Creation-Date: 2022-08-28T03:39:46+00:00\n"
12+
"POT-Creation-Date: 2022-11-15T06:49:36+00:00\n"
1313
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1414
"X-Generator: WP-CLI 2.5.0\n"
1515
"X-Domain: migrate-wp-cron-to-action-scheduler\n"

migrate-wp-cron-to-action-scheduler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Advanced Cron Scheduler
44
* Plugin URI: https://wordpress.org/plugins/migrate-wp-cron-to-action-scheduler/
55
* Description: The Advanced Cron Scheduler plugin helps to easily replace or migrate Native WordPress Cron to the Action Scheduler Library.
6-
* Version: 1.0.8
6+
* Version: 1.0.9
77
* Author: Sayan Datta
88
* Author URI: https://sayandatta.in
99
* License: GPLv3
@@ -35,7 +35,7 @@
3535
}
3636

3737
if ( ! defined( 'ACSWP_PLUGIN_VERSION' ) ) {
38-
define( 'ACSWP_PLUGIN_VERSION', '1.0.8' );
38+
define( 'ACSWP_PLUGIN_VERSION', '1.0.9' );
3939
}
4040

4141
// Require once the Composer Autoload

readme.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contributors: Infosatech
33
Tags: scheduler, cron, wp cron, debug, cron manager
44
Requires at least: 5.2
5-
Tested up to: 6.0
6-
Stable tag: 1.0.8
5+
Tested up to: 6.1
6+
Stable tag: 1.0.9
77
Requires PHP: 5.6
88
Donate link: https://www.paypal.me/iamsayan/
99
License: GPLv3
@@ -95,6 +95,12 @@ Yes, our plugins work independently of themes you are using. As long as your web
9595

9696
If you like Advanced Cron Scheduler, please take a moment to [give a 5-star rating](https://wordpress.org/support/plugin/migrate-wp-cron-to-action-scheduler/reviews/#new-post). It helps to keep development and support going strong. Thank you!
9797

98+
= 1.0.9 =
99+
Release Date: 15th November, 2022
100+
101+
* Updated: Action Scheduler library to v3.5.3.
102+
* Tested with WordPress 6.1.
103+
98104
= 1.0.8 =
99105
Release Date: 28th August, 2022
100106

vendor/composer/installed.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
"packages": [
33
{
44
"name": "woocommerce/action-scheduler",
5-
"version": "3.5.0",
6-
"version_normalized": "3.5.0.0",
5+
"version": "3.5.3",
6+
"version_normalized": "3.5.3.0",
77
"source": {
88
"type": "git",
99
"url": "https://github.com/woocommerce/action-scheduler.git",
10-
"reference": "2f013f99dbea83933431a10f2a92c3388545ea43"
10+
"reference": "63ef5af013ca3a6efdd8ef8e9363ac70778713cb"
1111
},
1212
"dist": {
1313
"type": "zip",
14-
"url": "https://api.github.com/repos/woocommerce/action-scheduler/zipball/2f013f99dbea83933431a10f2a92c3388545ea43",
15-
"reference": "2f013f99dbea83933431a10f2a92c3388545ea43",
14+
"url": "https://api.github.com/repos/woocommerce/action-scheduler/zipball/63ef5af013ca3a6efdd8ef8e9363ac70778713cb",
15+
"reference": "63ef5af013ca3a6efdd8ef8e9363ac70778713cb",
1616
"shasum": ""
1717
},
1818
"require-dev": {
@@ -21,7 +21,7 @@
2121
"wp-cli/wp-cli": "~2.5.0",
2222
"yoast/phpunit-polyfills": "^1.0"
2323
},
24-
"time": "2022-08-25T20:43:08+00:00",
24+
"time": "2022-11-09T17:45:19+00:00",
2525
"type": "wordpress-plugin",
2626
"extra": {
2727
"scripts-description": {
@@ -39,7 +39,7 @@
3939
"homepage": "https://actionscheduler.org/",
4040
"support": {
4141
"issues": "https://github.com/woocommerce/action-scheduler/issues",
42-
"source": "https://github.com/woocommerce/action-scheduler/tree/3.5.0"
42+
"source": "https://github.com/woocommerce/action-scheduler/tree/3.5.3"
4343
},
4444
"install-path": "../woocommerce/action-scheduler"
4545
}

vendor/composer/installed.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => 'iamsayan/advanced-cron-scheduler',
44
'pretty_version' => 'dev-develop',
55
'version' => 'dev-develop',
6-
'reference' => '162dde5a53e97e9ba3b7917b862d4eed7cbadf6f',
6+
'reference' => '58d737fb147940028f308df9b00c011e4c720fae',
77
'type' => 'wordpress-plugin',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -13,16 +13,16 @@
1313
'iamsayan/advanced-cron-scheduler' => array(
1414
'pretty_version' => 'dev-develop',
1515
'version' => 'dev-develop',
16-
'reference' => '162dde5a53e97e9ba3b7917b862d4eed7cbadf6f',
16+
'reference' => '58d737fb147940028f308df9b00c011e4c720fae',
1717
'type' => 'wordpress-plugin',
1818
'install_path' => __DIR__ . '/../../',
1919
'aliases' => array(),
2020
'dev_requirement' => false,
2121
),
2222
'woocommerce/action-scheduler' => array(
23-
'pretty_version' => '3.5.0',
24-
'version' => '3.5.0.0',
25-
'reference' => '2f013f99dbea83933431a10f2a92c3388545ea43',
23+
'pretty_version' => '3.5.3',
24+
'version' => '3.5.3.0',
25+
'reference' => '63ef5af013ca3a6efdd8ef8e9363ac70778713cb',
2626
'type' => 'wordpress-plugin',
2727
'install_path' => __DIR__ . '/../woocommerce/action-scheduler',
2828
'aliases' => array(),

vendor/woocommerce/action-scheduler/action-scheduler.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: A robust scheduling library for use in WordPress plugins.
66
* Author: Automattic
77
* Author URI: https://automattic.com/
8-
* Version: 3.5.0
8+
* Version: 3.5.3
99
* License: GPLv3
1010
*
1111
* Copyright 2019 Automattic, Inc. (https://automattic.com/contact/)
@@ -26,27 +26,27 @@
2626
* @package ActionScheduler
2727
*/
2828

29-
if ( ! function_exists( 'action_scheduler_register_3_dot_5_dot_0' ) && function_exists( 'add_action' ) ) {
29+
if ( ! function_exists( 'action_scheduler_register_3_dot_5_dot_3' ) && function_exists( 'add_action' ) ) { // WRCS: DEFINED_VERSION.
3030

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

36-
add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_5_dot_0', 0, 0 );
36+
add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_5_dot_3', 0, 0 ); // WRCS: DEFINED_VERSION.
3737

3838
/**
3939
* Registers this version of Action Scheduler.
4040
*/
41-
function action_scheduler_register_3_dot_5_dot_0() {
41+
function action_scheduler_register_3_dot_5_dot_3() { // WRCS: DEFINED_VERSION.
4242
$versions = ActionScheduler_Versions::instance();
43-
$versions->register( '3.5.0', 'action_scheduler_initialize_3_dot_5_dot_0' );
43+
$versions->register( '3.5.3', 'action_scheduler_initialize_3_dot_5_dot_3' ); // WRCS: DEFINED_VERSION.
4444
}
4545

4646
/**
4747
* Initializes this version of Action Scheduler.
4848
*/
49-
function action_scheduler_initialize_3_dot_5_dot_0() {
49+
function action_scheduler_initialize_3_dot_5_dot_3() { // WRCS: DEFINED_VERSION.
5050
// A final safety check is required even here, because historic versions of Action Scheduler
5151
// followed a different pattern (in some unusual cases, we could reach this point and the
5252
// ActionScheduler class is already defined—so we need to guard against that).
@@ -58,7 +58,7 @@ function action_scheduler_initialize_3_dot_5_dot_0() {
5858

5959
// Support usage in themes - load this version if no plugin has loaded a version yet.
6060
if ( did_action( 'plugins_loaded' ) && ! doing_action( 'plugins_loaded' ) && ! class_exists( 'ActionScheduler', false ) ) {
61-
action_scheduler_initialize_3_dot_5_dot_0();
61+
action_scheduler_initialize_3_dot_5_dot_3(); // WRCS: DEFINED_VERSION.
6262
do_action( 'action_scheduler_pre_theme_init' );
6363
ActionScheduler_Versions::initialize_latest_version();
6464
}

vendor/woocommerce/action-scheduler/classes/data-stores/ActionScheduler_DBStore.php

Lines changed: 79 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -375,49 +375,101 @@ protected function get_query_actions_sql( array $query, $select_or_count = 'sele
375375
throw new InvalidArgumentException( __( 'Invalid value for select or count parameter. Cannot query actions.', 'action-scheduler' ) );
376376
}
377377

378-
$query = wp_parse_args(
379-
$query,
380-
array(
381-
'hook' => '',
382-
'args' => null,
383-
'date' => null,
384-
'date_compare' => '<=',
385-
'modified' => null,
386-
'modified_compare' => '<=',
387-
'group' => '',
388-
'status' => '',
389-
'claimed' => null,
390-
'per_page' => 5,
391-
'offset' => 0,
392-
'orderby' => 'date',
393-
'order' => 'ASC',
394-
)
395-
);
378+
$query = wp_parse_args( $query, array(
379+
'hook' => '',
380+
'args' => null,
381+
'partial_args_matching' => 'off', // can be 'like' or 'json'
382+
'date' => null,
383+
'date_compare' => '<=',
384+
'modified' => null,
385+
'modified_compare' => '<=',
386+
'group' => '',
387+
'status' => '',
388+
'claimed' => null,
389+
'per_page' => 5,
390+
'offset' => 0,
391+
'orderby' => 'date',
392+
'order' => 'ASC',
393+
) );
396394

397395
/** @var \wpdb $wpdb */
398396
global $wpdb;
397+
398+
$db_server_info = is_callable( array( $wpdb, 'db_server_info' ) ) ? $wpdb->db_server_info() : $wpdb->db_version();
399+
if ( false !== strpos( $db_server_info, 'MariaDB' ) ) {
400+
$supports_json = version_compare(
401+
PHP_VERSION_ID >= 80016 ? $wpdb->db_version() : preg_replace( '/[^0-9.].*/', '', str_replace( '5.5.5-', '', $db_server_info ) ),
402+
'10.2',
403+
'>='
404+
);
405+
} else {
406+
$supports_json = version_compare( $wpdb->db_version(), '5.7', '>=' );
407+
}
408+
399409
$sql = ( 'count' === $select_or_count ) ? 'SELECT count(a.action_id)' : 'SELECT a.action_id';
400-
$sql .= " FROM {$wpdb->actionscheduler_actions} a";
410+
$sql .= " FROM {$wpdb->actionscheduler_actions} a";
401411
$sql_params = array();
402412

403413
if ( ! empty( $query['group'] ) || 'group' === $query['orderby'] ) {
404414
$sql .= " LEFT JOIN {$wpdb->actionscheduler_groups} g ON g.group_id=a.group_id";
405415
}
406416

407-
$sql .= ' WHERE 1=1';
417+
$sql .= " WHERE 1=1";
408418

409419
if ( ! empty( $query['group'] ) ) {
410-
$sql .= ' AND g.slug=%s';
420+
$sql .= " AND g.slug=%s";
411421
$sql_params[] = $query['group'];
412422
}
413423

414-
if ( $query['hook'] ) {
415-
$sql .= ' AND a.hook=%s';
424+
if ( ! empty( $query['hook'] ) ) {
425+
$sql .= " AND a.hook=%s";
416426
$sql_params[] = $query['hook'];
417427
}
428+
418429
if ( ! is_null( $query['args'] ) ) {
419-
$sql .= ' AND a.args=%s';
420-
$sql_params[] = $this->get_args_for_query( $query['args'] );
430+
switch ( $query['partial_args_matching'] ) {
431+
case 'json':
432+
if ( ! $supports_json ) {
433+
throw new \RuntimeException( __( 'JSON partial matching not supported in your environment. Please check your MySQL/MariaDB version.', 'action-scheduler' ) );
434+
}
435+
$supported_types = array(
436+
'integer' => '%d',
437+
'boolean' => '%s',
438+
'double' => '%f',
439+
'string' => '%s',
440+
);
441+
foreach ( $query['args'] as $key => $value ) {
442+
$value_type = gettype( $value );
443+
if ( 'boolean' === $value_type ) {
444+
$value = $value ? 'true' : 'false';
445+
}
446+
$placeholder = isset( $supported_types[ $value_type ] ) ? $supported_types[ $value_type ] : false;
447+
if ( ! $placeholder ) {
448+
throw new \RuntimeException( sprintf(
449+
/* translators: %s: provided value type */
450+
__( 'The value type for the JSON partial matching is not supported. Must be either integer, boolean, double or string. %s type provided.', 'action-scheduler' ),
451+
$value_type
452+
) );
453+
}
454+
$sql .= ' AND JSON_EXTRACT(a.args, %s)='.$placeholder;
455+
$sql_params[] = '$.'.$key;
456+
$sql_params[] = $value;
457+
}
458+
break;
459+
case 'like':
460+
foreach ( $query['args'] as $key => $value ) {
461+
$sql .= ' AND a.args LIKE %s';
462+
$json_partial = $wpdb->esc_like( trim( json_encode( array( $key => $value ) ), '{}' ) );
463+
$sql_params[] = "%{$json_partial}%";
464+
}
465+
break;
466+
case 'off':
467+
$sql .= " AND a.args=%s";
468+
$sql_params[] = $this->get_args_for_query( $query['args'] );
469+
break;
470+
default:
471+
throw new \RuntimeException( __( 'Unknown partial args matching value.', 'action-scheduler' ) );
472+
}
421473
}
422474

423475
if ( $query['status'] ) {
@@ -778,7 +830,7 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu
778830

779831
if ( ! empty( $hooks ) ) {
780832
$placeholders = array_fill( 0, count( $hooks ), '%s' );
781-
$where .= ' AND hook IN (' . join( ', ', $placeholders ) . ')';
833+
$where .= ' AND hook IN (' . join( ', ', $placeholders ) . ')';
782834
$params = array_merge( $params, array_values( $hooks ) );
783835
}
784836

@@ -792,7 +844,7 @@ protected function claim_actions( $claim_id, $limit, \DateTime $before_date = nu
792844
throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'action-scheduler' ), $group ) );
793845
}
794846

795-
$where .= ' AND group_id = %d';
847+
$where .= ' AND group_id = %d';
796848
$params[] = $group_id;
797849
}
798850

0 commit comments

Comments
 (0)