diff --git a/src/Integrations/Divi/Library/LibraryMakeGlobalAbility.php b/src/Integrations/Divi/Library/LibraryMakeGlobalAbility.php index 8939a4d..e06e26c 100644 --- a/src/Integrations/Divi/Library/LibraryMakeGlobalAbility.php +++ b/src/Integrations/Divi/Library/LibraryMakeGlobalAbility.php @@ -531,11 +531,14 @@ final class LibraryMakeGlobalAbility implements Ability $rest === [] ? 'keine weiteren' : implode(', ', $rest) ); - return $e->withDetails( - $details, - 'Den Stand mit lit/library-find-similar neu prüfen und nur die übrigen Seiten mit neuem tree_rev ersetzen.', - $e->rolledBack ? $state : null - ); + // Ruling P14: a backup of page N (revisions off) stays named – its sentence leads the hint. + $hint = 'Den Stand mit lit/library-find-similar neu prüfen und nur die übrigen Seiten mit neuem tree_rev ' + . 'ersetzen.'; + 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). */ diff --git a/tests/Unit/Integrations/Divi/Library/LibraryMakeGlobalAbilityTest.php b/tests/Unit/Integrations/Divi/Library/LibraryMakeGlobalAbilityTest.php index 1199706..23103a9 100644 --- a/tests/Unit/Integrations/Divi/Library/LibraryMakeGlobalAbilityTest.php +++ b/tests/Unit/Integrations/Divi/Library/LibraryMakeGlobalAbilityTest.php @@ -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. */ public function testAFailureMidwayReportsEveryPage(): void {