fix: failed library and layout saves name the revision screen (audit L3)

A failed save of a library entry or Theme Builder layout now carries
restore_url when a revision exists; a partial write's hint points to the
WordPress revision screen and lit-divi-outline instead of
lit/revisions-list and lit/revision-restore, which answer not found for
these types. Pages keep the default hint.

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:
2026-09-27 23:25:16 +02:00
co-authored by Claude Opus 5.5
parent 9c3f7d356f
commit 771f3794a0
3 changed files with 84 additions and 1 deletions
+33 -1
View File
@@ -127,7 +127,7 @@ final class DiviWriter
$e->revisionId
);
}
throw $e;
throw self::withRestorePoint($page, $e);
}
$outline = $this->outline($index, $change);
@@ -177,6 +177,38 @@ final class DiviWriter
return admin_url('revision.php?revision=' . $revisionId);
}
/**
* Audit L3 on the failure path: for a library entry or a Theme Builder layout the error names the WordPress
* revision screen (restore_url) and says so in the hint of a partial write, instead of lit/revisions-list and
* lit/revision-restore, which answer "not found" for these types. Pages keep the default hint.
*/
private static function withRestorePoint(DiviPage $page, WriteFailed $e): WriteFailed
{
if (! $page->isLibraryItem() && ! $page->isThemeBuilderLayout()) {
return $e;
}
$restore = self::restoreUrl($page, $e->revisionId);
$details = $restore === null ? [] : ['restore_url' => $restore];
if ($e->rolledBack) {
return $details === [] ? $e : $e->withDetails($details);
}
$back = $restore === null
? ''
: sprintf(
' Den vorherigen Stand (Revision %d) bei Bedarf im Revisionsvergleich von WordPress wiederherstellen '
. '(restore_url).',
(int) $e->revisionId
);
return $e->withDetails(
$details,
'Den Aufruf nicht einfach wiederholen. Zuerst den aktuellen Stand mit lit-divi-outline prüfen.' . $back
. ' Dem Nutzer Bescheid geben.'
);
}
/**
* save() for the Divi tools (E2): pages as before; a library entry keeps its shape, a global one
* needs confirm (dry run first), gets a backup when revisions are off and clears every page's