Pārlūkot izejas kodu

Internal: Add error checking before writing web/build/main.language.js

Yannick Warnier 6 gadi atpakaļ
vecāks
revīzija
7a6691647c
1 mainītis faili ar 7 papildinājumiem un 1 dzēšanām
  1. 7 1
      main/inc/global.inc.php

+ 7 - 1
main/inc/global.inc.php

@@ -653,5 +653,11 @@ if (!file_exists($file) || api_get_setting('server_type') === 'test') {
     // Force use of default to avoid problems
     $tpl = 'default/layout/main.js.tpl';
     $contents = $template->fetch($tpl);
-    file_put_contents($file, $contents);
+    if (PHP_SAPI === 'cli') {
+        // In CLI mode, the '.$file.' file does not get written on disk to avoid permissions issues.
+    } elseif (!is_writable($file)) {
+        error_log('Error: '.$file.' could not be written. Please check permissions. The web server must be able to write there.');
+    } else {
+        @file_put_contents($file, $contents);
+    }
 }