plugin updates
This commit is contained in:
@@ -13,21 +13,21 @@ namespace Action_Scheduler\Migration;
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ActionMigrator {
|
||||
/** var ActionScheduler_Store */
|
||||
/** @var ActionScheduler_Store */
|
||||
private $source;
|
||||
|
||||
/** var ActionScheduler_Store */
|
||||
/** @var ActionScheduler_Store */
|
||||
private $destination;
|
||||
|
||||
/** var LogMigrator */
|
||||
/** @var LogMigrator */
|
||||
private $log_migrator;
|
||||
|
||||
/**
|
||||
* ActionMigrator constructor.
|
||||
*
|
||||
* @param ActionScheduler_Store $source_store Source store object.
|
||||
* @param ActionScheduler_Store $destination_store Destination store object.
|
||||
* @param LogMigrator $log_migrator Log migrator object.
|
||||
* @param \ActionScheduler_Store $source_store Source store object.
|
||||
* @param \ActionScheduler_Store $destination_store Destination store object.
|
||||
* @param LogMigrator $log_migrator Log migrator object.
|
||||
*/
|
||||
public function __construct( \ActionScheduler_Store $source_store, \ActionScheduler_Store $destination_store, LogMigrator $log_migrator ) {
|
||||
$this->source = $source_store;
|
||||
@@ -41,6 +41,7 @@ class ActionMigrator {
|
||||
* @param int $source_action_id Action ID.
|
||||
*
|
||||
* @return int 0|new action ID
|
||||
* @throws \RuntimeException When unable to delete action from the source store.
|
||||
*/
|
||||
public function migrate( $source_action_id ) {
|
||||
try {
|
||||
@@ -52,13 +53,13 @@ class ActionMigrator {
|
||||
}
|
||||
|
||||
if ( is_null( $action ) || empty( $status ) || ! $action->get_schedule()->get_date() ) {
|
||||
// null action or empty status means the fetch operation failed or the action didn't exist
|
||||
// null schedule means it's missing vital data
|
||||
// delete it and move on
|
||||
// null action or empty status means the fetch operation failed or the action didn't exist.
|
||||
// null schedule means it's missing vital data.
|
||||
// delete it and move on.
|
||||
try {
|
||||
$this->source->delete_action( $source_action_id );
|
||||
} catch ( \Exception $e ) {
|
||||
// nothing to do, it didn't exist in the first place
|
||||
// nothing to do, it didn't exist in the first place.
|
||||
}
|
||||
do_action( 'action_scheduler/no_action_to_migrate', $source_action_id, $this->source, $this->destination );
|
||||
|
||||
@@ -67,14 +68,14 @@ class ActionMigrator {
|
||||
|
||||
try {
|
||||
|
||||
// Make sure the last attempt date is set correctly for completed and failed actions
|
||||
// Make sure the last attempt date is set correctly for completed and failed actions.
|
||||
$last_attempt_date = ( $status !== \ActionScheduler_Store::STATUS_PENDING ) ? $this->source->get_date( $source_action_id ) : null;
|
||||
|
||||
$destination_action_id = $this->destination->save_action( $action, null, $last_attempt_date );
|
||||
} catch ( \Exception $e ) {
|
||||
do_action( 'action_scheduler/migrate_action_failed', $source_action_id, $this->source, $this->destination );
|
||||
|
||||
return 0; // could not save the action in the new store
|
||||
return 0; // could not save the action in the new store.
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -99,7 +100,7 @@ class ActionMigrator {
|
||||
|
||||
return $destination_action_id;
|
||||
} catch ( \Exception $e ) {
|
||||
// could not delete from the old store
|
||||
// could not delete from the old store.
|
||||
$this->source->mark_migrated( $source_action_id );
|
||||
do_action( 'action_scheduler/migrate_action_incomplete', $source_action_id, $destination_action_id, $this->source, $this->destination );
|
||||
do_action( 'action_scheduler/migrated_action', $source_action_id, $destination_action_id, $this->source, $this->destination );
|
||||
|
||||
@@ -16,9 +16,9 @@ class ActionScheduler_DBStoreMigrator extends ActionScheduler_DBStore {
|
||||
* it can't have been attempted yet, but migrated completed actions will have an attempted date, so we need to save
|
||||
* that when first saving the action.
|
||||
*
|
||||
* @param ActionScheduler_Action $action
|
||||
* @param \DateTime $scheduled_date Optional date of the first instance to store.
|
||||
* @param \DateTime $last_attempt_date Optional date the action was last attempted.
|
||||
* @param ActionScheduler_Action $action Action to migrate.
|
||||
* @param null|\DateTime $scheduled_date Optional date of the first instance to store.
|
||||
* @param null|\DateTime $last_attempt_date Optional date the action was last attempted.
|
||||
*
|
||||
* @return string The action ID
|
||||
* @throws \RuntimeException When the action is not saved.
|
||||
|
||||
@@ -16,7 +16,7 @@ use ActionScheduler_Store as Store;
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class BatchFetcher {
|
||||
/** var ActionScheduler_Store */
|
||||
/** @var ActionScheduler_Store */
|
||||
private $store;
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ class BatchFetcher {
|
||||
/**
|
||||
* Retrieve a list of actions.
|
||||
*
|
||||
* @param int $count The number of actions to retrieve
|
||||
* @param int $count The number of actions to retrieve.
|
||||
*
|
||||
* @return int[] A list of action IDs
|
||||
*/
|
||||
@@ -69,7 +69,7 @@ class BatchFetcher {
|
||||
Store::STATUS_CANCELED,
|
||||
Store::STATUS_COMPLETE,
|
||||
Store::STATUS_RUNNING,
|
||||
'', // any other unanticipated status
|
||||
'', // any other unanticipated status.
|
||||
];
|
||||
|
||||
foreach ( $priorities as $status ) {
|
||||
@@ -83,4 +83,4 @@ class BatchFetcher {
|
||||
], $args );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ class Config {
|
||||
* Get the configured source store.
|
||||
*
|
||||
* @return ActionScheduler_Store
|
||||
* @throws \RuntimeException When source store is not configured.
|
||||
*/
|
||||
public function get_source_store() {
|
||||
if ( empty( $this->source_store ) ) {
|
||||
@@ -68,6 +69,7 @@ class Config {
|
||||
* Get the configured source logger.
|
||||
*
|
||||
* @return ActionScheduler_Logger
|
||||
* @throws \RuntimeException When source logger is not configured.
|
||||
*/
|
||||
public function get_source_logger() {
|
||||
if ( empty( $this->source_logger ) ) {
|
||||
@@ -80,7 +82,7 @@ class Config {
|
||||
/**
|
||||
* Set the configured source logger.
|
||||
*
|
||||
* @param ActionScheduler_Logger $logger
|
||||
* @param ActionScheduler_Logger $logger Logger object.
|
||||
*/
|
||||
public function set_source_logger( Logger $logger ) {
|
||||
$this->source_logger = $logger;
|
||||
@@ -90,6 +92,7 @@ class Config {
|
||||
* Get the configured destination store.
|
||||
*
|
||||
* @return ActionScheduler_Store
|
||||
* @throws \RuntimeException When destination store is not configured.
|
||||
*/
|
||||
public function get_destination_store() {
|
||||
if ( empty( $this->destination_store ) ) {
|
||||
@@ -102,7 +105,7 @@ class Config {
|
||||
/**
|
||||
* Set the configured destination store.
|
||||
*
|
||||
* @param ActionScheduler_Store $store
|
||||
* @param ActionScheduler_Store $store Action store object.
|
||||
*/
|
||||
public function set_destination_store( Store $store ) {
|
||||
$this->destination_store = $store;
|
||||
@@ -112,6 +115,7 @@ class Config {
|
||||
* Get the configured destination logger.
|
||||
*
|
||||
* @return ActionScheduler_Logger
|
||||
* @throws \RuntimeException When destination logger is not configured.
|
||||
*/
|
||||
public function get_destination_logger() {
|
||||
if ( empty( $this->destination_logger ) ) {
|
||||
@@ -124,7 +128,7 @@ class Config {
|
||||
/**
|
||||
* Set the configured destination logger.
|
||||
*
|
||||
* @param ActionScheduler_Logger $logger
|
||||
* @param ActionScheduler_Logger $logger Logger object.
|
||||
*/
|
||||
public function set_destination_logger( Logger $logger ) {
|
||||
$this->destination_logger = $logger;
|
||||
@@ -142,7 +146,7 @@ class Config {
|
||||
/**
|
||||
* Set flag indicating whether it's a dry run.
|
||||
*
|
||||
* @param bool $dry_run
|
||||
* @param bool $dry_run Dry run toggle.
|
||||
*/
|
||||
public function set_dry_run( $dry_run ) {
|
||||
$this->dry_run = (bool) $dry_run;
|
||||
@@ -160,7 +164,7 @@ class Config {
|
||||
/**
|
||||
* Set progress bar object.
|
||||
*
|
||||
* @param ActionScheduler\WPCLI\ProgressBar $progress_bar
|
||||
* @param ActionScheduler\WPCLI\ProgressBar $progress_bar Progress bar object.
|
||||
*/
|
||||
public function set_progress_bar( ProgressBar $progress_bar ) {
|
||||
$this->progress_bar = $progress_bar;
|
||||
|
||||
@@ -19,6 +19,7 @@ use Action_Scheduler\WP_CLI\ProgressBar;
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Controller {
|
||||
/** @var self */
|
||||
private static $instance;
|
||||
|
||||
/** @var Action_Scheduler\Migration\Scheduler */
|
||||
@@ -171,7 +172,7 @@ class Controller {
|
||||
add_action( 'init', array( $this, 'maybe_hook_migration' ) );
|
||||
add_action( 'wp_loaded', array( $this, 'schedule_migration' ) );
|
||||
|
||||
// Action Scheduler may be displayed as a Tools screen or WooCommerce > Status administration screen
|
||||
// Action Scheduler may be displayed as a Tools screen or WooCommerce > Status administration screen.
|
||||
add_action( 'load-tools_page_action-scheduler', array( $this, 'hook_admin_notices' ), 10, 0 );
|
||||
add_action( 'load-woocommerce_page_wc-status', array( $this, 'hook_admin_notices' ), 10, 0 );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,6 @@ class DryRun_LogMigrator extends LogMigrator {
|
||||
* @param int $destination_action_id Destination logger object.
|
||||
*/
|
||||
public function migrate( $source_action_id, $destination_action_id ) {
|
||||
// no-op
|
||||
// no-op.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user