fix: final review minors m-1 to m-8
- m-1: the no-change Divi result carries preview_url/edit_url too - m-2: overview names replace-text's per-page tree_rev - m-3: divi-shortform documents validation_failed vs not_found for unknown IDs - m-4: DiviWriter/DiviPageLoader final (no mocks left), neutral NewDraft log detail, snapshots are Etappe 4 - m-5: Tested up to 7.1, changelog completed - m-6: content-create warns when the extras changed the stored layout - m-7: deleting a whole section outlines nothing instead of the next one - m-8: uninstall removes the user meta lit_mcp_log_per_page; readme lists it 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:
@@ -34,6 +34,10 @@ defined('ABSPATH') || exit;
|
||||
*/
|
||||
final class ContentCreateAbility implements Ability
|
||||
{
|
||||
/** The extras (written after the layout) re-saved the entry and changed the stored layout (review m-6). */
|
||||
public const LAYOUT_CHANGED = 'Der Divi-Inhalt wurde beim Speichern der Felder verändert (z. B. durch ein Plugin); '
|
||||
. 'tree_rev beschreibt den gespeicherten Stand – vor weiteren Änderungen lit-divi-outline lesen.';
|
||||
|
||||
public function __construct(
|
||||
private ContentSchema $schema,
|
||||
private PostWriter $writer,
|
||||
@@ -161,6 +165,7 @@ final class ContentCreateAbility implements Ability
|
||||
return $draft->refuse($postId, $layout);
|
||||
}
|
||||
|
||||
$stored = is_array($layout) ? self::content($postId) : null;
|
||||
try {
|
||||
$this->writer->writeExtras($postId, $postType, $prepared, $input);
|
||||
} catch (Throwable $e) {
|
||||
@@ -168,6 +173,9 @@ final class ContentCreateAbility implements Ability
|
||||
}
|
||||
|
||||
$warnings = array_merge($prepared['warnings'], $layout['warnings'] ?? []);
|
||||
if ($stored !== null && self::content($postId) !== $stored) {
|
||||
$warnings[] = self::LAYOUT_CHANGED;
|
||||
}
|
||||
|
||||
return $this->result($postId, $postType, $input, $warnings, $layout);
|
||||
}
|
||||
@@ -188,6 +196,13 @@ final class ContentCreateAbility implements Ability
|
||||
return $this->divi?->check($postType, self::sections($input));
|
||||
}
|
||||
|
||||
private static function content(int $postId): ?string
|
||||
{
|
||||
$post = get_post($postId);
|
||||
|
||||
return $post instanceof WP_Post ? (string) $post->post_content : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
* @return list<mixed>
|
||||
|
||||
@@ -106,7 +106,7 @@ final class NewDraft
|
||||
static fn () => self::deleteDraft($postId)
|
||||
);
|
||||
|
||||
$detail = sprintf('Extras of new post %d could not be written: %s', $postId, $cause->getMessage());
|
||||
$detail = sprintf('Writing new post %d failed after the insert: %s', $postId, $cause->getMessage());
|
||||
if ($problems === []) {
|
||||
throw WriteFailed::rolledBack($reason, $cause, $detail);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user