fix: make-global keeps the backup sentence on a failure on page 2+ (ruling P14)
failedOn() replaced the hint for a failure after earlier pages were replaced, so the "Sicherung X liegt im Papierkorb" sentence of the failed page's backup was lost. The hint now leads with it when a backup exists. 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:
@@ -531,11 +531,14 @@ final class LibraryMakeGlobalAbility implements Ability
|
|||||||
$rest === [] ? 'keine weiteren' : implode(', ', $rest)
|
$rest === [] ? 'keine weiteren' : implode(', ', $rest)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $e->withDetails(
|
// Ruling P14: a backup of page N (revisions off) stays named – its sentence leads the hint.
|
||||||
$details,
|
$hint = 'Den Stand mit lit/library-find-similar neu prüfen und nur die übrigen Seiten mit neuem tree_rev '
|
||||||
'Den Stand mit lit/library-find-similar neu prüfen und nur die übrigen Seiten mit neuem tree_rev ersetzen.',
|
. 'ersetzen.';
|
||||||
$e->rolledBack ? $state : null
|
if (isset($e->details['backup_id']) && $e->hint !== null) {
|
||||||
);
|
$hint = $e->hint . ' ' . $hint;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $e->withDetails($details, $hint, $e->rolledBack ? $state : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Pages visitors see (or will see): changes there get VisibleEdits' restore point (P8a statuses). */
|
/** Pages visitors see (or will see): changes there get VisibleEdits' restore point (P8a statuses). */
|
||||||
|
|||||||
@@ -500,6 +500,34 @@ final class LibraryMakeGlobalAbilityTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Re-review: a failure on page 2+ after its backup keeps the backup sentence in hint and message (P14). */
|
||||||
|
public function testAFailureMidwayAfterABackupKeepsTheBackupSentence(): void
|
||||||
|
{
|
||||||
|
$this->givenCopiesOf1058();
|
||||||
|
$jobs = get_post(9);
|
||||||
|
$jobs->post_status = 'publish';
|
||||||
|
LibraryFixtures::given([$this->page, LibraryFixtures::item(1058), get_post(8), $jobs]);
|
||||||
|
Functions\when('wp_revisions_enabled')->justReturn(false);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->ability([], true, false, [null, WriteFailed::rolledBack('Grund.')])
|
||||||
|
->execute(self::targets(['s0'], ['s1'], true));
|
||||||
|
self::fail('no WriteFailed');
|
||||||
|
} catch (WriteFailed $e) {
|
||||||
|
$error = $e->toError();
|
||||||
|
self::assertSame(9, $e->details['failed_post']);
|
||||||
|
self::assertSame([8], $e->details['changed_posts']);
|
||||||
|
self::assertSame(1071, $e->details['backup_id']);
|
||||||
|
self::assertStringContainsString(
|
||||||
|
sprintf(VisibleEditsTest::KEPT, 1071, 'der Seite'),
|
||||||
|
$error->get_error_data()['hint']
|
||||||
|
);
|
||||||
|
self::assertStringContainsString('lit/library-find-similar', $error->get_error_data()['hint']);
|
||||||
|
self::assertStringContainsString('Sicherung 1071 im Papierkorb', Errors::clientMessage($error));
|
||||||
|
}
|
||||||
|
self::assertCount(2, $this->backups);
|
||||||
|
}
|
||||||
|
|
||||||
/** A failure on page N: the pages before stay replaced (each with revision), the rest untouched – all named. */
|
/** A failure on page N: the pages before stay replaced (each with revision), the rest untouched – all named. */
|
||||||
public function testAFailureMidwayReportsEveryPage(): void
|
public function testAFailureMidwayReportsEveryPage(): void
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user