From 7557879d4afd922aca7db029f9fa1504a34213ed Mon Sep 17 00:00:00 2001 From: Tom Misilo <1446856+misilot@users.noreply.github.com> Date: Wed, 24 Mar 2021 13:40:43 -0500 Subject: [PATCH] Add support for overriding the Time and Memory Limits (#8389) This is similar to what exists for the LDAP Import, and adds support for setting th Import and Report max execution time and memory limits Co-authored-by: snipe --- app/Console/Commands/ObjectImportCommand.php | 4 ++-- app/Http/Controllers/ReportsController.php | 4 +++- app/Http/Requests/ItemImportRequest.php | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/ObjectImportCommand.php b/app/Console/Commands/ObjectImportCommand.php index 3325a0c65d..69c017d961 100644 --- a/app/Console/Commands/ObjectImportCommand.php +++ b/app/Console/Commands/ObjectImportCommand.php @@ -5,8 +5,8 @@ use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; -ini_set('max_execution_time', 600); //600 seconds = 10 minutes -ini_set('memory_limit', '500M'); +ini_set('max_execution_time', env('IMPORT_TIME_LIM', 600)); //600 seconds = 10 minutes +ini_set('memory_limit', env('IMPORT_MEM_LIM', '500M')); /** * Class ObjectImportCommand diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 4b85b1def6..5622bd3375 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -403,7 +403,9 @@ class ReportsController extends Controller */ public function postCustom(Request $request) { - ini_set('max_execution_time', 12000); + + + ini_set('max_execution_time', env('REPORT_TIME_LIM', 12000)); //12000 seconds = 200 minutes $this->authorize('reports.view'); diff --git a/app/Http/Requests/ItemImportRequest.php b/app/Http/Requests/ItemImportRequest.php index e48c82bd90..126a2288e5 100644 --- a/app/Http/Requests/ItemImportRequest.php +++ b/app/Http/Requests/ItemImportRequest.php @@ -32,8 +32,8 @@ class ItemImportRequest extends FormRequest public function import(Import $import) { - ini_set('max_execution_time', 600); //600 seconds = 10 minutes - ini_set('memory_limit', '500M'); + ini_set('max_execution_time', env('IMPORT_TIME_LIM', 600)); //600 seconds = 10 minutes + ini_set('memory_limit', env('IMPORT_MEM_LIM', '500M')); $filename = config('app.private_uploads') . '/imports/' . $import->file_path; $import->import_type = $this->input('import-type'); $class = title_case($import->import_type);