From 53cdd8771dd6716d7c47f7483706c4862c8f3f74 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 17 May 2026 20:09:17 +0800 Subject: [PATCH] Harden order history status updates --- common/models/OrderHistory.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/models/OrderHistory.php b/common/models/OrderHistory.php index 2e3bddb7e..d66bfa8f9 100644 --- a/common/models/OrderHistory.php +++ b/common/models/OrderHistory.php @@ -128,12 +128,16 @@ public static function addOrderHistory($order_uuid, $status, $note) { ->andWhere(['order_uuid' => $order_uuid]) ->one(); + if (!$order) { + Yii::error('Order not found while adding order history: ' . $order_uuid); + throw new \yii\base\Exception('Order not found while adding order history.'); + } + $order->scenario = "updateStatus"; $order->order_status = $status; if (!$order->save()) { Yii::error($order->errors); - print_r($order->errors); - die(); + throw new \yii\base\Exception('Unable to update order status while adding order history.'); } $model = new OrderHistory(); @@ -142,8 +146,7 @@ public static function addOrderHistory($order_uuid, $status, $note) { $model->comment = $note; if (!$model->save()) { Yii::error($model->errors); - print_r($model->errors); - die(); + throw new \yii\base\Exception('Unable to save order history.'); } }