| Server IP : 108.167.142.43 / Your IP : 216.73.217.58 Web Server : Apache System : Linux gator4174.hostgator.com 5.14.0-687.39.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Aug 18 06:09:16 EDT 2026 x86_64 User : delarice ( 2406) PHP Version : 8.3.36 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home2/delarice/www/wp-content/plugins/templately/modules/mcp-server/Cleanup/ |
Upload File : |
<?php
/**
* Reclaim expired delegated-approval records.
*
* @package Templately
*/
namespace Templately\Modules\McpServer\Cleanup;
use Templately\Modules\McpServer\Auth\OAuth\RecordStore;
use Templately\Modules\Utilities\Cleanup\CleanupTask;
use Templately\Modules\Utilities\Cleanup\Context;
use Templately\Modules\Utilities\Cleanup\RetentionKind;
use Templately\Modules\Utilities\Cleanup\TaskRegistry;
use Templately\Modules\Utilities\Cleanup\TaskResult;
/**
* This module used to run its OWN daily WP-Cron sweep
* (`templately_mcp_oauth_sweep`). It now contributes to the one shared sweep
* instead — two cleaners on separate cadences with no shared run claim is
* exactly what spec 052 exists to end.
*
* INTRINSIC retention, not age: each record carries its own `expires_at`, and
* expiry is enforced on read as well. Applying the shared age window here would
* either be ignored or would reclaim credentials that are still valid.
*
* `RecordStore::sweep()` itself is unchanged and still lives in this module —
* only the scheduling moved.
*/
class OAuthRecordsTask implements CleanupTask {
public static function register(): void {
add_action(
TaskRegistry::COLLECT_ACTION,
static function ( TaskRegistry $registry ) {
$registry->register_classes( [ self::class ] );
}
);
}
public function descriptor(): array {
return [
'id' => 'mcp-oauth-records',
'label' => __( 'Expired agent approvals', 'templately' ),
'group' => 'cache',
'scope' => 'records',
'retention_kind' => RetentionKind::INTRINSIC,
'destructive' => true,
'schedulable' => true,
];
}
public function estimate( Context $context ): TaskResult {
return TaskResult::empty()->add( RecordStore::count_expired(), 0 );
}
public function run( Context $context ): TaskResult {
$expired = RecordStore::count_expired();
if ( $context->is_dry_run() ) {
return TaskResult::empty()->add( $expired, 0 );
}
RecordStore::sweep();
return TaskResult::empty()->add( $expired, 0 );
}
}