feat: content-create and content-update with schema validation

All-or-nothing writes: validation (fields, terms, featured image, parent,
template) before any write; failed extras delete the new draft (create) or
restore revision, old columns, fields, terms and featured image (update).
content-update requires rev; Rev::ofPost covers content, title, excerpt,
status and post_modified_gmt. MetaFieldSource::write() now throws on failure.

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:01:48 +02:00
co-authored by Claude Opus 5.5
parent b9d46f3cec
commit 4f9a47fe32
15 changed files with 1355 additions and 9 deletions
+20 -1
View File
@@ -4,13 +4,32 @@ declare(strict_types=1);
namespace LIT\MCP\Abilities;
use WP_Post;
/**
* Short hash of post_content – the optimistic-lock handle ("rev", spec §5.3).
* Short hash used as optimistic-lock handle ("rev", spec §5.3).
*/
final class Rev
{
/** Hash of a single string, e.g. post_content (Divi layouts). */
public static function of(string $content): string
{
return substr(hash('sha256', $content), 0, 12);
}
/**
* Rev of an entry for the content tools: changes when content, title, excerpt or
* status change, or when anything else touched the post row (post_modified_gmt),
* so parallel edits beyond post_content are detected as well.
*/
public static function ofPost(WP_Post $post): string
{
return self::of(implode("\0", [
(string) $post->post_content,
(string) $post->post_title,
(string) $post->post_excerpt,
(string) $post->post_status,
(string) $post->post_modified_gmt,
]));
}
}