From c685e3e9f42ee8dcd3d54827e461d1e56f906a92 Mon Sep 17 00:00:00 2001 From: Dan Church Date: Mon, 27 Sep 2021 14:57:18 -0500 Subject: [PATCH] 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. --- app/Console/Commands/ImportCities.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/ImportCities.php b/app/Console/Commands/ImportCities.php index 2fd93db99..1056f5ce2 100644 --- a/app/Console/Commands/ImportCities.php +++ b/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; }