fix: global library edits check private and scheduled pages, name the backup on failure (P8a, P14)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -179,7 +179,43 @@ final class DiviWriter
|
||||
return $prepared;
|
||||
}
|
||||
|
||||
return array_merge($this->save($ability, $page, $change, $input, $prepared['scope']), $prepared['details']);
|
||||
try {
|
||||
$saved = $this->save($ability, $page, $change, $input, $prepared['scope']);
|
||||
} catch (WriteFailed $e) {
|
||||
throw self::keepingBackup($e, $prepared['details']['backup_id'] ?? null);
|
||||
}
|
||||
|
||||
return array_merge($saved, $prepared['details']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ruling P14: GlobalEdits made a backup (revisions off) before the save failed – the error names
|
||||
* it, because it stays in the trash and is the only earlier state.
|
||||
*/
|
||||
private static function keepingBackup(WriteFailed $e, mixed $backupId): WriteFailed
|
||||
{
|
||||
if (! is_int($backupId)) {
|
||||
return $e;
|
||||
}
|
||||
|
||||
$kept = sprintf(
|
||||
'Sicherung %d liegt im Papierkorb (vorheriger Stand des Bibliothekseintrags, in WordPress '
|
||||
. 'wiederherstellbar).',
|
||||
$backupId
|
||||
);
|
||||
if ($e->rolledBack) {
|
||||
return $e->withDetails(
|
||||
['backup_id' => $backupId],
|
||||
$kept . ' Den Aufruf erst nach Prüfung mit lit-divi-outline wiederholen.',
|
||||
Errors::notSavedKeeping(sprintf('Sicherung %d im Papierkorb', $backupId))
|
||||
);
|
||||
}
|
||||
|
||||
return $e->withDetails(
|
||||
['backup_id' => $backupId],
|
||||
'Den Aufruf nicht einfach wiederholen. ' . $kept . ' Zuerst den Stand mit lit-divi-outline prüfen und '
|
||||
. 'dem Nutzer Bescheid geben.'
|
||||
);
|
||||
}
|
||||
|
||||
/** A tool's confirm_required on a global library entry, extended by the affected pages. */
|
||||
|
||||
Reference in New Issue
Block a user