瀏覽代碼

Fix global memory limit set in constructor

Instead, set it when running.

Having the set in the constructor was causing memory_limit to be changed
for "artisan queue:work" processes.
Dan Church 3 年之前
父節點
當前提交
c685e3e9f4
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      app/Console/Commands/ImportCities.php

+ 3 - 1
app/Console/Commands/ImportCities.php

@@ -65,7 +65,6 @@ class ImportCities extends Command
     public function __construct()
     {
         parent::__construct();
-        ini_set('memory_limit', '256M');
     }
 
     /**
@@ -75,6 +74,8 @@ class ImportCities extends Command
      */
     public function handle()
     {
+        $old_memory_limit = ini_get('memory_limit');
+        ini_set('memory_limit', '256M');
         $path = storage_path('app/cities.json');
 
         if(hash_file('sha512', $path) !== self::CHECKSUM) {
@@ -136,6 +137,7 @@ class ImportCities extends Command
         $this->line('');
         $this->info('Successfully imported ' . $cityCount . ' entries!');
         $this->line('');
+        ini_set('memory_limit', $old_memory_limit);
         return;
     }