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
+32
View File
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Abilities;
use LIT\MCP\Abilities\WriteFailed;
use LIT\MCP\Tests\Unit\TestCase;
use RuntimeException;
final class WriteFailedTest extends TestCase
{
public function testCleanRollbackMapsToWriteFailed(): void
{
$cause = new RuntimeException('meta kaputt');
$failure = new WriteFailed('Felder konnten nicht gespeichert werden.', true, 5, null, $cause);
self::assertTrue($failure->rolledBack);
self::assertSame($cause, $failure->getPrevious());
self::assertStringContainsString('meta kaputt', $failure->getMessage());
self::assertSame('lit_write_failed', $failure->toError()->get_error_code());
}
public function testIncompleteRollbackMapsToPartialWriteWithTheIds(): void
{
$error = (new WriteFailed('Felder konnten nicht gespeichert werden.', false, 5, 811))->toError();
self::assertSame('lit_partial_write', $error->get_error_code());
self::assertSame(5, $error->get_error_data()['post_id']);
self::assertSame(811, $error->get_error_data()['revision_id']);
}
}