fix: menu rollback survives a throwing delete of a new item (S50)
MenuWriter::fail guards wp_delete_post for created items: the touched items are still restored and the client gets partial_write (with previous_items) instead of internal_error. 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:
@@ -431,8 +431,13 @@ class MenuWriter
|
||||
{
|
||||
$problems = [];
|
||||
foreach ($this->created as $itemId) {
|
||||
if (! wp_delete_post($itemId, true) instanceof WP_Post) {
|
||||
$problems[] = sprintf('created item %d not deleted', $itemId);
|
||||
// Ruling S50: a throwing delete (e.g. a hook) must not stop the rest of the rollback.
|
||||
try {
|
||||
if (! wp_delete_post($itemId, true) instanceof WP_Post) {
|
||||
$problems[] = sprintf('created item %d not deleted', $itemId);
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
$problems[] = sprintf('created item %d not deleted: %s', $itemId, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user