fix: typed write failures, template rollback, parent and term cleanup

WriteFailed maps to lit_write_failed / lit_partial_write (partial writes are
logged with result partial); old template read before the update; row marker
set before wp_update_post; created terms deleted on rollback; parent must be a
readable non-descendant of a hierarchical type; featured image must be
readable; snapshot keeps empty values; meta comparison after sanitize_meta;
follow-up failures (listener, change log) only add warnings.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
2026-09-25 23:11:18 +02:00
co-authored by Claude Opus 5.5
parent 4f9a47fe32
commit a9b2f2db71
18 changed files with 934 additions and 130 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Abilities;
use Throwable;
/**
* 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) {
$message = sprintf('[wp-lit-mcp] %s failed: %s', $context, $e);
error_log($message); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
$warnings[] = $warning;
return null;
}
}
}