From aece4d8f3bb129df6f8ef6abdf3a187ad6d2ead6 Mon Sep 17 00:00:00 2001 From: Ivan Bochkarev Date: Thu, 16 Jul 2026 00:55:44 +0600 Subject: [PATCH] fix(order): return error when status save fails (#376) OrderStatusService::change no longer returns true after a failed msOrder::save(); callers get ms3_err_unknown instead of a false success. --- .../src/Services/Order/OrderStatusService.php | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/core/components/minishop3/src/Services/Order/OrderStatusService.php b/core/components/minishop3/src/Services/Order/OrderStatusService.php index eea6e370..3307fca1 100644 --- a/core/components/minishop3/src/Services/Order/OrderStatusService.php +++ b/core/components/minishop3/src/Services/Order/OrderStatusService.php @@ -146,25 +146,27 @@ public function change(int $orderId, int $statusId, bool $skipNotifications = fa $msOrder->set('status_id', $statusId); - if ($msOrder->save()) { - $this->orderLog->add($msOrder->get('id'), $statusId, 'status'); - - $response = $this->ms3->utils->invokeEvent('msOnChangeOrderStatus', [ - 'msOrder' => $msOrder, - 'old_status' => $oldStatus?->get('id'), - 'status' => $statusId, - ]); - if (!$response['success']) { - return $response['message']; - } + if (!$msOrder->save()) { + return $this->modx->lexicon('ms3_err_unknown'); + } - // Send notifications via NotificationManager (unless skipped) - // Use output buffering to prevent any stray output from Fenom/pdoTools - if (!$skipNotifications) { - ob_start(); - $this->sendNotifications($msOrder, $status, $oldStatus); - ob_end_clean(); - } + $this->orderLog->add($msOrder->get('id'), $statusId, 'status'); + + $response = $this->ms3->utils->invokeEvent('msOnChangeOrderStatus', [ + 'msOrder' => $msOrder, + 'old_status' => $oldStatus?->get('id'), + 'status' => $statusId, + ]); + if (!$response['success']) { + return $response['message']; + } + + // Send notifications via NotificationManager (unless skipped) + // Use output buffering to prevent any stray output from Fenom/pdoTools + if (!$skipNotifications) { + ob_start(); + $this->sendNotifications($msOrder, $status, $oldStatus); + ob_end_clean(); } return true;