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
33 lines
734 B
PHP
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;
|
|
}
|
|
}
|
|
}
|