From: Aleksey Filippov Date: Mon, 2 Mar 2026 08:16:52 +0000 (+0300) Subject: fix(ERP-250): add null check for WriteOffsErp model in actionUpdate X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=f10428e28ac2f62ffe3f6a8f9fa8b9e571a3393d;p=erp24_rep%2Fyii-erp24%2F.git fix(ERP-250): add null check for WriteOffsErp model in actionUpdate $query->one() can return null when the record is deleted, sent to 1C, or the user has no store access. Without the check, line 1076 crashes with "Call to a member function getRelation() on null". Now throws NotFoundHttpException (404) as documented in the PHPDoc. Co-Authored-By: Claude Opus 4.6 --- diff --git a/erp24/controllers/WriteOffsErpController.php b/erp24/controllers/WriteOffsErpController.php index 9904f6e6..e56bcab7 100644 --- a/erp24/controllers/WriteOffsErpController.php +++ b/erp24/controllers/WriteOffsErpController.php @@ -1072,6 +1072,9 @@ class WriteOffsErpController extends Controller $model = $query->one(); + if ($model === null) { + throw new NotFoundHttpException('Списание не найдено или недоступно.'); + } $modelWriteOffsProductsErps = ($model->getRelation('writeOffsProductsErps', false)); $model->writeOffsProductsErps = ArrayHelper::getValue($model->getRelatedRecords(), 'writeOffsProductsErps');