From 039564a50799e31e2048c2aed2da888cfd5dd628 Mon Sep 17 00:00:00 2001 From: Nigel Cunningham Date: Wed, 30 Jul 2014 14:22:15 +1000 Subject: [PATCH] (Bug785472) Remove unneeded raise_memory_limit calls On the basis of my profiling and testing over the last week, all of the scripts affected by this patch don't need their raise_memory_limit calls. Ensure_sanity currently sets the memory limit to 128MB, which has been seen to be more than sufficient for each of these use cases. Tests have involved at least 1000 records being imported in each case, and sometimes as many as 20,000. I would have liked to have tested with some really full profiles (eg lots of pictures and content), but am satisfied that there's enough margin to cover those cases. In any case, such files are often handled using external apps and therefore won't be counted toward PHP's memory use anyway. Finally, the limit can easily be increased by the user if necessary for a particular case. Change-Id: Ifecc83fd47da51268bae6cbd6960735eb91f9403 Signed-off-by: Nigel Cunningham --- htdocs/admin/groups/uploadcsv.php | 1 - htdocs/admin/groups/uploadmemberscsv.php | 1 - htdocs/admin/upgrade.php | 2 -- htdocs/admin/users/bulkimport.php | 2 -- htdocs/admin/users/uploadcsv.php | 1 - htdocs/import/index.php | 3 --- htdocs/lib/cron.php | 1 - htdocs/lib/csvfile.php | 1 - 8 files changed, 12 deletions(-) diff --git a/htdocs/admin/groups/uploadcsv.php b/htdocs/admin/groups/uploadcsv.php index a27540b223..13da141813 100644 --- a/htdocs/admin/groups/uploadcsv.php +++ b/htdocs/admin/groups/uploadcsv.php @@ -18,7 +18,6 @@ require_once('pieforms/pieform.php'); require_once(get_config('libroot') . 'group.php'); require_once(get_config('libroot') . 'institution.php'); safe_require('artefact', 'internal'); -raise_memory_limit("512M"); // Turn on autodetecting of line endings, so mac newlines (\r) will work ini_set('auto_detect_line_endings', 1); diff --git a/htdocs/admin/groups/uploadmemberscsv.php b/htdocs/admin/groups/uploadmemberscsv.php index d18acf4e6f..0d21b31bcf 100644 --- a/htdocs/admin/groups/uploadmemberscsv.php +++ b/htdocs/admin/groups/uploadmemberscsv.php @@ -18,7 +18,6 @@ require_once('pieforms/pieform.php'); require_once(get_config('libroot') . 'group.php'); require_once(get_config('libroot') . 'institution.php'); safe_require('artefact', 'internal'); -raise_memory_limit("512M"); // Turn on autodetecting of line endings, so mac newlines (\r) will work ini_set('auto_detect_line_endings', 1); diff --git a/htdocs/admin/upgrade.php b/htdocs/admin/upgrade.php index ac685a8d7e..166ed32148 100644 --- a/htdocs/admin/upgrade.php +++ b/htdocs/admin/upgrade.php @@ -122,8 +122,6 @@ $localsuccess = json_encode(get_string('localdatasuccess', 'admin')); // Check if Mahara is being installed. An extra hook is required to insert core // data if so. if (!empty($upgrades['core']->install)) { - raise_time_limit(120); - raise_memory_limit('256M'); $upgrades['firstcoredata'] = true; $upgrades['localpreinst'] = true; $upgrades['lastcoredata'] = true; diff --git a/htdocs/admin/users/bulkimport.php b/htdocs/admin/users/bulkimport.php index df2942a044..7c81bd4d35 100644 --- a/htdocs/admin/users/bulkimport.php +++ b/htdocs/admin/users/bulkimport.php @@ -17,8 +17,6 @@ require_once('institution.php'); require_once(get_config('docroot') . '/lib/htmloutput.php'); safe_require('artefact', 'internal'); safe_require('artefact', 'file'); -raise_memory_limit('1024M'); -set_time_limit(300); // 5 minutes define('TITLE', get_string('bulkleap2aimport', 'admin')); diff --git a/htdocs/admin/users/uploadcsv.php b/htdocs/admin/users/uploadcsv.php index 6fe523e9b7..fff2c32cd8 100644 --- a/htdocs/admin/users/uploadcsv.php +++ b/htdocs/admin/users/uploadcsv.php @@ -18,7 +18,6 @@ require_once('pieforms/pieform.php'); require_once('institution.php'); require_once('phpmailer/class.phpmailer.php'); safe_require('artefact', 'internal'); -raise_memory_limit("512M"); // Turn on autodetecting of line endings, so mac newlines (\r) will work ini_set('auto_detect_line_endings', 1); diff --git a/htdocs/import/index.php b/htdocs/import/index.php index df43f9c52d..d1016f4d43 100644 --- a/htdocs/import/index.php +++ b/htdocs/import/index.php @@ -37,9 +37,6 @@ define('SECTION_PLUGINNAME', 'import'); define('SECTION_PAGE', 'index'); -//TODO: Optimize! -raise_memory_limit("512M"); - define('PRINTUPLOADFORM_ACT', 0); define('PRINTIMPORTITEMSFORM_ACT', 1); define('DOIMPORT_ACT', 2); diff --git a/htdocs/lib/cron.php b/htdocs/lib/cron.php index bb5d794479..13717b9a8c 100644 --- a/htdocs/lib/cron.php +++ b/htdocs/lib/cron.php @@ -28,7 +28,6 @@ $fake = isset($argv[1]); $start = $fake ? strtotime($argv[1]) : $realstart; log_info('---------- cron running ' . date('r', $start) . ' ----------'); -raise_memory_limit('128M'); if (!is_writable(get_config('dataroot'))) { log_warn("Unable to write to dataroot directory."); diff --git a/htdocs/lib/csvfile.php b/htdocs/lib/csvfile.php index 249b693b24..7358f1156f 100644 --- a/htdocs/lib/csvfile.php +++ b/htdocs/lib/csvfile.php @@ -10,7 +10,6 @@ */ defined('INTERNAL') || die(); -raise_memory_limit("512M"); define('MAX_LINE_LENGTH', 1024); -- GitLab