echo $OUTPUT->header();
// This may take a long time.
- set_time_limit(0);
+ core_php_time_limit::raise();
// Disable plugin to prevent concurrent cron execution.
unset($enabled[$enrol]);
$progressbar->create(); // prints the HTML code of the progress bar
// we may need a bit of extra execution time and memory here
- @set_time_limit(HOURSECS);
+ core_php_time_limit::raise(HOURSECS);
raise_memory_limit(MEMORY_EXTRA);
tool_customlang_utils::checkout($lng, $progressbar);
* @return does not return, calls die()
*/
function tool_dbtransfer_export_xml_database($description, $mdb) {
- @set_time_limit(0);
+ core_php_time_limit::raise();
\core\session\manager::write_close(); // Release session.
* @return void
*/
function tool_dbtransfer_transfer_database(moodle_database $sourcedb, moodle_database $targetdb, progress_trace $feedback = null) {
- @set_time_limit(0);
+ core_php_time_limit::raise();
\core\session\manager::write_close(); // Release session.
// Update time limit so PHP doesn't time out.
if (!CLI_SCRIPT) {
- set_time_limit(120);
+ core_php_time_limit::raise(120);
}
}
echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess');
- set_time_limit(0);
+ core_php_time_limit::raise();
foreach ($rs as $table) {
$DB->set_debug(true);
$notice_error = array();
if (($mode == INSTALLATION_OF_SELECTED_LANG) and confirm_sesskey() and !empty($pack)) {
- set_time_limit(0);
+ core_php_time_limit::raise();
make_temp_directory('');
make_upload_directory('lang');
}
if ($mode == UPDATE_ALL_LANG) {
- set_time_limit(0);
+ core_php_time_limit::raise();
$installer = new lang_installer();
/// Turn off time limits, sometimes upgrades can be slow.
-@set_time_limit(0);
+core_php_time_limit::raise();
echo '<strong>Progress:</strong>';
$i = 0;
error('Not available on production sites, sorry.');
}
-set_time_limit(60*30);
+core_php_time_limit::raise(60*30);
$oldcwd = getcwd();
$code = 0;
$errors = 0;
// We will most certainly need extra time and memory to process big files.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
// Loop over the CSV lines.
$tracker->start();
// We might need extra time and memory depending on the number of rows to preview.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
// Loop over the CSV lines.
$iid = optional_param('iid', '', PARAM_INT);
$previewrows = optional_param('previewrows', 10, PARAM_INT);
-@set_time_limit(60*60); // 1 hour should be enough
+core_php_time_limit::raise(60*60); // 1 hour should be enough
raise_memory_limit(MEMORY_HUGE);
require_login();
// Large files are likely to take their time and memory. Let PHP know
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
// Create a unique temporary directory, to process the zip file
*/
public function execute_plan() {
// Basic/initial prevention against time/memory limits
- set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
+ core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted
raise_memory_limit(MEMORY_EXTRA);
// If this is not a course backup, inform the plan we are not
// including all the activities for sure. This will affect any
public function execute_plan() {
// Basic/initial prevention against time/memory limits
- set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
+ core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted
raise_memory_limit(MEMORY_EXTRA);
// If this is not a course restore, inform the plan we are not
// including all the activities for sure. This will affect any
throw new restore_controller_exception('cannot_precheck_wrong_status', $this->status);
}
// Basic/initial prevention against time/memory limits
- set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
+ core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted
raise_memory_limit(MEMORY_EXTRA);
$this->precheck = restore_prechecks_helper::execute_prechecks($this, $droptemptablesafter);
if (!array_key_exists('errors', $this->precheck)) { // No errors, can be executed
require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php');
// Basic/initial prevention against time/memory limits
- set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
+ core_php_time_limit::raise(1 * 60 * 60); // 1 hour for 1 course initially granted
raise_memory_limit(MEMORY_EXTRA);
$this->progress->start_progress('Backup format conversion');
cron_trace_time_and_memory();
// This could take a while!
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
$nextstarttime = backup_cron_automated_helper::calculate_next_automated_backup($admin->timezone, $now);
mtrace(' ' . $rec->url . ' ', '');
// Fetch the rss feed, using standard simplepie caching
// so feeds will be renewed only if cache has expired
- @set_time_limit(60);
+ core_php_time_limit::raise(60);
$feed = new moodle_simplepie();
// set timeout for longer than normal to be agressive at
$updatecount = 0;
// Large calendars take a while...
- set_time_limit(300);
+ core_php_time_limit::raise(300);
// Mark all events in a subscription with a zero timestamp.
if (!empty($subscriptionid)) {
}
// We may need a lot of time here.
- @set_time_limit(0);
+ core_php_time_limit::raise();
$plugin = enrol_get_plugin('category');
}
// Unfortunately this may take a long time, this script can be interrupted without problems.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
$trace->output('Starting user enrolment synchronisation...');
}
// We may need a lot of memory here.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
$table = $this->get_config('remoteenroltable');
$trace->output('Starting course synchronisation...');
// We may need a lot of memory here.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
if (!$extdb = $this->db_init()) {
global $CFG, $DB;
// We may need more memory here.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
$filelocation = $this->get_config('location');
$fileisnew = false;
if ( file_exists($filename) ) {
- @set_time_limit(0);
+ core_php_time_limit::raise();
$starttime = time();
$this->log_line('----------------------------------------------------------------------');
}
// We may need a lot of memory here
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
// Get enrolments for each type of role.
$ldap_pagedresults = ldap_paged_results_supported($this->get_config('ldap_version'));
// we may need a lot of memory here
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
$oneidnumber = null;
}
// Unfortunately this may take a long time, execution can be interrupted safely here.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
$trace->output('Verifying manual enrolment expiration...');
}
// unfortunately this may take a long time, execution can be interrupted safely
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
if ($verbose) {
}
// Unfortunately this may take a long time, execution can be interrupted safely here.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
$trace->output('Verifying self-enrolments...');
// Large files are likely to take their time and memory. Let PHP know
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
// Use current (non-conflicting) time stamp.
// Large files are likely to take their time and memory. Let PHP know
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
$csvimport->init();
// Large files are likely to take their time and memory. Let PHP know
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
-@set_time_limit(0);
+core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
$text = download_file_content($url);
// Large files are likely to take their time and memory. Let PHP know
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
if ($text = $mform->get_file_content('userfile')) {
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-set_time_limit(0);
+core_php_time_limit::raise();
require_once '../../../config.php';
require_once $CFG->libdir . '/gradelib.php';
require_once '../../lib.php';
global $CFG, $DB, $OUTPUT;
// This may take a long time.
- @set_time_limit(0);
+ core_php_time_limit::raise();
// Recursively uninstall all subplugins first.
$subplugintypes = core_component::get_plugin_types_with_subplugins();
'block_instances', '');
// Turn off time limits, sometimes upgrades can be slow.
- @set_time_limit(0);
+ core_php_time_limit::raise();
if (!$tables = $DB->get_tables() ) { // No tables yet at all.
return false;
$awards = 0;
// Raise timelimit as this could take a while for big web sites.
- set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
// For site level badges, get all active site users who can earn this badge and haven't got it yet.
global $CFG, $DB;
// This may take a long time...
- set_time_limit(0);
+ \core_php_time_limit::raise();
$maxlifetime = $CFG->sessiontimeout;
set_debugging(DEBUG_DEVELOPER, true);
}
- set_time_limit(0);
+ core_php_time_limit::raise();
$starttime = microtime();
// Increase memory limit
mtrace("... used " . (microtime(1) - $pre_time) . " seconds");
}
// Reset possible changes by modules to time_limit. MDL-11597
- @set_time_limit(0);
+ core_php_time_limit::raise();
mtrace("done.");
}
}
$DB->set_field('block', 'lastcron', $timenow, array('id'=>$block->id));
}
// Reset possible changes by blocks to time_limit. MDL-11597
- @set_time_limit(0);
+ core_php_time_limit::raise();
mtrace('done.');
}
}
}
}
}
- @set_time_limit(0);
+ core_php_time_limit::raise();
} else {
mtrace('Next stats run after:'. userdate($timetocheck));
}
round(microtime(true) - $pre_time, 2) . " seconds)");
set_config('lastcron', time(), $component);
- @set_time_limit(0);
+ core_php_time_limit::raise();
}
if ($description) {
// Unfortunately this may take a long time, it should not be interrupted,
// otherwise users get duplicate notification.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_HUGE);
*/
public static function set_timeout($seconds=360) {
$seconds = ($seconds < 300) ? 300 : $seconds;
- set_time_limit($seconds);
+ core_php_time_limit::raise($seconds);
}
/**
fseek($handle, $ranges[0][1]);
while (!feof($handle) && $length > 0) {
- @set_time_limit(60*60); //reset time limit to 60 min - should be enough for 1 MB chunk
+ core_php_time_limit::raise(60*60); //reset time limit to 60 min - should be enough for 1 MB chunk
$buffer = fread($handle, ($chunksize < $length ? $chunksize : $length));
echo $buffer;
flush();
echo $range[0];
fseek($handle, $range[1]);
while (!feof($handle) && $length > 0) {
- @set_time_limit(60*60); //reset time limit to 60 min - should be enough for 1 MB chunk
+ core_php_time_limit::raise(60*60); //reset time limit to 60 min - should be enough for 1 MB chunk
$buffer = fread($handle, ($chunksize < $length ? $chunksize : $length));
echo $buffer;
flush();
$select = array('id'=>$courseid);
} else {
$select = array();
- @set_time_limit(0); // this could take a while! MDL-10954
+ core_php_time_limit::raise(); // this could take a while! MDL-10954
}
$rs = $DB->get_recordset("course", $select,'','id,'.join(',', course_modinfo::$cachedfields));
}
$days++;
- @set_time_limit($timeout - 200);
+ core_php_time_limit::raise($timeout - 200);
if ($days > 1) {
// move the lock
$weeks = 0;
while ($now > $nextstartweek) {
- @set_time_limit($timeout - 200);
+ core_php_time_limit::raise($timeout - 200);
$weeks++;
if ($weeks > 1) {
$months = 0;
while ($now > $nextstartmonth) {
- @set_time_limit($timeout - 200);
+ core_php_time_limit::raise($timeout - 200);
$months++;
if ($months > 1) {
}
function run_tests($function, $contexts, $numcalls, $basetime) {
- set_time_limit(120);
+ core_php_time_limit::raise(120);
$startime = microtime(true);
for ($j = 0; $j < $numcalls; $j++) {
$function($contexts[array_rand($contexts)]);
function populate_test_database($syscontext, $numcategories, $numcourses, $nummodules, $numoverrides, $numconfigs) {
global $DB, $OUTPUT;
- set_time_limit(600);
+ core_php_time_limit::raise(600);
$syscontext->id = $DB->insert_record('context', $syscontext);
// Category contexts.
if (CLI_SCRIPT) {
// there is no point in timing out of CLI scripts, admins can stop them if necessary
- set_time_limit(0);
+ core_php_time_limit::raise();
} else {
- set_time_limit($max_execution_time);
+ core_php_time_limit::raise($max_execution_time);
}
set_config('upgraderunning', $expected_end); // keep upgrade locked until this time
}
foreach ($plugs as $plug=>$fullplug) {
// Reset time so that it works when installing a large number of plugins
- set_time_limit(600);
+ core_php_time_limit::raise(600);
$component = clean_param($type.'_'.$plug, PARAM_COMPONENT); // standardised plugin name
// check plugin dir is valid name
make_writable_directory($CFG->dataroot.'/muc', true);
try {
- set_time_limit(600);
+ core_php_time_limit::raise(600);
print_upgrade_part_start('moodle', true, $verbose); // does not store upgrade running flag
$DB->get_manager()->install_from_xmldb_file("$CFG->libdir/db/install.xml");
// Pre-upgrade scripts for local hack workarounds.
$preupgradefile = "$CFG->dirroot/local/preupgrade.php";
if (file_exists($preupgradefile)) {
- set_time_limit(0);
+ core_php_time_limit::raise();
require($preupgradefile);
// Reset upgrade timeout to default.
upgrade_set_timeout();
// let's try to open a socket
$this->_error_log('open a socket connection');
$this->sock = fsockopen($this->_socket . $this->_server, $this->_port, $this->_errno, $this->_errstr, $this->_socket_timeout);
- set_time_limit(30);
+ core_php_time_limit::raise(30);
if (is_resource($this->sock)) {
socket_set_blocking($this->sock, true);
$this->_connection_closed = false;
raise_memory_limit(MEMORY_EXTRA);
$packer = get_file_packer('application/zip');
- @set_time_limit(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME);
+ core_php_time_limit::raise(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME);
return $packer->extract_to_storage($zipfile,
$contextid,
public function import_zip_files($assignment, $fileplugin) {
global $CFG, $PAGE, $DB;
- @set_time_limit(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME);
+ core_php_time_limit::raise(ASSIGNFEEDBACK_FILE_MAXFILEUNZIPTIME);
$packer = get_file_packer('application/zip');
$feedbackfilesupdated = 0;
return false;
}
- @set_time_limit(ASSIGN_MAX_UPGRADE_TIME_SECS);
+ core_php_time_limit::raise(ASSIGN_MAX_UPGRADE_TIME_SECS);
// Get the module details.
$oldmodule = $DB->get_record('modules', array('name'=>'assignment'), '*', MUST_EXIST);
die("Error: Cannot run with PHP safe_mode = On. Turn off safe_mode in php.ini.\n");
}
-@set_time_limit (0);
+core_php_time_limit::raise(0);
error_reporting(E_ALL);
function chat_empty_connection() {
// we are going to run for a long time
// avoid being terminated by php
-@set_time_limit(0);
+core_php_time_limit::raise();
$chat_sid = required_param('chat_sid', PARAM_ALPHANUM);
$chat_lasttime = optional_param('chat_lasttime', 0, PARAM_INT);
if ($thumbfile = $fs->get_file($this->context->id, 'mod_data', 'content', $content->id, '/', 'thumb_'.$content->content)) {
$thumbfile->delete();
}
- @set_time_limit(300);
+ core_php_time_limit::raise(300);
// Might be slow!
$this->update_thumbnail($content, $file);
}
// Large files are likely to take their time and memory. Let PHP know
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
- @set_time_limit(0);
+ core_php_time_limit::raise();
raise_memory_limit(MEMORY_EXTRA);
$iid = csv_import_reader::get_new_iid('moddata');
foreach ($users as $userto) {
- @set_time_limit(120); // terminate if processing of any account takes longer than 2 minutes
+ core_php_time_limit::raise(120); // terminate if processing of any account takes longer than 2 minutes
mtrace('Processing user '.$userto->id);
mtrace('Starting digest processing...');
- @set_time_limit(300); // terminate if not able to fetch all digests in 5 minutes
+ core_php_time_limit::raise(300); // terminate if not able to fetch all digests in 5 minutes
if (!isset($CFG->digestmailtimelast)) { // To catch the first time
set_config('digestmailtimelast', 0);
// Data collected, start sending out emails to each user
foreach ($userdiscussions as $userid => $thesediscussions) {
- @set_time_limit(120); // terminate if processing of any account takes longer than 2 minutes
+ core_php_time_limit::raise(120); // terminate if processing of any account takes longer than 2 minutes
cron_setup_user();
foreach ($thesediscussions as $discussionid) {
- @set_time_limit(120); // to be reset for each post
+ core_php_time_limit::raise(120); // to be reset for each post
$discussion = $discussions[$discussionid];
$forum = $forums[$discussion->forum];
protected function regrade_attempt($attempt, $dryrun = false, $slots = null) {
global $DB;
// Need more time for a quiz with many questions.
- set_time_limit(300);
+ core_php_time_limit::raise(300);
$transaction = $DB->start_delegated_transaction();
* @return array containing two arrays calculated[] and calculated_for_subquestion[].
*/
public function calculate($qubaids) {
- set_time_limit(0);
+ \core_php_time_limit::raise();
list($lateststeps, $summarks, $summarksavg) = $this->get_latest_steps($qubaids);
}
protected function prevent_timeout() {
- set_time_limit(300);
+ core_php_time_limit::raise(300);
if ($this->doingbackup) {
return;
}
global $USER, $CFG, $DB, $OUTPUT;
// reset the timer in case file upload was slow
- set_time_limit(0);
+ core_php_time_limit::raise();
// STAGE 1: Parse the file
echo $OUTPUT->notification(get_string('parsingquestions', 'question'), 'notifysuccess');
foreach ($questions as $question) { // Process and store each question
// reset the php timeout
- set_time_limit(0);
+ core_php_time_limit::raise();
// check for category modifiers
if ($question->qtype == 'category') {
// we may need a bit more memory and this may take a long time to process
raise_memory_limit(MEMORY_EXTRA);
-@set_time_limit(0);
+core_php_time_limit::raise();
// Print the header.
admin_externalpage_setup('reportsecurity', '', null, '', array('pagelayout'=>'report'));
require_once($CFG->libdir.'/filelib.php');
require_once('lib.php');
/// Wait as long as it takes for this script to finish
-set_time_limit(0);
+core_php_time_limit::raise();
require_sesskey();
require_login();
$maxbytes = get_user_max_upload_file_size($context, $CFG->maxbytes, $coursemaxbytes, $maxbytes);
// Wait as long as it takes for this script to finish
-set_time_limit(0);
+core_php_time_limit::raise();
// These actions all occur on the currently active repository instance
switch ($action) {
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
/// Wait as long as it takes for this script to finish
-set_time_limit(0);
+core_php_time_limit::raise();
/// Get repository instance information
$sql = 'SELECT i.name, i.typeid, r.type, i.contextid FROM {repository} r, {repository_instances} i '.