MDL-24684 backup - basic protection against time/memory limits
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 30 Jun 2011 01:37:30 +0000 (03:37 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 30 Jun 2011 01:37:30 +0000 (03:37 +0200)
backup/controller/backup_controller.class.php
backup/controller/restore_controller.class.php

index 9db2e3d..cd05481 100644 (file)
@@ -290,6 +290,9 @@ class backup_controller extends backup implements loggable {
      * @return void Throws and exception of completes
      */
     public function execute_plan() {
+        // Basic/initial prevention against time/memory limits
+        set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
+        raise_memory_limit(MEMORY_EXTRA);
         return $this->plan->execute();
     }
 
index 7cbdb58..f523df9 100644 (file)
@@ -296,6 +296,9 @@ class restore_controller extends backup implements loggable {
     }
 
     public function execute_plan() {
+        // Basic/initial prevention against time/memory limits
+        set_time_limit(1 * 60 * 60); // 1 hour for 1 course initially granted
+        raise_memory_limit(MEMORY_EXTRA);
         return $this->plan->execute();
     }
 
@@ -383,6 +386,10 @@ class restore_controller extends backup implements loggable {
         global $CFG;
         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
+        raise_memory_limit(MEMORY_EXTRA);
+
         if ($this->status != backup::STATUS_REQUIRE_CONV) {
             throw new restore_controller_exception('cannot_convert_not_required_status');
         }