includes/Database/class-database-cleanup-runner.php
Database cleanup application runner.
Class Database_Cleanup_Runner
Class Database_Cleanup_Runner
final class Database_Cleanup_RunnerConstants
| Constant | Visibility | Value | Line |
|---|---|---|---|
SOURCE_REST | public | \'rest\' | 38 |
SOURCE_ABILITY | public | \'ability\' | 46 |
SOURCE_CLI | public | \'cli\' | 54 |
LEGACY_ALIASES | private | array( \'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(): arrayGet the canonical cleanup types accepted by application adapters.
Return: string[] — Canonical cleanup types, including Action Scheduler and all.
publicstatic preview()
public static function preview(string $type): arrayPreview the rows a CLI cleanup request would remove. Parameter Type Default Description $typestring— Requested cleanup type.
Return: array{would_delete:array<string,int>}.
publicstatic run()
public static function run(string $type, string=self::SOURCE_ABILITY $source): arrayRun one bounded cleanup request through the domain owner. Parameter Type Default Description $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 }.
privatestatic canonical_type()
private static function canonical_type(string $type, string $source): stringResolve a canonical cleanup type for the requesting adapter. Parameter Type Default Description $typestring— Requested cleanup type. $sourcestring— One of the SOURCE_* constants.
Return: string — Canonical type, or an empty string when invalid.
privatestatic empty_result()
private static function empty_result(string $type): arrayBuild the stable invalid-type result. Parameter Type Default Description $typestring— Requested cleanup type.
Return: array<string,mixed>.
privatestatic completed_result()
private static function completed_result(string $type, string $canonical_type, int $deleted, array=array() $results, array=array() $failures): arrayBuild a stable successful or partial result. Parameter Type Default Description $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>.
privatestatic log_result()
private static function log_result(string $type, int $deleted, string $source, bool $all, ?bool=null $action_scheduler_available): voidLog the activity historically emitted by the requesting adapter. Parameter Type Default Description $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.
Hooks
Hooks referenced in includes/Database/class-database-cleanup-runner.php: Hook Type Line Notes wppo_database_cleanup_completedaction 188 @param ×2