refactor: rename for intent (L3)
PostChangeResult is PostSaveFollowUp (the after-save pipeline, not a result); DiviChange::changed() is record() (moved nodes are recorded but not touched). cleanValue/withoutControls were renamed in wave 2. 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:
@@ -16,7 +16,7 @@ use LIT\MCP\Integrations\Divi\BlockTree\NodeSummary;
|
||||
final class DiviChange
|
||||
{
|
||||
/** @var list<array{block: ?Block, id: ?string, type: string, action: string, label: string}> */
|
||||
private array $changed = [];
|
||||
private array $entries = [];
|
||||
|
||||
/** @var list<Block> */
|
||||
private array $touched = [];
|
||||
@@ -32,9 +32,9 @@ final class DiviChange
|
||||
* A node that still exists after the change: "inserted", "updated", "moved" or "duplicated".
|
||||
* Every action but "moved" counts for the quality warnings.
|
||||
*/
|
||||
public function changed(Block $block, string $action): self
|
||||
public function record(Block $block, string $action): self
|
||||
{
|
||||
$this->changed[] = [
|
||||
$this->entries[] = [
|
||||
'block' => $block,
|
||||
'id' => null,
|
||||
'type' => $block->name(),
|
||||
@@ -51,7 +51,7 @@ final class DiviChange
|
||||
/** A node that is gone; $idBefore is its ID before the change. */
|
||||
public function removed(string $idBefore, Block $block): self
|
||||
{
|
||||
$this->changed[] = [
|
||||
$this->entries[] = [
|
||||
'block' => null,
|
||||
'id' => $idBefore,
|
||||
'type' => $block->name(),
|
||||
@@ -72,7 +72,7 @@ final class DiviChange
|
||||
/** @return list<array{block: ?Block, id: ?string, type: string, action: string, label: string}> */
|
||||
public function entries(): array
|
||||
{
|
||||
return $this->changed;
|
||||
return $this->entries;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,6 +75,6 @@ final class DiviDuplicateNodeAbility extends DiviWriteAbility
|
||||
));
|
||||
}
|
||||
|
||||
return (new DiviChange(sprintf('Knoten %s dupliziert', $id)))->changed($copy, 'duplicated');
|
||||
return (new DiviChange(sprintf('Knoten %s dupliziert', $id)))->record($copy, 'duplicated');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ final class DiviInsertAbility extends DiviWriteAbility
|
||||
|
||||
$change = new DiviChange(sprintf('%d Divi-Knoten eingefügt', count($composed['blocks'])));
|
||||
foreach ($composed['blocks'] as $block) {
|
||||
$change->changed($block, 'inserted');
|
||||
$change->record($block, 'inserted');
|
||||
}
|
||||
|
||||
return $change;
|
||||
|
||||
@@ -71,6 +71,6 @@ final class DiviMoveAbility extends DiviWriteAbility
|
||||
);
|
||||
}
|
||||
|
||||
return (new DiviChange(sprintf('Knoten %s verschoben', $id)))->changed($node, 'moved');
|
||||
return (new DiviChange(sprintf('Knoten %s verschoben', $id)))->record($node, 'moved');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ final class DiviReplaceTextAbility implements Ability
|
||||
$change = new DiviChange(sprintf('Text ersetzt (%d Stellen)', $found['count']));
|
||||
foreach ($found['blocks'] as [$block, $attrs]) {
|
||||
$block->setAttrs($attrs);
|
||||
$change->changed($block, 'updated');
|
||||
$change->record($block, 'updated');
|
||||
}
|
||||
|
||||
$saved = $this->writer->save($this->name(), $page, $change, $input);
|
||||
|
||||
@@ -146,7 +146,7 @@ final class DiviUpdateAbility extends DiviWriteAbility
|
||||
foreach ($updates as [$block, $attrs]) {
|
||||
// Composer::update() output: every client value already passed the choke point.
|
||||
$block->setAttrs($attrs);
|
||||
$change->changed($block, 'updated');
|
||||
$change->record($block, 'updated');
|
||||
}
|
||||
|
||||
return $change;
|
||||
|
||||
@@ -13,7 +13,7 @@ use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\Outline;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\Serializer;
|
||||
use LIT\MCP\Integrations\Divi\Design\DesignSystemReader;
|
||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
||||
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||
use WP_Error;
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ class DiviWriter
|
||||
$warnings[] = self::OUTLINE_TRUNCATED;
|
||||
}
|
||||
|
||||
$result = (new PostChangeResult(
|
||||
$result = (new PostSaveFollowUp(
|
||||
$ability,
|
||||
$this->log,
|
||||
(int) $post->ID,
|
||||
|
||||
@@ -9,7 +9,7 @@ use LIT\MCP\Abilities\Errors;
|
||||
use LIT\MCP\Abilities\Rev;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
||||
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
use Throwable;
|
||||
@@ -216,7 +216,7 @@ final class ContentCreateAbility implements Ability
|
||||
private function result(int $postId, string $postType, array $input, array $warnings, ?string $outline): array
|
||||
{
|
||||
// The draft is saved – failures from here on are logged and reported as warnings only.
|
||||
$change = (new PostChangeResult($this->name(), $this->log, $postId, 'der Entwurf', $warnings))
|
||||
$change = (new PostSaveFollowUp($this->name(), $this->log, $postId, 'der Entwurf', $warnings))
|
||||
->afterSave($input);
|
||||
$post = $change->reread();
|
||||
$title = $post instanceof WP_Post ? (string) $post->post_title : (string) $input['title'];
|
||||
|
||||
@@ -11,7 +11,7 @@ use LIT\MCP\Abilities\Rollback;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\Abilities\WriteFailed;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
||||
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use LIT\MCP\Integrations\WordPress\PostRow;
|
||||
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
||||
@@ -179,7 +179,7 @@ final class ContentUpdateAbility implements Ability
|
||||
$postType = (string) $post->post_type;
|
||||
|
||||
// The change is saved – failures from here on are logged and reported as warnings only.
|
||||
$change = (new PostChangeResult($this->name(), $this->log, $postId, 'die Änderung', $warnings))
|
||||
$change = (new PostSaveFollowUp($this->name(), $this->log, $postId, 'die Änderung', $warnings))
|
||||
->afterSave($input);
|
||||
$updated = $change->reread($post) ?? $post;
|
||||
$changedKeys = array_keys(array_intersect_key($input, array_flip(self::CHANGE_KEYS)));
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ use WP_Post;
|
||||
* failure must not turn the saved change into an error – listener and log failures are
|
||||
* logged and reported as warnings ("… ist gespeichert").
|
||||
*/
|
||||
final class PostChangeResult
|
||||
final class PostSaveFollowUp
|
||||
{
|
||||
/** @var list<string> */
|
||||
private array $warnings;
|
||||
@@ -9,7 +9,7 @@ use LIT\MCP\Abilities\Errors;
|
||||
use LIT\MCP\Abilities\Rev;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
||||
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
@@ -129,7 +129,7 @@ final class RevisionRestoreAbility implements Ability
|
||||
}
|
||||
|
||||
// The restore is saved – failures from here on are logged and reported as warnings only.
|
||||
$change = (new PostChangeResult($this->name(), $this->log, $postId))->afterSave($input, 'Wiederherstellen');
|
||||
$change = (new PostSaveFollowUp($this->name(), $this->log, $postId))->afterSave($input, 'Wiederherstellen');
|
||||
$updated = $change->reread($post) ?? $post;
|
||||
$summary = sprintf('"%s" auf Stand vom %s zurückgesetzt', $updated->post_title, $revision->post_date);
|
||||
$postType = (string) $post->post_type;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace LIT\MCP\Integrations\WordPress\Status;
|
||||
use LIT\MCP\Abilities\Ability;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
||||
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
use WP_Error;
|
||||
@@ -87,7 +87,7 @@ final class PostDuplicateAbility implements Ability
|
||||
$copyId = $this->cloner->duplicate($original);
|
||||
|
||||
// The copy is saved – failures from here on are logged and reported as warnings only.
|
||||
$change = (new PostChangeResult($this->name(), $this->log, $copyId, 'die Kopie'))
|
||||
$change = (new PostSaveFollowUp($this->name(), $this->log, $copyId, 'die Kopie'))
|
||||
->afterSave($input, 'Anlegen der Kopie');
|
||||
$copy = $change->reread();
|
||||
$copyTitle = $copy instanceof WP_Post ? (string) $copy->post_title : '';
|
||||
|
||||
@@ -9,7 +9,7 @@ use LIT\MCP\Abilities\Errors;
|
||||
use LIT\MCP\Abilities\Rev;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
||||
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
use WP_Error;
|
||||
@@ -120,7 +120,7 @@ final class PostPublishAbility implements Ability
|
||||
}
|
||||
|
||||
// The status change is saved – failures from here on are logged and reported as warnings only.
|
||||
$change = (new PostChangeResult($this->name(), $this->log, $postId))->afterSave($input, 'Veröffentlichen');
|
||||
$change = (new PostSaveFollowUp($this->name(), $this->log, $postId))->afterSave($input, 'Veröffentlichen');
|
||||
$change->log((string) $post->post_type, sprintf('"%s" veröffentlicht', $title));
|
||||
|
||||
return $change->result(sprintf('"%s" ist jetzt veröffentlicht.', $title), $change->reread($post))
|
||||
|
||||
@@ -11,7 +11,7 @@ use LIT\MCP\Abilities\Rev;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\Abilities\WriteFailed;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
||||
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
@@ -222,7 +222,7 @@ final class PostReplaceWithCopyAbility implements Ability
|
||||
$warnings[] = $trashWarning;
|
||||
}
|
||||
|
||||
$change = (new PostChangeResult($this->name(), $this->log, $originalId, 'die Änderung', $warnings))
|
||||
$change = (new PostSaveFollowUp($this->name(), $this->log, $originalId, 'die Änderung', $warnings))
|
||||
->afterSave($input);
|
||||
$title = PostCloner::withoutSuffix((string) $copy->post_title);
|
||||
$summary = sprintf('Kopie ID %d in "%s" (ID %d) übernommen', $copyId, $title, $originalId);
|
||||
|
||||
@@ -10,7 +10,7 @@ use LIT\MCP\Abilities\Ability;
|
||||
use LIT\MCP\Abilities\Errors;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
||||
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
use WP_Error;
|
||||
@@ -142,7 +142,7 @@ final class PostScheduleAbility implements Ability
|
||||
$raw
|
||||
)]
|
||||
: [];
|
||||
$change = (new PostChangeResult($this->name(), $this->log, $postId, 'die Änderung', $warnings))
|
||||
$change = (new PostSaveFollowUp($this->name(), $this->log, $postId, 'die Änderung', $warnings))
|
||||
->afterSave($input, 'Planen');
|
||||
$title = (string) $post->post_title;
|
||||
$summary = sprintf('"%s" geplant für %s', $title, $raw)
|
||||
|
||||
@@ -9,7 +9,7 @@ use LIT\MCP\Abilities\Errors;
|
||||
use LIT\MCP\Abilities\Rev;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
||||
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
use WP_Error;
|
||||
@@ -137,7 +137,7 @@ final class PostTrashAbility implements Ability
|
||||
}
|
||||
|
||||
// The change is saved – a failure of the change log from here on is a warning only.
|
||||
$change = (new PostChangeResult($this->name(), $this->log, $postId, 'die Änderung', $impact))
|
||||
$change = (new PostSaveFollowUp($this->name(), $this->log, $postId, 'die Änderung', $impact))
|
||||
->log((string) $post->post_type, sprintf('"%s" in den Papierkorb gelegt', $title));
|
||||
|
||||
$summary = sprintf('"%s" liegt im Papierkorb und ist dort wiederherstellbar.', $title);
|
||||
|
||||
@@ -9,7 +9,7 @@ use LIT\MCP\Abilities\Errors;
|
||||
use LIT\MCP\Abilities\Rev;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
||||
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
use WP_Error;
|
||||
@@ -103,7 +103,7 @@ final class PostUnpublishAbility implements Ability
|
||||
}
|
||||
|
||||
// The status change is saved – failures from here on are logged and reported as warnings only.
|
||||
$change = (new PostChangeResult($this->name(), $this->log, $postId))->afterSave($input, 'Zurückziehen');
|
||||
$change = (new PostSaveFollowUp($this->name(), $this->log, $postId))->afterSave($input, 'Zurückziehen');
|
||||
$summary = sprintf('"%s" zurückgezogen (vorher %s, jetzt Entwurf)', $title, $post->post_status);
|
||||
$change->log((string) $post->post_type, $summary);
|
||||
$updated = $change->reread($post) ?? $post;
|
||||
|
||||
Reference in New Issue
Block a user