Queue
Manages one queue row per attachment and its files.
Namespace: WebberZone\Image_Optimizer
Since: 1.0.0
Source: includes/class-queue.php line 19
Methods
add() static
Add attachments, resetting existing rows only when forced.
Since: 1.0.0
Line: 79
static public function add( array $attachment_ids, bool $force = ... ): int;
| Type | Name | Description |
|---|---|---|
array |
$attachment_ids |
|
bool |
$force |
Whether to requeue rows that already finished. |
Returns: int — Number of rows written.
claim() static
Claim the next batch of pending rows.
Since: 1.0.0
Line: 123
static public function claim( int $limit ): array;
| Type | Name | Description |
|---|---|---|
int |
$limit |
Maximum rows to claim. |
Returns: array — object> Claimed rows.
get_status() static
Get the current status of an attachment’s row.
Since: 1.0.0
Line: 182
static public function get_status( int $attachment_id ): string;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
Returns: string — Status, or an empty string when there is no row.
get_id() static
Get the row ID for an attachment.
Since: 1.0.0
Line: 205
static public function get_id( int $attachment_id ): int;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
Returns: int — Row ID, or 0 when there is no row.
claim_attachment() static
Claim the pending row for one specific attachment, bypassing queue order.
Since: 1.0.0
Line: 226
static public function claim_attachment( int $attachment_id ): object|null;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
Returns: object|null — Claimed row, or null when nothing was pending for it.
complete() static
Record the outcome of a claimed row.
Since: 1.0.0
Line: 278
static public function complete( int $id, string $status, int $saved = ..., string $error = ..., int $source = ... ): void;
| Type | Name | Description |
|---|---|---|
int |
$id |
Queue row ID. |
string |
$status |
New status. |
int |
$saved |
Bytes saved. |
string |
$error |
Error message, if any. |
int |
$source |
Total source bytes considered. |
Returns: void
release_stale() static
Requeue stale claims left by terminated workers.
Since: 1.0.0
Line: 337
static public function release_stale( int $older_than_seconds = ... ): int;
| Type | Name | Description |
|---|---|---|
int |
$older_than_seconds |
Age in seconds after which a claim is stale. |
Returns: int — Rows released.
get_counts() static
Count the rows in each status.
Since: 1.0.0
Line: 372
static public function get_counts( ): array;
Returns: array — int> Status to count, plus a total key.
flush_counts() static
Discard the cached status counts.
Since: 1.0.0
Line: 427
static public function flush_counts( ): void;
Returns: void
has_pending() static
Whether any row is waiting to be processed.
Since: 1.0.0
Line: 438
static public function has_pending( ): bool;
Returns: bool — True when work remains.
remove() static
Remove rows for a single attachment.
Since: 1.0.0
Line: 452
static public function remove( int $attachment_id ): void;
| Type | Name | Description |
|---|---|---|
int |
$attachment_id |
Attachment ID. |
Returns: void
clear() static
Empty the queue.
Since: 1.0.0
Line: 472
static public function clear( ): void;
Returns: void
clear_pending() static
Remove pending claims while retaining completed totals.
Since: 1.0.0
Line: 494
static public function clear_pending( ): void;
Returns: void
get_failures() static
Get the most recent failures.
Since: 1.0.0
Line: 519
static public function get_failures( int $limit = ... ): array;
| Type | Name | Description |
|---|---|---|
int |
$limit |
Maximum rows to return. |
Returns: array — object> Failed rows.