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
|
final class DiviChange
|
||||||
{
|
{
|
||||||
/** @var list<array{block: ?Block, id: ?string, type: string, action: string, label: string}> */
|
/** @var list<array{block: ?Block, id: ?string, type: string, action: string, label: string}> */
|
||||||
private array $changed = [];
|
private array $entries = [];
|
||||||
|
|
||||||
/** @var list<Block> */
|
/** @var list<Block> */
|
||||||
private array $touched = [];
|
private array $touched = [];
|
||||||
@@ -32,9 +32,9 @@ final class DiviChange
|
|||||||
* A node that still exists after the change: "inserted", "updated", "moved" or "duplicated".
|
* A node that still exists after the change: "inserted", "updated", "moved" or "duplicated".
|
||||||
* Every action but "moved" counts for the quality warnings.
|
* 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,
|
'block' => $block,
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'type' => $block->name(),
|
'type' => $block->name(),
|
||||||
@@ -51,7 +51,7 @@ final class DiviChange
|
|||||||
/** A node that is gone; $idBefore is its ID before the change. */
|
/** A node that is gone; $idBefore is its ID before the change. */
|
||||||
public function removed(string $idBefore, Block $block): self
|
public function removed(string $idBefore, Block $block): self
|
||||||
{
|
{
|
||||||
$this->changed[] = [
|
$this->entries[] = [
|
||||||
'block' => null,
|
'block' => null,
|
||||||
'id' => $idBefore,
|
'id' => $idBefore,
|
||||||
'type' => $block->name(),
|
'type' => $block->name(),
|
||||||
@@ -72,7 +72,7 @@ final class DiviChange
|
|||||||
/** @return list<array{block: ?Block, id: ?string, type: string, action: string, label: string}> */
|
/** @return list<array{block: ?Block, id: ?string, type: string, action: string, label: string}> */
|
||||||
public function entries(): array
|
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'])));
|
$change = new DiviChange(sprintf('%d Divi-Knoten eingefügt', count($composed['blocks'])));
|
||||||
foreach ($composed['blocks'] as $block) {
|
foreach ($composed['blocks'] as $block) {
|
||||||
$change->changed($block, 'inserted');
|
$change->record($block, 'inserted');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $change;
|
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']));
|
$change = new DiviChange(sprintf('Text ersetzt (%d Stellen)', $found['count']));
|
||||||
foreach ($found['blocks'] as [$block, $attrs]) {
|
foreach ($found['blocks'] as [$block, $attrs]) {
|
||||||
$block->setAttrs($attrs);
|
$block->setAttrs($attrs);
|
||||||
$change->changed($block, 'updated');
|
$change->record($block, 'updated');
|
||||||
}
|
}
|
||||||
|
|
||||||
$saved = $this->writer->save($this->name(), $page, $change, $input);
|
$saved = $this->writer->save($this->name(), $page, $change, $input);
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ final class DiviUpdateAbility extends DiviWriteAbility
|
|||||||
foreach ($updates as [$block, $attrs]) {
|
foreach ($updates as [$block, $attrs]) {
|
||||||
// Composer::update() output: every client value already passed the choke point.
|
// Composer::update() output: every client value already passed the choke point.
|
||||||
$block->setAttrs($attrs);
|
$block->setAttrs($attrs);
|
||||||
$change->changed($block, 'updated');
|
$change->record($block, 'updated');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $change;
|
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\Outline;
|
||||||
use LIT\MCP\Integrations\Divi\BlockTree\Serializer;
|
use LIT\MCP\Integrations\Divi\BlockTree\Serializer;
|
||||||
use LIT\MCP\Integrations\Divi\Design\DesignSystemReader;
|
use LIT\MCP\Integrations\Divi\Design\DesignSystemReader;
|
||||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||||
use WP_Error;
|
use WP_Error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,7 +114,7 @@ class DiviWriter
|
|||||||
$warnings[] = self::OUTLINE_TRUNCATED;
|
$warnings[] = self::OUTLINE_TRUNCATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = (new PostChangeResult(
|
$result = (new PostSaveFollowUp(
|
||||||
$ability,
|
$ability,
|
||||||
$this->log,
|
$this->log,
|
||||||
(int) $post->ID,
|
(int) $post->ID,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use LIT\MCP\Abilities\Errors;
|
|||||||
use LIT\MCP\Abilities\Rev;
|
use LIT\MCP\Abilities\Rev;
|
||||||
use LIT\MCP\Abilities\ToolResult;
|
use LIT\MCP\Abilities\ToolResult;
|
||||||
use LIT\MCP\ChangeLog\ChangeLog;
|
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\PostGuard;
|
||||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||||
use Throwable;
|
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
|
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.
|
// 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);
|
->afterSave($input);
|
||||||
$post = $change->reread();
|
$post = $change->reread();
|
||||||
$title = $post instanceof WP_Post ? (string) $post->post_title : (string) $input['title'];
|
$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\ToolResult;
|
||||||
use LIT\MCP\Abilities\WriteFailed;
|
use LIT\MCP\Abilities\WriteFailed;
|
||||||
use LIT\MCP\ChangeLog\ChangeLog;
|
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\PostGuard;
|
||||||
use LIT\MCP\Integrations\WordPress\PostRow;
|
use LIT\MCP\Integrations\WordPress\PostRow;
|
||||||
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
||||||
@@ -179,7 +179,7 @@ final class ContentUpdateAbility implements Ability
|
|||||||
$postType = (string) $post->post_type;
|
$postType = (string) $post->post_type;
|
||||||
|
|
||||||
// The change is saved – failures from here on are logged and reported as warnings only.
|
// 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);
|
->afterSave($input);
|
||||||
$updated = $change->reread($post) ?? $post;
|
$updated = $change->reread($post) ?? $post;
|
||||||
$changedKeys = array_keys(array_intersect_key($input, array_flip(self::CHANGE_KEYS)));
|
$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
|
* failure must not turn the saved change into an error – listener and log failures are
|
||||||
* logged and reported as warnings ("… ist gespeichert").
|
* logged and reported as warnings ("… ist gespeichert").
|
||||||
*/
|
*/
|
||||||
final class PostChangeResult
|
final class PostSaveFollowUp
|
||||||
{
|
{
|
||||||
/** @var list<string> */
|
/** @var list<string> */
|
||||||
private array $warnings;
|
private array $warnings;
|
||||||
@@ -9,7 +9,7 @@ use LIT\MCP\Abilities\Errors;
|
|||||||
use LIT\MCP\Abilities\Rev;
|
use LIT\MCP\Abilities\Rev;
|
||||||
use LIT\MCP\Abilities\ToolResult;
|
use LIT\MCP\Abilities\ToolResult;
|
||||||
use LIT\MCP\ChangeLog\ChangeLog;
|
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\PostGuard;
|
||||||
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
||||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
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.
|
// 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;
|
$updated = $change->reread($post) ?? $post;
|
||||||
$summary = sprintf('"%s" auf Stand vom %s zurückgesetzt', $updated->post_title, $revision->post_date);
|
$summary = sprintf('"%s" auf Stand vom %s zurückgesetzt', $updated->post_title, $revision->post_date);
|
||||||
$postType = (string) $post->post_type;
|
$postType = (string) $post->post_type;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace LIT\MCP\Integrations\WordPress\Status;
|
|||||||
use LIT\MCP\Abilities\Ability;
|
use LIT\MCP\Abilities\Ability;
|
||||||
use LIT\MCP\Abilities\ToolResult;
|
use LIT\MCP\Abilities\ToolResult;
|
||||||
use LIT\MCP\ChangeLog\ChangeLog;
|
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\PostGuard;
|
||||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||||
use WP_Error;
|
use WP_Error;
|
||||||
@@ -87,7 +87,7 @@ final class PostDuplicateAbility implements Ability
|
|||||||
$copyId = $this->cloner->duplicate($original);
|
$copyId = $this->cloner->duplicate($original);
|
||||||
|
|
||||||
// The copy is saved – failures from here on are logged and reported as warnings only.
|
// 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');
|
->afterSave($input, 'Anlegen der Kopie');
|
||||||
$copy = $change->reread();
|
$copy = $change->reread();
|
||||||
$copyTitle = $copy instanceof WP_Post ? (string) $copy->post_title : '';
|
$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\Rev;
|
||||||
use LIT\MCP\Abilities\ToolResult;
|
use LIT\MCP\Abilities\ToolResult;
|
||||||
use LIT\MCP\ChangeLog\ChangeLog;
|
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\PostGuard;
|
||||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||||
use WP_Error;
|
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.
|
// 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));
|
$change->log((string) $post->post_type, sprintf('"%s" veröffentlicht', $title));
|
||||||
|
|
||||||
return $change->result(sprintf('"%s" ist jetzt veröffentlicht.', $title), $change->reread($post))
|
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\ToolResult;
|
||||||
use LIT\MCP\Abilities\WriteFailed;
|
use LIT\MCP\Abilities\WriteFailed;
|
||||||
use LIT\MCP\ChangeLog\ChangeLog;
|
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\PostGuard;
|
||||||
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
||||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||||
@@ -222,7 +222,7 @@ final class PostReplaceWithCopyAbility implements Ability
|
|||||||
$warnings[] = $trashWarning;
|
$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);
|
->afterSave($input);
|
||||||
$title = PostCloner::withoutSuffix((string) $copy->post_title);
|
$title = PostCloner::withoutSuffix((string) $copy->post_title);
|
||||||
$summary = sprintf('Kopie ID %d in "%s" (ID %d) übernommen', $copyId, $title, $originalId);
|
$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\Errors;
|
||||||
use LIT\MCP\Abilities\ToolResult;
|
use LIT\MCP\Abilities\ToolResult;
|
||||||
use LIT\MCP\ChangeLog\ChangeLog;
|
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\PostGuard;
|
||||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||||
use WP_Error;
|
use WP_Error;
|
||||||
@@ -142,7 +142,7 @@ final class PostScheduleAbility implements Ability
|
|||||||
$raw
|
$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');
|
->afterSave($input, 'Planen');
|
||||||
$title = (string) $post->post_title;
|
$title = (string) $post->post_title;
|
||||||
$summary = sprintf('"%s" geplant für %s', $title, $raw)
|
$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\Rev;
|
||||||
use LIT\MCP\Abilities\ToolResult;
|
use LIT\MCP\Abilities\ToolResult;
|
||||||
use LIT\MCP\ChangeLog\ChangeLog;
|
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\PostGuard;
|
||||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||||
use WP_Error;
|
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.
|
// 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));
|
->log((string) $post->post_type, sprintf('"%s" in den Papierkorb gelegt', $title));
|
||||||
|
|
||||||
$summary = sprintf('"%s" liegt im Papierkorb und ist dort wiederherstellbar.', $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\Rev;
|
||||||
use LIT\MCP\Abilities\ToolResult;
|
use LIT\MCP\Abilities\ToolResult;
|
||||||
use LIT\MCP\ChangeLog\ChangeLog;
|
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\PostGuard;
|
||||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||||
use WP_Error;
|
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.
|
// 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);
|
$summary = sprintf('"%s" zurückgezogen (vorher %s, jetzt Entwurf)', $title, $post->post_status);
|
||||||
$change->log((string) $post->post_type, $summary);
|
$change->log((string) $post->post_type, $summary);
|
||||||
$updated = $change->reread($post) ?? $post;
|
$updated = $change->reread($post) ?? $post;
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ final class DiviChangeTest extends TestCase
|
|||||||
));
|
));
|
||||||
$row = $index->find('s0.r0');
|
$row = $index->find('s0.r0');
|
||||||
$change = (new DiviChange('x'))
|
$change = (new DiviChange('x'))
|
||||||
->changed($row, 'updated')
|
->record($row, 'updated')
|
||||||
->removed('s3.r1', Block::create('divi/row'))
|
->removed('s3.r1', Block::create('divi/row'))
|
||||||
->changed(Block::create('divi/text'), 'inserted');
|
->record(Block::create('divi/text'), 'inserted');
|
||||||
|
|
||||||
self::assertSame(
|
self::assertSame(
|
||||||
['s0.r0', 's3.r1', null],
|
['s0.r0', 's3.r1', null],
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ final class DiviWriterTest extends TestCase
|
|||||||
$button->setAttrs(AttrMap::set($button->attrs(), 'button.innerContent.desktop.value.text', 'Neu'));
|
$button->setAttrs(AttrMap::set($button->attrs(), 'button.innerContent.desktop.value.text', 'Neu'));
|
||||||
$page->document->children()[0]->removeChild($removed);
|
$page->document->children()[0]->removeChild($removed);
|
||||||
$change = (new DiviChange('Button geändert'))
|
$change = (new DiviChange('Button geändert'))
|
||||||
->changed($button, 'updated')
|
->record($button, 'updated')
|
||||||
->removed('s1', $removed)
|
->removed('s1', $removed)
|
||||||
->warning('eigene Warnung');
|
->warning('eigene Warnung');
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -7,13 +7,13 @@ namespace LIT\MCP\Tests\Unit\Integrations\WordPress;
|
|||||||
use Brain\Monkey\Actions;
|
use Brain\Monkey\Actions;
|
||||||
use Brain\Monkey\Functions;
|
use Brain\Monkey\Functions;
|
||||||
use LIT\MCP\Abilities\Rev;
|
use LIT\MCP\Abilities\Rev;
|
||||||
use LIT\MCP\Integrations\WordPress\PostChangeResult;
|
use LIT\MCP\Integrations\WordPress\PostSaveFollowUp;
|
||||||
use LIT\MCP\Tests\Support\FakeChangeLog;
|
use LIT\MCP\Tests\Support\FakeChangeLog;
|
||||||
use LIT\MCP\Tests\Unit\TestCase;
|
use LIT\MCP\Tests\Unit\TestCase;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use WP_Post;
|
use WP_Post;
|
||||||
|
|
||||||
final class PostChangeResultTest extends TestCase
|
final class PostSaveFollowUpTest extends TestCase
|
||||||
{
|
{
|
||||||
private string $errorLog = '';
|
private string $errorLog = '';
|
||||||
private string|false $previousLog = false;
|
private string|false $previousLog = false;
|
||||||
@@ -39,7 +39,7 @@ final class PostChangeResultTest extends TestCase
|
|||||||
Functions\when('get_post')->justReturn($post);
|
Functions\when('get_post')->justReturn($post);
|
||||||
$log = new FakeChangeLog(9);
|
$log = new FakeChangeLog(9);
|
||||||
|
|
||||||
$change = new PostChangeResult('lit/content-update', $log, 5, 'die Änderung', ['vorher']);
|
$change = new PostSaveFollowUp('lit/content-update', $log, 5, 'die Änderung', ['vorher']);
|
||||||
$change->afterSave(['post_id' => 5]);
|
$change->afterSave(['post_id' => 5]);
|
||||||
$updated = $change->reread();
|
$updated = $change->reread();
|
||||||
$change->log('page', 'geändert', 811);
|
$change->log('page', 'geändert', 811);
|
||||||
@@ -68,7 +68,7 @@ final class PostChangeResultTest extends TestCase
|
|||||||
$log = new FakeChangeLog(1, new RuntimeException('log kaputt'));
|
$log = new FakeChangeLog(1, new RuntimeException('log kaputt'));
|
||||||
$fallback = new WP_Post(['ID' => 5]);
|
$fallback = new WP_Post(['ID' => 5]);
|
||||||
|
|
||||||
$change = new PostChangeResult('lit/post-publish', $log, 5);
|
$change = new PostSaveFollowUp('lit/post-publish', $log, 5);
|
||||||
$change->afterSave([], 'Veröffentlichen');
|
$change->afterSave([], 'Veröffentlichen');
|
||||||
$updated = $change->reread($fallback);
|
$updated = $change->reread($fallback);
|
||||||
$change->log('page', 'x');
|
$change->log('page', 'x');
|
||||||
@@ -88,7 +88,7 @@ final class PostChangeResultTest extends TestCase
|
|||||||
{
|
{
|
||||||
Functions\when('get_post')->justReturn(null);
|
Functions\when('get_post')->justReturn(null);
|
||||||
|
|
||||||
$change = new PostChangeResult('lit/content-create', FakeChangeLog::forbidden(), 5, 'der Entwurf');
|
$change = new PostSaveFollowUp('lit/content-create', FakeChangeLog::forbidden(), 5, 'der Entwurf');
|
||||||
|
|
||||||
self::assertNull($change->reread());
|
self::assertNull($change->reread());
|
||||||
self::assertNull($change->result('ok', null)->toArray()['rev']);
|
self::assertNull($change->result('ok', null)->toArray()['rev']);
|
||||||
Reference in New Issue
Block a user