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
@@ -69,7 +69,33 @@ final class TermAssignerTest extends TestCase
Functions\expect('wp_insert_term')->once()->with('Neu', 'category')->andReturn(['term_id' => 15]);
Functions\expect('wp_set_object_terms')->once()->with(5, [4, 15], 'category', false)->andReturn([4, 15]);
(new TermAssigner())->assign(5, ['category' => [4, 'Neu']]);
self::assertSame([15 => 'category'], (new TermAssigner())->assign(5, ['category' => [4, 'Neu']]));
}
public function testAFailedAssignmentDeletesTheTermsItCreated(): void
{
Functions\when('wp_insert_term')->justReturn(['term_id' => 15]);
Functions\when('wp_set_object_terms')->justReturn(new WP_Error('x', 'kaputt'));
Functions\expect('wp_delete_term')->once()->with(15, 'category')->andReturn(true);
$this->expectException(RuntimeException::class);
(new TermAssigner())->assign(5, ['category' => ['Neu']]);
}
public function testDeleteTermsAcceptsAlreadyMissingTermsAndThrowsOnRealFailures(): void
{
Functions\when('wp_delete_term')->alias(static fn (int $id): mixed => match ($id) {
15 => true,
16 => false,
default => new WP_Error('x', 'kaputt'),
});
$assigner = new TermAssigner();
$assigner->deleteTerms([15 => 'category', 16 => 'category']);
$this->expectException(RuntimeException::class);
$assigner->deleteTerms([15 => 'category', 17 => 'post_tag']);
}
public function testAssignFailureThrows(): void