]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
fix(ERP-251): replace file_put_contents with Yii logging in DataBuhController
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Mon, 2 Mar 2026 15:14:27 +0000 (18:14 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Mon, 2 Mar 2026 15:14:27 +0000 (18:14 +0300)
Hardcoded path /var/www/erp24/api2/json_buh does not exist on deploy
server (/var/www/erp24_deploy/), causing file_put_contents errors.
Replace debug file dumps with Yii::info/Yii::error under 'buh.upload'
category. Request data is already persisted via ApiCronBuh model.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
erp24/api2/controllers/DataBuhController.php

index 315595973e3f27ddaf98f05187eaeab7f6d5aac4..4f1120714908df3d773c3137b6eca879bbae6cf1 100644 (file)
@@ -12,11 +12,7 @@ use yii_app\services\MotivationServiceBuh;
 
 class DataBuhController extends BaseController
 {
-    const OUT_DIR =
-//        DIR . "/../json";
-        "/var/www/erp24/api2/json_buh";
-
-//          "/var/www/www-root/data/www/api.bazacvetov24.ru/data/json";
+    private const LOG_CATEGORY = 'buh.upload';
 
     public function actionRequest($inn)
     {
@@ -94,7 +90,7 @@ class DataBuhController extends BaseController
             $fl = time();
         }
 
-        file_put_contents(self::OUT_DIR . '/upload_' . $fl . '.json', PHP_EOL . $request);
+        Yii::info("upload_{$fl}: " . mb_substr($request, 0, 500), self::LOG_CATEGORY);
 
         try {
 
@@ -110,7 +106,7 @@ class DataBuhController extends BaseController
 
             }
         } catch (Exception $e) {
-            file_put_contents(self::OUT_DIR . '/error_buh_upload.txt', PHP_EOL . 'result empty', FILE_APPEND);
+            Yii::error('error_buh_upload: ' . $e->getMessage(), self::LOG_CATEGORY);
         }
 
         return $this->asJson(['request_id' => $requestId, 'response' => true]);