Files
WP-LIT-MCP/src/Abilities/FollowUp.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

33 lines
734 B
PHP

<?php
declare(strict_types=1);
namespace LIT\MCP\Abilities;
use LIT\MCP\Log;
use Throwable;
defined('ABSPATH') || exit;
/**
* Runs a step after a write has already succeeded (listeners, change log): a failure
* there must not turn the saved change into an error. It is logged and reported as warning.
*/
final class FollowUp
{
/**
* @param list<string> $warnings Receives $warning when the step fails.
*/
public static function run(callable $step, string $context, string $warning, array &$warnings): mixed
{
try {
return $step();
} catch (Throwable $e) {
Log::failure($context, $e);
$warnings[] = $warning;
return null;
}
}
}