feat: deferred 1a items - menu_rev lock, lit_mcp_guides filter, warnings, schedule guard precision
Task 14 (rulings P17/P18, Q10): - lit/menu-get returns menu_rev (Rev::ofMenu over id, parent, position, title, url, object, object_id); lit/menu-set-items requires it, refuses a stale one with rev_mismatch (hint: lit/menu-get) and returns the new menu_rev. Errors::revMismatch takes an optional message/hint. - GuideRepository: filter lit_mcp_guides adds/overrides topics; invalid topic names and non-string content are ignored, files stay the default. - lit/post-trash names front page, posts page and linking menus in the confirmation and as warnings; lit/menu-assign-location needs confirm to remove an assigned menu and names it; lit/post-schedule warns that a private entry becomes public; Divi hints no longer point to non-existing lit-divi-* tools. - PostGuard::missedSchedule: 60 s publish window, zero GMT date falls back to get_gmt_from_date(post_date); post-schedule refuses dates within that window. - write_failed after a clean rollback that keeps a revision/backup says "Die Aenderung wurde nicht gespeichert (... bleibt erhalten)" via the new state parameter (Errors::writeFailed / WriteFailed rolledBackState). - wp-basis-smoke: menu_rev flow, unassign confirm, trash/menu and private-schedule warnings. 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:
@@ -56,13 +56,14 @@ final class Errors
|
||||
return self::make('not_found', $message, $hint, 404);
|
||||
}
|
||||
|
||||
public static function revMismatch(): WP_Error
|
||||
/** $message/$hint replace the post-oriented defaults (e.g. for the menu lock menu_rev). */
|
||||
public static function revMismatch(?string $message = null, ?string $hint = null): WP_Error
|
||||
{
|
||||
return self::make(
|
||||
'rev_mismatch',
|
||||
'Der Inhalt wurde seit dem letzten Lesen geändert; nichts wurde geschrieben.',
|
||||
'Neu lesen (z. B. lit/content-get, direkt: lit-content-get) und die Änderung auf dem aktuellen Stand '
|
||||
. 'wiederholen.',
|
||||
$message ?? 'Der Inhalt wurde seit dem letzten Lesen geändert; nichts wurde geschrieben.',
|
||||
$hint ?? 'Neu lesen (z. B. lit/content-get, direkt: lit-content-get) und die Änderung auf dem aktuellen '
|
||||
. 'Stand wiederholen.',
|
||||
409
|
||||
);
|
||||
}
|
||||
@@ -105,12 +106,18 @@ final class Errors
|
||||
*
|
||||
* @param array<string, mixed> $details Extra error details (e.g. a backup that stays).
|
||||
* @param string|null $hint Replaces the default hint (e.g. "re-read before retrying").
|
||||
* @param string|null $state Replaces "Nichts wurde gespeichert." when the rollback left
|
||||
* something behind on purpose (a backup or revision).
|
||||
*/
|
||||
public static function writeFailed(string $reason, array $details = [], ?string $hint = null): WP_Error
|
||||
{
|
||||
public static function writeFailed(
|
||||
string $reason,
|
||||
array $details = [],
|
||||
?string $hint = null,
|
||||
?string $state = null
|
||||
): WP_Error {
|
||||
return self::make(
|
||||
'write_failed',
|
||||
trim('Speichern fehlgeschlagen: ' . $reason) . ' Nichts wurde gespeichert.',
|
||||
trim('Speichern fehlgeschlagen: ' . $reason) . ' ' . ($state ?? 'Nichts wurde gespeichert.'),
|
||||
$hint ?? 'Eingaben prüfen, ggf. korrigieren und erneut versuchen; tritt der Fehler wieder auf, den '
|
||||
. 'Administrator informieren (Details im PHP-Error-Log der Website).',
|
||||
500,
|
||||
@@ -118,6 +125,16 @@ final class Errors
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The $state for writeFailed() when a clean rollback deliberately keeps something, e.g.
|
||||
* "Revision 811" or "Sicherung 88": the change itself is not saved, but "Nichts wurde
|
||||
* gespeichert" would be untrue.
|
||||
*/
|
||||
public static function notSavedKeeping(string $kept): string
|
||||
{
|
||||
return sprintf('Die Änderung wurde nicht gespeichert (%s bleibt erhalten).', $kept);
|
||||
}
|
||||
|
||||
/**
|
||||
* A write failed and could not be rolled back completely – something may have been saved.
|
||||
* $state and $hint replace the post-oriented defaults for writes that are not about a post
|
||||
|
||||
Reference in New Issue
Block a user