STATUS_COMPLETE
STATUS_COMPLETE = 'complete'
Class ActionScheduler_DBStoreMigrator
A class for direct saving of actions to the table data store during migration.
$max_args_length : int
Maximum length of args.
$max_index_length : int
Maximum length of index.
$claim_filters : array
List of claim filters.
$claim_before_date : \DateTime|null
Used to share information about the before_date property of claims internally.
This is used in preference to passing the same information as a method param for backwards-compatibility reasons.
$store : \ActionScheduler_Store
ActionScheduler_Store instance.
save_unique_action(\ActionScheduler_Action $action, \DateTime|null $scheduled_date = null) : int
Save an action, checks if this is a unique action before actually saving.
\ActionScheduler_Action | $action | Action object. |
\DateTime|null | $scheduled_date | Optional schedule date. Default null. |
Throws exception when saving the action fails.
Action ID.
save_action(\ActionScheduler_Action $action, null|\DateTime $scheduled_date = null, null|\DateTime $last_attempt_date = null) : string
Save an action with optional last attempt date.
Normally, saving an action sets its attempted date to 0000-00-00 00:00:00 because when an action is first saved, 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.
\ActionScheduler_Action | $action | Action to migrate. |
null|\DateTime | $scheduled_date | Optional date of the first instance to store. |
null|\DateTime | $last_attempt_date | Optional date the action was last attempted. |
When the action is not saved.
The action ID
query_actions(array $query = array(), string $query_type = 'select') : string|array|null
Query for action count or list of action IDs.
array | $query | { Query filtering options.
} |
string | $query_type | Whether to select or count the results. Default, select. |
The IDs of actions matching the query. Null on failure.
stake_claim(int $max_actions = 10, \DateTime|null $before_date = null, array $hooks = array(), string $group = '') : \ActionScheduler_ActionClaim
Make a claim.
int | $max_actions | Maximum number of actions to claim. |
\DateTime|null | $before_date | Claim only actions schedule before the given date. Defaults to now. |
array | $hooks | Claim only actions with a hook or hooks. |
string | $group | Claim only actions in the given group. |
find_action(string $hook, array $params = array()) : string|null
Find an action.
Note: the query ordering changes based on the passed 'status' value.
string | $hook | Action hook. |
array | $params | Parameters of the action to find. |
ID of the next action matching the criteria or NULL if not found.
get_group_ids(string|array $slugs, bool $create_if_not_exists = true) : array
Get a group's ID based on its name/slug.
string|array | $slugs | The string name of a group, or names for several groups. |
bool | $create_if_not_exists | Whether to create the group if it does not already exist. Default, true - create the group. |
The group IDs, if they exist or were successfully created. May be empty.
make_action_from_db_record(object $data) : \ActionScheduler_Action|\ActionScheduler_CanceledAction|\ActionScheduler_FinishedAction
Create an action from a database record.
object | $data | Action database record. |
get_query_actions_sql(array $query, string $select_or_count = 'select') : string
Returns the SQL statement to query (or count) actions.
array | $query | Filtering options. |
string | $select_or_count | Whether the SQL should select and return the IDs or just the row count. |
If the query is invalid.
When "unknown partial args matching value".
SQL statement already properly escaped.
claim_actions(string $claim_id, int $limit, \DateTime|null $before_date = null, array $hooks = array(), string $group = '') : int
Mark actions claimed.
string | $claim_id | Claim Id. |
int | $limit | Number of action to include in claim. |
\DateTime|null | $before_date | Should use UTC timezone. |
array | $hooks | Hooks to filter for. |
string | $group | Group to filter for. |
Throws InvalidArgumentException if group doesn't exist.
Throws RuntimeException if unable to claim action.
The number of actions that were claimed.
get_scheduled_date_string(\ActionScheduler_Action $action, null|\DateTime $scheduled_date = null) : string
Get the time MySQL formatted date/time string for an action's (next) scheduled date.
\ActionScheduler_Action | $action | Action. |
null|\DateTime | $scheduled_date | Action's schedule date (optional). |
get_scheduled_date_string_local(\ActionScheduler_Action|null $action, null|\DateTime $scheduled_date = null) : string
Get the time MySQL formatted date/time string for an action's (next) scheduled date.
\ActionScheduler_Action|null | $action | Action. |
null|\DateTime | $scheduled_date | Action's scheduled date (optional). |
validate_schedule(mixed $schedule, int $action_id) : mixed
Validate a ActionScheduler_Schedule object.
mixed | $schedule | The unserialized ActionScheduler_Schedule object. |
int | $action_id | The action ID. |
When the schedule is invalid.
validate_action(\ActionScheduler_Action $action) : mixed
InnoDB indexes have a maximum size of 767 bytes by default, which is only 191 characters with utf8mb4.
Previously, AS wasn't concerned about args length, as we used the (unindex) post_content column. However, with custom tables, we use an indexed VARCHAR column instead.
\ActionScheduler_Action | $action | Action to be validated. |
When json encoded args is too long.
save_action_to_db(\ActionScheduler_Action $action, ?\DateTime $date = null, bool $unique = false) : int
Save an action.
\ActionScheduler_Action | $action | Action object. |
?\DateTime | $date | Optional schedule date. Default null. |
bool | $unique | Whether the action should be unique. |
Throws exception when saving the action fails.
Action ID.
None found |
build_insert_sql(array $data, bool $unique) : string
Helper function to build insert query.
array | $data | Row data for action. |
bool | $unique | Whether the action should be unique. |
Insert query.
None found |
build_where_clause_for_insert(array $data, string $table_name, bool $unique) : string
Helper method to build where clause for action insert statement.
array | $data | Row data for action. |
string | $table_name | Action table name. |
bool | $unique | Where action should be unique. |
Where clause to be used with insert.
None found |
get_placeholder_for_column(string $column_name) : string
Helper method to get $wpdb->prepare placeholder for a given column name.
string | $column_name | Name of column in actions table. |
Placeholder to use for given column.
None found |
bulk_cancel_actions(int[] $action_ids) : void
Cancel a set of action IDs.
int[] | $action_ids | List of action IDs. |
since | 3.0.0 |
---|