Move memory/execution time limits into a function see BT#14425

pull/2573/head
Julio 7 years ago
parent 8a720b8e51
commit bdd8c78886
  1. 6
      main/admin/special_exports.php
  2. 7
      main/coursecopy/copy_course.php
  3. 6
      main/coursecopy/copy_course_session.php
  4. 6
      main/coursecopy/copy_course_session_selected.php
  5. 7
      main/coursecopy/create_backup.php
  6. 6
      main/coursecopy/import_backup.php
  7. 6
      main/coursecopy/import_moodle.php
  8. 3
      main/gradebook/gradebook_display_certificate.php
  9. 4
      main/gradebook/gradebook_display_summary.php
  10. 12
      main/inc/lib/api.lib.php
  11. 6
      main/inc/lib/sessionmanager.lib.php
  12. 7
      main/lp/learnpath.class.php

@ -25,11 +25,7 @@ $nameTools = get_lang('SpecialExports');
$export = ''; $export = '';
$querypath = ''; $querypath = '';
// include additional libraries api_set_more_memory_and_time_limits();
if (function_exists('ini_set')) {
api_set_memory_limit('256M');
ini_set('max_execution_time', 0);
}
// Displaying the header // Displaying the header
Display::display_header($nameTools); Display::display_header($nameTools);

@ -20,12 +20,7 @@ if (!api_is_allowed_to_edit()) {
api_not_allowed(true); api_not_allowed(true);
} }
// Remove memory and time limits as much as possible as this might be a long process... api_set_more_memory_and_time_limits();
if (function_exists('ini_set')) {
api_set_memory_limit('256M');
ini_set('max_execution_time', 1800);
//ini_set('post_max_size', "512M");
}
// Breadcrumbs // Breadcrumbs
$interbreadcrumb[] = [ $interbreadcrumb[] = [

@ -28,11 +28,7 @@ if (!api_is_allowed_to_edit() && !api_is_session_admin()) {
api_not_allowed(true); api_not_allowed(true);
} }
// Remove memory and time limits as much as possible as this might be a long process... api_set_more_memory_and_time_limits();
if (function_exists('ini_set')) {
api_set_memory_limit('256M');
ini_set('max_execution_time', 1800);
}
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;

@ -41,11 +41,7 @@ if (empty($courseCode) || empty($sessionId)) {
api_not_allowed(true); api_not_allowed(true);
} }
// Remove memory and time limits as much as possible as this might be a long process... api_set_more_memory_and_time_limits();
if (function_exists('ini_set')) {
ini_set('memory_limit', '256M');
ini_set('max_execution_time', 1800);
}
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
$nameTools = get_lang('CopyCourse'); $nameTools = get_lang('CopyCourse');

@ -16,7 +16,6 @@ require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_COURSE_MAINTENANCE; $current_course_tool = TOOL_COURSE_MAINTENANCE;
api_protect_course_script(true); api_protect_course_script(true);
api_check_archive_dir(); api_check_archive_dir();
// Check access rights (only teachers are allowed here) // Check access rights (only teachers are allowed here)
@ -24,11 +23,7 @@ if (!api_is_allowed_to_edit()) {
api_not_allowed(true); api_not_allowed(true);
} }
// Remove memory and time limits as much as possible as this might be a long process... api_set_more_memory_and_time_limits();
if (function_exists('ini_set')) {
api_set_memory_limit('256M');
ini_set('max_execution_time', 1800);
}
// Section for the tabs // Section for the tabs
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;

@ -22,11 +22,7 @@ if (!api_is_allowed_to_edit()) {
api_not_allowed(true); api_not_allowed(true);
} }
// Remove memory and time limits as much as possible as this might be a long process... api_set_more_memory_and_time_limits();
if (function_exists('ini_set')) {
api_set_memory_limit('256M');
ini_set('max_execution_time', 1800);
}
// Section for the tabs // Section for the tabs
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;

@ -18,11 +18,7 @@ if (!api_is_allowed_to_edit()) {
api_not_allowed(true); api_not_allowed(true);
} }
// Remove memory and time limits as much as possible as this might be a long process... api_set_more_memory_and_time_limits();
if (function_exists('ini_set')) {
api_set_memory_limit('256M');
ini_set('max_execution_time', 1800);
}
// Section for the tabs // Section for the tabs
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;

@ -13,8 +13,7 @@ if (!api_is_student_boss()) {
api_protect_course_script(true); api_protect_course_script(true);
} }
set_time_limit(0); api_set_more_memory_and_time_limits();
ini_set('max_execution_time', 0);
//extra javascript functions for in html head: //extra javascript functions for in html head:
$htmlHeadXtra[] = "<script> $htmlHeadXtra[] = "<script>

@ -12,10 +12,8 @@ require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_GRADEBOOK; $current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script(); api_protect_course_script();
set_time_limit(0); api_set_more_memory_and_time_limits();
ini_set('max_execution_time', 0);
api_block_anonymous_users(); api_block_anonymous_users();
GradebookUtils::block_students(); GradebookUtils::block_students();
$cat_id = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : null; $cat_id = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : null;

@ -7866,6 +7866,18 @@ function api_set_settings_and_plugins()
$_SESSION['_plugins'] = $_plugins; $_SESSION['_plugins'] = $_plugins;
} }
/**
* Modify default memory_limit and max_execution_time limits
* Needed when processing long tasks
*/
function api_set_more_memory_and_time_limits()
{
if (function_exists('ini_set')) {
api_set_memory_limit('256M');
ini_set('max_execution_time', 1800);
}
}
/** /**
* Tries to set memory limit, if authorized and new limit is higher than current. * Tries to set memory limit, if authorized and new limit is higher than current.
* *

@ -4422,11 +4422,7 @@ class SessionManager
// We will copy the current courses of the session to new courses // We will copy the current courses of the session to new courses
if (!empty($short_courses)) { if (!empty($short_courses)) {
if ($create_new_courses) { if ($create_new_courses) {
//Just in case api_set_more_memory_and_time_limits();
if (function_exists('ini_set')) {
api_set_memory_limit('256M');
ini_set('max_execution_time', 0);
}
$params = []; $params = [];
$params['skip_lp_dates'] = true; $params['skip_lp_dates'] = true;

@ -10482,12 +10482,7 @@ class learnpath
{ {
$_course = api_get_course_info(); $_course = api_get_course_info();
$course_id = $_course['real_id']; $course_id = $_course['real_id'];
api_set_more_memory_and_time_limits();
// Remove memory and time limits as much as possible as this might be a long process...
if (function_exists('ini_set')) {
api_set_memory_limit('256M');
ini_set('max_execution_time', 600);
}
// Create the zip handler (this will remain available throughout the method). // Create the zip handler (this will remain available throughout the method).
$archive_path = api_get_path(SYS_ARCHIVE_PATH); $archive_path = api_get_path(SYS_ARCHIVE_PATH);

Loading…
Cancel
Save