plugin updates
This commit is contained in:
@@ -77,7 +77,7 @@ class ActionScheduler_DBStore extends ActionScheduler_Store {
|
||||
* @param bool $unique Whether the action should be unique.
|
||||
*
|
||||
* @return int Action ID.
|
||||
* @throws RuntimeException Throws exception when saving the action fails.
|
||||
* @throws \RuntimeException Throws exception when saving the action fails.
|
||||
*/
|
||||
private function save_action_to_db( ActionScheduler_Action $action, DateTime $date = null, $unique = false ) {
|
||||
global $wpdb;
|
||||
@@ -388,7 +388,8 @@ AND `group_id` = %d
|
||||
* @param string $select_or_count Whether the SQL should select and return the IDs or just the row count.
|
||||
*
|
||||
* @return string SQL statement already properly escaped.
|
||||
* @throws InvalidArgumentException If the query is invalid.
|
||||
* @throws \InvalidArgumentException If the query is invalid.
|
||||
* @throws \RuntimeException When "unknown partial args matching value".
|
||||
*/
|
||||
protected function get_query_actions_sql( array $query, $select_or_count = 'select' ) {
|
||||
|
||||
@@ -399,7 +400,7 @@ AND `group_id` = %d
|
||||
$query = wp_parse_args( $query, array(
|
||||
'hook' => '',
|
||||
'args' => null,
|
||||
'partial_args_matching' => 'off', // can be 'like' or 'json'
|
||||
'partial_args_matching' => 'off', // can be 'like' or 'json'.
|
||||
'date' => null,
|
||||
'date_compare' => '<=',
|
||||
'modified' => null,
|
||||
@@ -435,15 +436,15 @@ AND `group_id` = %d
|
||||
$sql .= " LEFT JOIN {$wpdb->actionscheduler_groups} g ON g.group_id=a.group_id";
|
||||
}
|
||||
|
||||
$sql .= " WHERE 1=1";
|
||||
$sql .= ' WHERE 1=1';
|
||||
|
||||
if ( ! empty( $query['group'] ) ) {
|
||||
$sql .= " AND g.slug=%s";
|
||||
$sql .= ' AND g.slug=%s';
|
||||
$sql_params[] = $query['group'];
|
||||
}
|
||||
|
||||
if ( ! empty( $query['hook'] ) ) {
|
||||
$sql .= " AND a.hook=%s";
|
||||
$sql .= ' AND a.hook=%s';
|
||||
$sql_params[] = $query['hook'];
|
||||
}
|
||||
|
||||
@@ -472,8 +473,8 @@ AND `group_id` = %d
|
||||
$value_type
|
||||
) );
|
||||
}
|
||||
$sql .= ' AND JSON_EXTRACT(a.args, %s)='.$placeholder;
|
||||
$sql_params[] = '$.'.$key;
|
||||
$sql .= ' AND JSON_EXTRACT(a.args, %s)=' . $placeholder;
|
||||
$sql_params[] = '$.' . $key;
|
||||
$sql_params[] = $value;
|
||||
}
|
||||
break;
|
||||
@@ -485,7 +486,7 @@ AND `group_id` = %d
|
||||
}
|
||||
break;
|
||||
case 'off':
|
||||
$sql .= " AND a.args=%s";
|
||||
$sql .= ' AND a.args=%s';
|
||||
$sql_params[] = $this->get_args_for_query( $query['args'] );
|
||||
break;
|
||||
default:
|
||||
@@ -823,7 +824,7 @@ AND `group_id` = %d
|
||||
* Set a claim filter.
|
||||
*
|
||||
* @param string $filter_name Claim filter name.
|
||||
* @param mixed $filter_values Values to filter.
|
||||
* @param mixed $filter_values Values to filter.
|
||||
* @return void
|
||||
*/
|
||||
public function set_claim_filter( $filter_name, $filter_values ) {
|
||||
@@ -1017,6 +1018,7 @@ AND `group_id` = %d
|
||||
* Release actions from a claim and delete the claim.
|
||||
*
|
||||
* @param ActionScheduler_ActionClaim $claim Claim object.
|
||||
* @throws \RuntimeException When unable to release actions from claim.
|
||||
*/
|
||||
public function release_claim( ActionScheduler_ActionClaim $claim ) {
|
||||
/** @var \wpdb $wpdb */
|
||||
|
||||
@@ -15,8 +15,11 @@ use Action_Scheduler\Migration\Controller;
|
||||
class ActionScheduler_HybridStore extends Store {
|
||||
const DEMARKATION_OPTION = 'action_scheduler_hybrid_store_demarkation';
|
||||
|
||||
/** @var ActionScheduler_Store */
|
||||
private $primary_store;
|
||||
/** @var ActionScheduler_Store */
|
||||
private $secondary_store;
|
||||
/** @var Action_Scheduler\Migration\Runner */
|
||||
private $migration_runner;
|
||||
|
||||
/**
|
||||
@@ -64,8 +67,8 @@ class ActionScheduler_HybridStore extends Store {
|
||||
* value to be one higher than the posts table to ensure that
|
||||
* there are no ID collisions.
|
||||
*
|
||||
* @param string $table_name
|
||||
* @param string $table_suffix
|
||||
* @param string $table_name Table name.
|
||||
* @param string $table_suffix Suffix of table name.
|
||||
*
|
||||
* @return void
|
||||
* @codeCoverageIgnore
|
||||
@@ -78,7 +81,7 @@ class ActionScheduler_HybridStore extends Store {
|
||||
/** @var \wpdb $wpdb */
|
||||
global $wpdb;
|
||||
/**
|
||||
* A default date of '0000-00-00 00:00:00' is invalid in MySQL 5.7 when configured with
|
||||
* A default date of '0000-00-00 00:00:00' is invalid in MySQL 5.7 when configured with
|
||||
* sql_mode including both STRICT_TRANS_TABLES and NO_ZERO_DATE.
|
||||
*/
|
||||
$default_date = new DateTime( 'tomorrow' );
|
||||
@@ -135,8 +138,8 @@ class ActionScheduler_HybridStore extends Store {
|
||||
* After it migrates, the secondary store will logically contain
|
||||
* the next matching action, so return the result thence.
|
||||
*
|
||||
* @param string $hook
|
||||
* @param array $params
|
||||
* @param string $hook Action's hook.
|
||||
* @param array $params Action's arguments.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -154,7 +157,7 @@ class ActionScheduler_HybridStore extends Store {
|
||||
* If any are found, migrate them immediately. Then the secondary
|
||||
* store will contain the canonical results.
|
||||
*
|
||||
* @param array $query
|
||||
* @param array $query Query arguments.
|
||||
* @param string $query_type Whether to select or count the results. Default, select.
|
||||
*
|
||||
* @return int[]
|
||||
@@ -203,8 +206,10 @@ class ActionScheduler_HybridStore extends Store {
|
||||
* migrate them immediately, then ask the primary store for the
|
||||
* canonical claim.
|
||||
*
|
||||
* @param int $max_actions
|
||||
* @param DateTime|null $before_date
|
||||
* @param int $max_actions Maximum number of actions to claim.
|
||||
* @param null|DateTime $before_date Latest timestamp of actions to claim.
|
||||
* @param string[] $hooks Hook of actions to claim.
|
||||
* @param string $group Group of actions to claim.
|
||||
*
|
||||
* @return ActionScheduler_ActionClaim
|
||||
*/
|
||||
@@ -376,10 +381,12 @@ class ActionScheduler_HybridStore extends Store {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
/**
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* All claim-related functions should operate solely
|
||||
* on the primary store.
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the claim count from the table data store.
|
||||
|
||||
@@ -8,9 +8,11 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
const TYPE = 'action_log';
|
||||
|
||||
/**
|
||||
* @param string $action_id
|
||||
* @param string $message
|
||||
* @param DateTime $date
|
||||
* Create log entry.
|
||||
*
|
||||
* @param string $action_id Action ID.
|
||||
* @param string $message Action log's message.
|
||||
* @param DateTime $date Action log's timestamp.
|
||||
*
|
||||
* @return string The log entry ID
|
||||
*/
|
||||
@@ -24,6 +26,13 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
return $comment_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create comment.
|
||||
*
|
||||
* @param int $action_id Action ID.
|
||||
* @param string $message Action log's message.
|
||||
* @param DateTime $date Action log entry's timestamp.
|
||||
*/
|
||||
protected function create_wp_comment( $action_id, $message, DateTime $date ) {
|
||||
|
||||
$comment_date_gmt = $date->format('Y-m-d H:i:s');
|
||||
@@ -41,7 +50,9 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $entry_id
|
||||
* Get single log entry for action.
|
||||
*
|
||||
* @param string $entry_id Entry ID.
|
||||
*
|
||||
* @return ActionScheduler_LogEntry
|
||||
*/
|
||||
@@ -57,7 +68,9 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $action_id
|
||||
* Get action's logs.
|
||||
*
|
||||
* @param string $action_id Action ID.
|
||||
*
|
||||
* @return ActionScheduler_LogEntry[]
|
||||
*/
|
||||
@@ -83,6 +96,11 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
return $logs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment.
|
||||
*
|
||||
* @param int $comment_id Comment ID.
|
||||
*/
|
||||
protected function get_comment( $comment_id ) {
|
||||
return get_comment( $comment_id );
|
||||
}
|
||||
@@ -90,12 +108,14 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
|
||||
|
||||
/**
|
||||
* @param WP_Comment_Query $query
|
||||
* Filter comment queries.
|
||||
*
|
||||
* @param WP_Comment_Query $query Comment query object.
|
||||
*/
|
||||
public function filter_comment_queries( $query ) {
|
||||
foreach ( array('ID', 'parent', 'post_author', 'post_name', 'post_parent', 'type', 'post_type', 'post_id', 'post_ID') as $key ) {
|
||||
if ( !empty($query->query_vars[$key]) ) {
|
||||
return; // don't slow down queries that wouldn't include action_log comments anyway
|
||||
return; // don't slow down queries that wouldn't include action_log comments anyway.
|
||||
}
|
||||
}
|
||||
$query->query_vars['action_log_filter'] = TRUE;
|
||||
@@ -103,8 +123,10 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $clauses
|
||||
* @param WP_Comment_Query $query
|
||||
* Filter comment queries.
|
||||
*
|
||||
* @param array $clauses Query's clauses.
|
||||
* @param WP_Comment_Query $query Query object.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -119,8 +141,8 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
* Make sure Action Scheduler logs are excluded from comment feeds, which use WP_Query, not
|
||||
* the WP_Comment_Query class handled by @see self::filter_comment_queries().
|
||||
*
|
||||
* @param string $where
|
||||
* @param WP_Query $query
|
||||
* @param string $where Query's `where` clause.
|
||||
* @param WP_Query $query Query object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -144,8 +166,8 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
/**
|
||||
* Remove action log entries from wp_count_comments()
|
||||
*
|
||||
* @param array $stats
|
||||
* @param int $post_id
|
||||
* @param array $stats Comment count.
|
||||
* @param int $post_id Post ID.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
@@ -179,7 +201,7 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
$approved = array( '0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed' );
|
||||
|
||||
foreach ( (array) $count as $row ) {
|
||||
// Don't count post-trashed toward totals
|
||||
// Don't count post-trashed toward totals.
|
||||
if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
|
||||
$total += $row['num_comments'];
|
||||
}
|
||||
@@ -213,6 +235,8 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function init() {
|
||||
@@ -222,17 +246,24 @@ class ActionScheduler_wpCommentLogger extends ActionScheduler_Logger {
|
||||
parent::init();
|
||||
|
||||
add_action( 'pre_get_comments', array( $this, 'filter_comment_queries' ), 10, 1 );
|
||||
add_action( 'wp_count_comments', array( $this, 'filter_comment_count' ), 20, 2 ); // run after WC_Comments::wp_count_comments() to make sure we exclude order notes and action logs
|
||||
add_action( 'wp_count_comments', array( $this, 'filter_comment_count' ), 20, 2 ); // run after WC_Comments::wp_count_comments() to make sure we exclude order notes and action logs.
|
||||
add_action( 'comment_feed_where', array( $this, 'filter_comment_feed' ), 10, 2 );
|
||||
|
||||
// Delete comments count cache whenever there is a new comment or a comment status changes
|
||||
// Delete comments count cache whenever there is a new comment or a comment status changes.
|
||||
add_action( 'wp_insert_comment', array( $this, 'delete_comment_count_cache' ) );
|
||||
add_action( 'wp_set_comment_status', array( $this, 'delete_comment_count_cache' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Defer comment counting.
|
||||
*/
|
||||
public function disable_comment_counting() {
|
||||
wp_defer_comment_counting(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable comment counting.
|
||||
*/
|
||||
public function enable_comment_counting() {
|
||||
wp_defer_comment_counting(false);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ActionScheduler_wpPostStore_PostStatusRegistrar {
|
||||
|
||||
/**
|
||||
* Registrar.
|
||||
*/
|
||||
public function register() {
|
||||
register_post_status( ActionScheduler_Store::STATUS_RUNNING, array_merge( $this->post_status_args(), $this->post_status_running_labels() ) );
|
||||
register_post_status( ActionScheduler_Store::STATUS_FAILED, array_merge( $this->post_status_args(), $this->post_status_failed_labels() ) );
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ActionScheduler_wpPostStore_PostTypeRegistrar {
|
||||
/**
|
||||
* Registrar.
|
||||
*/
|
||||
public function register() {
|
||||
register_post_type( ActionScheduler_wpPostStore::POST_TYPE, $this->post_type_args() );
|
||||
}
|
||||
@@ -47,4 +50,3 @@ class ActionScheduler_wpPostStore_PostTypeRegistrar {
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,17 @@
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ActionScheduler_wpPostStore_TaxonomyRegistrar {
|
||||
|
||||
/**
|
||||
* Registrar.
|
||||
*/
|
||||
public function register() {
|
||||
register_taxonomy( ActionScheduler_wpPostStore::GROUP_TAXONOMY, ActionScheduler_wpPostStore::POST_TYPE, $this->taxonomy_args() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get taxonomy arguments.
|
||||
*/
|
||||
protected function taxonomy_args() {
|
||||
$args = array(
|
||||
'label' => __( 'Action Group', 'woocommerce' ),
|
||||
@@ -23,4 +30,3 @@ class ActionScheduler_wpPostStore_TaxonomyRegistrar {
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user