class-database-cleanup-runner.php

Database cleanup application runner.

Source includes/Database/class-database-cleanup-runner.php3 min readPart of Performance Optimisation

includes/Database/class-database-cleanup-runner.php

Database cleanup application runner.

Namespace: PerformanceOptimise\\Inc · Lines: 323

Class Database_Cleanup_Runner

Class Database_Cleanup_Runner

Source: includes/Database/class-database-cleanup-runner.php, line 30

final class Database_Cleanup_Runner

Tags: @since NEXT

Constants

ConstantVisibilityValueLine
SOURCE_RESTpublic\'rest\'38
SOURCE_ABILITYpublic\'ability\'46
SOURCE_CLIpublic\'cli\'54
LEGACY_ALIASESprivatearray( \'drafts\' => \'auto_drafts\', \'trash\' => \'trashed_posts\', \'spam\' => \'spam_comments\', \'trashed\' => \'trashed_comments\', \'transients\' => \'expired_transients\', \'orphans\' => \'orphan_postmeta\', \'unattached\' => \'unattached_media\', \'oembed\' => \'oembed_cache\', )65

publicstatic valid_types()

public static function valid_types(): array

Get the canonical cleanup types accepted by application adapters.

Return: string[] — Canonical cleanup types, including Action Scheduler and all.

Tags: @since NEXT

Source: includes/Database/class-database-cleanup-runner.php, line 82

publicstatic preview()

public static function preview(string $type): array

Preview the rows a CLI cleanup request would remove.

ParameterTypeDefaultDescription
$typestring—Requested cleanup type.

Return: array{would_delete:array<string,int>}.

Tags: @since NEXT

Source: includes/Database/class-database-cleanup-runner.php, line 97

publicstatic run()

public static function run(string $type, string=self::SOURCE_ABILITY $source): array

Run one bounded cleanup request through the domain owner.

ParameterTypeDefaultDescription
$typestring—Requested cleanup type.
$sourcestring=self::SOURCE_ABILITY—One of the SOURCE_* constants.

Return: array{ — valid:bool, requested_type:string, type:string, canonical_type:string, result:int|WP_Error|null, results:array<string,int|WP_Error>, deleted:int, failures:array<string,WP_Error>, action_scheduler_available:bool|null }.

Tags: @since NEXT

Source: includes/Database/class-database-cleanup-runner.php, line 131

privatestatic canonical_type()

private static function canonical_type(string $type, string $source): string

Resolve a canonical cleanup type for the requesting adapter.

ParameterTypeDefaultDescription
$typestring—Requested cleanup type.
$sourcestring—One of the SOURCE_* constants.

Return: string — Canonical type, or an empty string when invalid.

Tags: @since NEXT

Source: includes/Database/class-database-cleanup-runner.php, line 208

privatestatic empty_result()

private static function empty_result(string $type): array

Build the stable invalid-type result.

ParameterTypeDefaultDescription
$typestring—Requested cleanup type.

Return: array<string,mixed>.

Tags: @since NEXT

Source: includes/Database/class-database-cleanup-runner.php, line 222

privatestatic completed_result()

private static function completed_result(string $type, string $canonical_type, int $deleted, array=array() $results, array=array() $failures): array

Build a stable successful or partial result.

ParameterTypeDefaultDescription
$typestring—Requested cleanup type.
$canonical_typestring—Canonical cleanup type.
$deletedint—Total rows deleted.
$resultsarray=array()—Per-type results.
$failuresarray=array()—Per-type failures.

Return: array<string,mixed>.

Tags: @since NEXT

Source: includes/Database/class-database-cleanup-runner.php, line 247

privatestatic log_result()

private static function log_result(string $type, int $deleted, string $source, bool $all, ?bool=null $action_scheduler_available): void

Log the activity historically emitted by the requesting adapter.

ParameterTypeDefaultDescription
$typestring—Requested cleanup type.
$deletedint—Total rows deleted.
$sourcestring—One of the SOURCE_* constants.
$allbool—Whether this is the all-types branch.
$action_scheduler_available?bool=null—Action Scheduler availability.

Return: void.

Tags: @since NEXT

Source: includes/Database/class-database-cleanup-runner.php, line 272

Hooks

Hooks referenced in includes/Database/class-database-cleanup-runner.php:

HookTypeLineNotes
wppo_database_cleanup_completedaction188@param ×2