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 requeued.
Since: 1.0.0
Line: 83
static public function add( array $attachment_ids, bool $requeue = ..., bool $reencode = ..., bool $outdated = ... ): int;
| Type | Name | Description |
|---|---|---|
array |
$attachment_ids |
|
bool |
$requeue |
Whether to requeue rows that already finished. |
bool |
$reencode |
Whether the next pass should re-encode copies that are already up to date. |
bool |
$outdated |
Whether to re-encode only copies with changed settings. |
Returns: int — Number of rows written.
claim() static
Claim the next batch of pending rows.
Since: 1.0.0
Line: 133
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: 192
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: 215
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: 236
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: 288
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: 349
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.
defer() static
Hand a claimed row back for the next batch without counting an attempt.
Used when the worker yields on its own deadline, which is a deliberate stop rather than a failure, so the row keeps its full retry budget.
Since: 1.1.0
Line: 404
static public function defer( int $id ): void;
| Type | Name | Description |
|---|---|---|
int |
$id |
Queue row ID. |
Returns: void
get_counts() static
Count the rows in each status.
Since: 1.0.0
Line: 434
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: 489
static public function flush_counts( ): void;
Returns: void
has_pending() static
Whether any row is waiting to be processed.
Since: 1.0.0
Line: 500
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: 514
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: 534
static public function clear( ): void;
Returns: void
clear_pending() static
Remove pending claims while retaining completed totals.
Since: 1.0.0
Line: 556
static public function clear_pending( ): void;
Returns: void
count_requeued() static
Count waiting or in-progress rows whose attachment already has a conversion record.
Since: 1.1.2
Line: 580
static public function count_requeued( ): int;
Returns: int — Row count.
get_failed_ids() static
Get the IDs of every attachment whose row failed.
Since: 1.1.2
Line: 610
static public function get_failed_ids( ): array;
Returns: array — int> Attachment IDs.
get_failures() static
Get the most recent failures.
Since: 1.0.0
Line: 633
static public function get_failures( int $limit = ... ): array;
| Type | Name | Description |
|---|---|---|
int |
$limit |
Maximum rows to return. |
Returns: array — object> Failed rows.