ActionScheduler_ActionClaim
Represents a claim on a set of action IDs. Claims are used by the queue runner and data stores to lock a batch of pending actions for processing, preventing other processes from running them simultaneously.
Source: classes/ActionScheduler_ActionClaim.php
Properties
private string $id = ''
The claim identifier. In the DB store this corresponds to the claim_id primary key in the actionscheduler_claims table.
private int[] $action_ids = array()
List of action IDs included in the claim.
Constructor
__construct( string $id, array $action_ids )
Creates a claim instance.
$id— Claim ID.$action_ids— Array of action IDs included in the claim.
Methods
public function get_id()
Returns the claim ID.
public function get_actions()
Returns the array of claimed action IDs.
Claim Workflow (DB Store)
ActionScheduler_Store::stake_claim() is implemented by the DB store to claim a batch of actions:
Generate claim ID
ActionScheduler_DBStore::generate_claim_id()inserts a row into theactionscheduler_claimstable and returns the new ID.
Select and claim actions
ActionScheduler_DBStore::claim_actions()selects pending actions (status = pending) withclaim_id = 0andscheduled_date_gmt <= now.- Optional filters include
hooksandgroup. - Actions are ordered by
priority ASC, attempts ASC, scheduled_date_gmt ASC, action_id ASC(filterable viaaction_scheduler_claim_actions_order_by). - The DB store uses
SELECT ... FOR UPDATEand, when supported,SKIP LOCKEDto avoid deadlocks. - The matched rows are updated to set
claim_idand update attempt timestamps.
Resolve claimed IDs
ActionScheduler_DBStore::find_actions_by_claim_id()fetches the list of action IDs in the claim, validating each scheduled date against the original cut-off time.
Return a claim object
stake_claim()returns anActionScheduler_ActionClaimcontaining the claim ID and action IDs.
Releasing Claims
Generate claim ID
Select and claim actions
ActionScheduler_DBStore::generate_claim_id()inserts a row into theactionscheduler_claimstable and returns the new ID.
Related Store APIs
Resolve claimed IDs
ActionScheduler_DBStore::claim_actions()selects pending actions (status = pending) withclaim_id = 0andscheduled_date_gmt <= now.- Optional filters include
hooksandgroup. - Actions are ordered by
priority ASC, attempts ASC, scheduled_date_gmt ASC, action_id ASC(filterable viaaction_scheduler_claim_actions_order_by). - The DB store uses
SELECT ... FOR UPDATEand, when supported,SKIP LOCKEDto avoid deadlocks. - The matched rows are updated to set
claim_idand update attempt timestamps.
Usage Notes
Return a claim object