Files
WP-LIT-MCP/src/ChangeLog/ChangeLogCleanup.php
T
janniclas.loosenandClaude Opus 5.5 b24eb6c3e9 fix(security): no direct HTTP access to plugin PHP files (audit L2, cheap part)
Every file under src/ exits outside WordPress (defined('ABSPATH') ||
exit; after the use block, so a direct request no longer prints a fatal
error with the server path); divi-convert-fixture.php gets the WP_CLI
guard the other integration scripts have. A unit test keeps both true;
PSR1 side-effects warning excluded for the guard.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
2026-09-26 19:32:12 +02:00

40 lines
833 B
PHP

<?php
declare(strict_types=1);
namespace LIT\MCP\ChangeLog;
use LIT\MCP\Limits;
defined('ABSPATH') || exit;
/**
* Daily WP-Cron job that removes log rows older than the configured retention.
*/
final class ChangeLogCleanup
{
public const HOOK = 'lit_mcp_log_cleanup';
public function __construct(private ChangeLog $log, private Limits $limits)
{
}
public function register(): void
{
add_action(self::HOOK, [$this, 'run']);
add_action('init', [$this, 'ensureScheduled']);
}
public function ensureScheduled(): void
{
if (wp_next_scheduled(self::HOOK) === false) {
wp_schedule_event(time() + 3600, 'daily', self::HOOK);
}
}
public function run(): void
{
$this->log->purgeOlderThan($this->limits->logRetentionDays());
}
}