Avoid setting memory_limit to lower value than the one already configured (#215)

Some scripts are setting the memory_limit PHP option : setup, csvimport and XLSX export. This was done to avoid crashing when dealing with such large amount of data.
But sometimes we were setting the value without any prior check, so we could actually lower the memory_limit value :/

Now this memory_limit change is done using \utils::SetMinMemoryLimit, which will call ini_set if and only if the current value is lower than the one to be set.

Setup calls (setup/ajax.dataloader.php and webservices/backoffice.dataloader.php) were left as is as they weren't subject to this bug, and also they are more complex (logging done on each case).
This commit is contained in:
BGdu38
2021-05-25 12:03:19 +02:00
committed by GitHub
parent 81822efa0f
commit c2f5cafaf3
4 changed files with 104 additions and 41 deletions

View File

@@ -17,21 +17,24 @@
* You should have received a copy of the GNU Affero General Public License
*/
try
{
ini_set('memory_limit', '256M');
try {
require_once('../approot.inc.php');
require_once(APPROOT.'/application/application.inc.php');
require_once(APPROOT.'/application/itopwebpage.class.inc.php');
require_once(APPROOT.'/application/ajaxwebpage.class.inc.php');
require_once(APPROOT.'/application/startup.inc.php');
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
if (utils::SetMinMemoryLimit('256M') === false) {
IssueLog::Warning('csvimport : cannot set minimum memory_limit !');
}
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$iStep = utils::ReadParam('step', 1);
$oPage = new iTopWebPage(Dict::S('UI:Title:BulkImport'));
$oPage->SetBreadCrumbEntry('ui-tool-bulkimport', Dict::S('Menu:CSVImportMenu'), Dict::S('UI:Title:BulkImport+'), '', utils::GetAbsoluteUrlAppRoot().'images/wrench.png');
@@ -1542,4 +1545,3 @@ catch(Exception $e)
IssueLog::Error($e->getMessage());
}
}
?>