From d5a9774241e6b3d260fb9901d6e6c87805fcce68 Mon Sep 17 00:00:00 2001 From: Jan-Niclas Loosen Date: Sat, 26 Sep 2026 18:35:59 +0200 Subject: [PATCH] fix: content-create names the Divi layout when its write fails (S50) A failing Divi layout write discarded the draft with the fields/terms message (REASON_EXTRAS); it now passes NewDraft::REASON_LAYOUT (ledger T9). Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7 --- src/Integrations/WordPress/Content/ContentCreateAbility.php | 2 +- src/Integrations/WordPress/Content/NewDraft.php | 1 + .../Integrations/WordPress/Content/ContentCreateDiviTest.php | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Integrations/WordPress/Content/ContentCreateAbility.php b/src/Integrations/WordPress/Content/ContentCreateAbility.php index 6f8edcd..cf254cb 100644 --- a/src/Integrations/WordPress/Content/ContentCreateAbility.php +++ b/src/Integrations/WordPress/Content/ContentCreateAbility.php @@ -144,7 +144,7 @@ final class ContentCreateAbility implements Ability try { $layout = $withDivi ? $this->divi?->write($postId, $postType, self::sections($input)) : null; } catch (Throwable $e) { - $draft->discard($postId, $e, NewDraft::REASON_EXTRAS); + $draft->discard($postId, $e, NewDraft::REASON_LAYOUT); } if ($layout instanceof WP_Error) { return $draft->refuse($postId, $layout); diff --git a/src/Integrations/WordPress/Content/NewDraft.php b/src/Integrations/WordPress/Content/NewDraft.php index 753d7c9..24ae8b6 100644 --- a/src/Integrations/WordPress/Content/NewDraft.php +++ b/src/Integrations/WordPress/Content/NewDraft.php @@ -26,6 +26,7 @@ final class NewDraft { public const REASON_INSERT = 'WordPress hat beim Anlegen des Eintrags einen Fehler gemeldet.'; public const REASON_EXTRAS = 'Felder, Begriffe oder Beitragsbild konnten nicht gespeichert werden.'; + public const REASON_LAYOUT = 'Das Divi-Layout konnte nicht gespeichert werden.'; public function __construct( private PostWriter $writer, diff --git a/tests/Unit/Integrations/WordPress/Content/ContentCreateDiviTest.php b/tests/Unit/Integrations/WordPress/Content/ContentCreateDiviTest.php index 510e947..85c76e5 100644 --- a/tests/Unit/Integrations/WordPress/Content/ContentCreateDiviTest.php +++ b/tests/Unit/Integrations/WordPress/Content/ContentCreateDiviTest.php @@ -13,6 +13,7 @@ use LIT\MCP\Integrations\Divi\Pages\DiviContentComposer; use LIT\MCP\Integrations\Divi\Pages\DiviSaver; use LIT\MCP\Integrations\WordPress\Content\ContentComposer; use LIT\MCP\Integrations\WordPress\Content\ContentCreateAbility; +use LIT\MCP\Integrations\WordPress\Content\NewDraft; use LIT\MCP\Integrations\WordPress\Content\PostWriter; use LIT\MCP\Integrations\WordPress\Schema\ContentSchema; use LIT\MCP\Tests\Support\DiviWriterFixture; @@ -168,6 +169,9 @@ final class ContentCreateDiviTest extends TestCase self::fail('WriteFailed expected'); } catch (WriteFailed $e) { self::assertTrue($e->rolledBack); + // Ruling S50 / ledger T9: the client reads about the layout, not about fields or terms. + self::assertSame(NewDraft::REASON_LAYOUT, $e->reason); + self::assertStringContainsString('Divi-Layout', $e->reason); } }