From c9e232f2ffb43bc475aa41601546836216ab0e24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2021 18:00:27 +0100 Subject: [PATCH] Try to fix import/export timeout by dynamic increase --- htdocs/admin/system/phpinfo.php | 2 +- htdocs/exports/export.php | 7 ++++--- htdocs/imports/import.php | 8 ++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index a7bce7a3025..b6160d2d2e9 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -288,7 +288,7 @@ function getResultColumn($name, array $activated, array $loaded, array $function $html .= ' '.$langs->trans("PHPSupport", $name); } } else { - if (strtolower($name) == 'xdebug') $html .= yn(0); + if (strtolower($name) == 'xdebug') $html .= yn(0).' - '; else $html .= img_warning($langs->trans("ModuleActivated", "xdebug")); if (in_array(strtolower($name), $loaded)) { $html .= ' '.$langs->trans("Loaded").' - '; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index c9db970cd0b..c80ee4d248f 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -270,11 +270,12 @@ if ($step == 1 || $action == 'cleanselect') if ($action == 'builddoc') { - $max_execution_time_for_export = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME); // 5mn if not defined + $max_execution_time_for_importexport = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME); // 5mn if not defined $max_time = @ini_get("max_execution_time"); - if ($max_time && $max_time < $max_execution_time_for_export) + if ($max_time && $max_time < $max_execution_time_for_importexport) { - @ini_set("max_execution_time", $max_execution_time_for_export); // This work only if safe mode is off. also web servers has timeout of 300 + dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically."); + @ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300 } // Build export file diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index fbb17e15280..8814fa584fa 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1518,6 +1518,14 @@ if ($step == 5 && $datatoimport) } print ''; } else { + $max_execution_time_for_importexport = (empty($conf->global->IMPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->IMPORT_MAX_EXECUTION_TIME); // 5mn if not defined + $max_time = @ini_get("max_execution_time"); + if ($max_time && $max_time < $max_execution_time_for_importexport) + { + dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically."); + @ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300 + } + // Launch import $arrayoferrors = array(); $arrayofwarnings = array();