fix: Task 5 review round 1 - restore point inside the kses window, strict map field types (S37)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-26 15:08:48 +02:00
co-authored by Claude Opus 5.5
parent 7762b76305
commit b8cb01812e
12 changed files with 200 additions and 26 deletions
@@ -30,7 +30,11 @@ final class DiviSaverTest extends TestCase
{
parent::setUp();
$this->post = new WP_Post(['ID' => 7, 'post_type' => 'page', 'post_content' => 'ALT']);
Functions\when('wp_save_post_revision')->justReturn(811);
Functions\when('wp_save_post_revision')->alias(function (): int {
$this->calls[] = 'revision';
return 811;
});
Functions\when('wp_get_post_revisions')->justReturn([811 => new WP_Post(['ID' => 811])]);
Functions\when('update_post_meta')->alias(function (int $id, string $key, string $value): bool {
$this->calls[] = "meta:$key=$value";
@@ -73,7 +77,12 @@ final class DiviSaverTest extends TestCase
self::assertSame(['revision_id' => 811, 'warnings' => []], $saved);
self::assertSame(
['kses off', 'update', 'kses on', 'meta:_et_pb_use_divi_5=on', 'meta:_et_pb_use_builder=on'],
// Ruling S37: the restore-point revision is captured inside the same kses-off window –
// it copies the stored content, and kses would strip an admin's embeds from it.
[
'kses off', 'revision', 'update', 'kses on',
'meta:_et_pb_use_divi_5=on', 'meta:_et_pb_use_builder=on', 'meta:_et_pb_show_page_creation=off',
],
$this->calls
);
}
@@ -87,6 +96,7 @@ final class DiviSaverTest extends TestCase
$saved = (new DiviSaver())->save($this->post, 'NEU');
self::assertNotContains('kses off', $this->calls);
self::assertSame(['revision'], array_slice($this->calls, 0, 1));
self::assertSame([DiviSaver::CHANGED_ON_SAVE], $saved['warnings']);
}
@@ -141,7 +151,10 @@ final class DiviSaverTest extends TestCase
self::assertTrue($e->rolledBack);
self::assertSame(['NEU', 'ALT'], $written);
// The kses bypass is restored in finally – after the failed save and after the restore.
self::assertSame(['kses off', 'update', 'kses on', 'kses off', 'update', 'kses on'], $this->calls);
self::assertSame(
['kses off', 'revision', 'update', 'kses on', 'kses off', 'update', 'kses on'],
$this->calls
);
}
}