diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index bf37ffdbdbb..078c237e32f 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -136,6 +136,11 @@ abstract class moodle_database { */ private $inorequaluniqueindex = 1; + /** + * @var boolean variable use to temporarily disable logging. + */ + protected $skiplogging = false; + /** * Constructor - Instantiates the database, specifying if it's external (connect to other systems) or not (Moodle DB). * Note that this affects the decision of whether prefix checks must be performed or not. @@ -487,6 +492,11 @@ abstract class moodle_database { * @return void */ public function query_log($error=false) { + // Logging disabled by the driver. + if ($this->skiplogging) { + return; + } + $logall = !empty($this->dboptions['logall']); $logslow = !empty($this->dboptions['logslow']) ? $this->dboptions['logslow'] : false; $logerrors = !empty($this->dboptions['logerrors']); @@ -525,6 +535,20 @@ abstract class moodle_database { } } + /** + * Disable logging temporarily. + */ + protected function query_log_prevent() { + $this->skiplogging = true; + } + + /** + * Restore old logging behavior. + */ + protected function query_log_allow() { + $this->skiplogging = false; + } + /** * Returns the time elapsed since the query started. * @return float Seconds with microseconds