fix: media usage check fails closed on database errors; refused deletes checked for partial state
MediaUsageFinder treats a failed query (null result or last_error) as a possible usage and an incomplete scan, so media-delete refuses without force. A refused wp_delete_attachment() is write_failed only when the attachment is intact, otherwise partial_write. media-update: re-read hint on write_failed, normalized ids in failures, documented lock resolution and kses on restore. 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:
@@ -102,14 +102,15 @@ final class Errors
|
||||
* A write failed and was rolled back completely.
|
||||
*
|
||||
* @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").
|
||||
*/
|
||||
public static function writeFailed(string $reason, array $details = []): WP_Error
|
||||
public static function writeFailed(string $reason, array $details = [], ?string $hint = null): WP_Error
|
||||
{
|
||||
return self::make(
|
||||
'write_failed',
|
||||
trim('Speichern fehlgeschlagen: ' . $reason) . ' Nichts wurde gespeichert.',
|
||||
'Eingaben prüfen, ggf. korrigieren und erneut versuchen; tritt der Fehler wieder auf, den Administrator '
|
||||
. 'informieren (Details im PHP-Error-Log der Website).',
|
||||
$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,
|
||||
$details
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user