Skip to content

Commit 4771986

Browse files
committed
Merge branch 'trunk' into fix-forum-17945942
2 parents 5a6f76f + d4e5dac commit 4771986

File tree

5 files changed

+172
-105
lines changed

5 files changed

+172
-105
lines changed

classes/data-stores/ActionScheduler_HybridStore.php

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,32 @@
1515
class ActionScheduler_HybridStore extends Store {
1616
const DEMARKATION_OPTION = 'action_scheduler_hybrid_store_demarkation';
1717

18-
/** @var ActionScheduler_Store */
18+
/**
19+
* Primary store instance.
20+
*
21+
* @var ActionScheduler_Store
22+
*/
1923
private $primary_store;
20-
/** @var ActionScheduler_Store */
24+
25+
/**
26+
* Secondary store instance.
27+
*
28+
* @var ActionScheduler_Store
29+
*/
2130
private $secondary_store;
22-
/** @var Action_Scheduler\Migration\Runner */
31+
32+
/**
33+
* Runner instance.
34+
*
35+
* @var Action_Scheduler\Migration\Runner
36+
*/
2337
private $migration_runner;
2438

2539
/**
26-
* @var int The dividing line between IDs of actions created
27-
* by the primary and secondary stores.
40+
* The dividing line between IDs of actions created
41+
* by the primary and secondary stores.
42+
*
43+
* @var int
2844
*
2945
* Methods that accept an action ID will compare the ID against
3046
* this to determine which store will contain that ID. In almost
@@ -56,10 +72,10 @@ public function __construct( Config $config = null ) {
5672
* @codeCoverageIgnore
5773
*/
5874
public function init() {
59-
add_action( 'action_scheduler/created_table', [ $this, 'set_autoincrement' ], 10, 2 );
75+
add_action( 'action_scheduler/created_table', array( $this, 'set_autoincrement' ), 10, 2 );
6076
$this->primary_store->init();
6177
$this->secondary_store->init();
62-
remove_action( 'action_scheduler/created_table', [ $this, 'set_autoincrement' ], 10 );
78+
remove_action( 'action_scheduler/created_table', array( $this, 'set_autoincrement' ), 10 );
6379
}
6480

6581
/**
@@ -78,8 +94,14 @@ public function set_autoincrement( $table_name, $table_suffix ) {
7894
if ( empty( $this->demarkation_id ) ) {
7995
$this->demarkation_id = $this->set_demarkation_id();
8096
}
81-
/** @var \wpdb $wpdb */
97+
98+
/**
99+
* Global.
100+
*
101+
* @var \wpdb $wpdb
102+
*/
82103
global $wpdb;
104+
83105
/**
84106
* A default date of '0000-00-00 00:00:00' is invalid in MySQL 5.7 when configured with
85107
* sql_mode including both STRICT_TRANS_TABLES and NO_ZERO_DATE.
@@ -91,20 +113,20 @@ public function set_autoincrement( $table_name, $table_suffix ) {
91113

92114
$row_count = $wpdb->insert(
93115
$wpdb->{ActionScheduler_StoreSchema::ACTIONS_TABLE},
94-
[
116+
array(
95117
'action_id' => $this->demarkation_id,
96118
'hook' => '',
97119
'status' => '',
98120
'scheduled_date_gmt' => $date_gmt,
99121
'scheduled_date_local' => $date_local,
100122
'last_attempt_gmt' => $date_gmt,
101123
'last_attempt_local' => $date_local,
102-
]
124+
)
103125
);
104126
if ( $row_count > 0 ) {
105127
$wpdb->delete(
106128
$wpdb->{ActionScheduler_StoreSchema::ACTIONS_TABLE},
107-
[ 'action_id' => $this->demarkation_id ]
129+
array( 'action_id' => $this->demarkation_id )
108130
);
109131
}
110132
}
@@ -122,10 +144,15 @@ public function set_autoincrement( $table_name, $table_suffix ) {
122144
*/
123145
private function set_demarkation_id( $id = null ) {
124146
if ( empty( $id ) ) {
125-
/** @var \wpdb $wpdb */
147+
/**
148+
* Global.
149+
*
150+
* @var \wpdb $wpdb
151+
*/
126152
global $wpdb;
153+
127154
$id = (int) $wpdb->get_var( "SELECT MAX(ID) FROM $wpdb->posts" );
128-
$id ++;
155+
$id++;
129156
}
130157
update_option( self::DEMARKATION_OPTION, $id );
131158

@@ -143,10 +170,10 @@ private function set_demarkation_id( $id = null ) {
143170
*
144171
* @return string
145172
*/
146-
public function find_action( $hook, $params = [] ) {
173+
public function find_action( $hook, $params = array() ) {
147174
$found_unmigrated_action = $this->secondary_store->find_action( $hook, $params );
148175
if ( ! empty( $found_unmigrated_action ) ) {
149-
$this->migrate( [ $found_unmigrated_action ] );
176+
$this->migrate( array( $found_unmigrated_action ) );
150177
}
151178

152179
return $this->primary_store->find_action( $hook, $params );
@@ -162,7 +189,7 @@ public function find_action( $hook, $params = [] ) {
162189
*
163190
* @return int[]
164191
*/
165-
public function query_actions( $query = [], $query_type = 'select' ) {
192+
public function query_actions( $query = array(), $query_type = 'select' ) {
166193
$found_unmigrated_actions = $this->secondary_store->query_actions( $query, 'select' );
167194
if ( ! empty( $found_unmigrated_actions ) ) {
168195
$this->migrate( $found_unmigrated_actions );
@@ -357,19 +384,19 @@ public function get_status( $action_id ) {
357384
*/
358385
protected function get_store_from_action_id( $action_id, $primary_first = false ) {
359386
if ( $primary_first ) {
360-
$stores = [
387+
$stores = array(
361388
$this->primary_store,
362389
$this->secondary_store,
363-
];
390+
);
364391
} elseif ( $action_id < $this->demarkation_id ) {
365-
$stores = [
392+
$stores = array(
366393
$this->secondary_store,
367394
$this->primary_store,
368-
];
395+
);
369396
} else {
370-
$stores = [
397+
$stores = array(
371398
$this->primary_store,
372-
];
399+
);
373400
}
374401

375402
foreach ( $stores as $store ) {

classes/data-stores/ActionScheduler_wpPostStore_PostStatusRegistrar.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
/**
44
* Class ActionScheduler_wpPostStore_PostStatusRegistrar
5+
*
56
* @codeCoverageIgnore
67
*/
78
class ActionScheduler_wpPostStore_PostStatusRegistrar {

phpcs.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
</rule>
5050

5151
<rule ref="PEAR.NamingConventions.ValidClassName">
52+
<exclude-pattern>tests/phpunit/logging/ActionScheduler_wpCommentLogger_Test.php</exclude-pattern>
53+
<exclude-pattern>classes/data-stores/ActionScheduler_wpPostStore_PostStatusRegistrar.php</exclude-pattern>
5254
<exclude-pattern>classes/data-stores/ActionScheduler_wpPostStore_TaxonomyRegistrar.php</exclude-pattern>
5355
<exclude-pattern>tests/phpunit/jobstore/ActionScheduler_wpPostStore_Test.php</exclude-pattern>
5456
<exclude-pattern>classes/data-stores/ActionScheduler_wpCommentLogger.php</exclude-pattern>

0 commit comments

Comments
 (0)