mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-57192-master' of git://github.com/ankitagarwal/moodle
This commit is contained in:
commit
41af8a5f90
@ -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
|
||||
|
@ -183,6 +183,9 @@ class mssql_native_moodle_database extends moodle_database {
|
||||
throw new dml_connection_exception($dberr);
|
||||
}
|
||||
|
||||
// Disable logging until we are fully setup.
|
||||
$this->query_log_prevent();
|
||||
|
||||
// already connected, select database and set some env. variables
|
||||
$this->query_start("--mssql_select_db", null, SQL_QUERY_AUX);
|
||||
$result = mssql_select_db($this->dbname, $this->mssql);
|
||||
@ -238,6 +241,9 @@ class mssql_native_moodle_database extends moodle_database {
|
||||
// Fetch/offset is supported staring from SQL Server 2012.
|
||||
$this->supportsoffsetfetch = $serverinfo['version'] > '11';
|
||||
|
||||
// We can enable logging now.
|
||||
$this->query_log_allow();
|
||||
|
||||
// Connection stabilised and configured, going to instantiate the temptables controller
|
||||
$this->temptables = new mssql_native_moodle_temptables($this);
|
||||
|
||||
|
@ -449,6 +449,9 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||
throw new dml_connection_exception($dberr);
|
||||
}
|
||||
|
||||
// Disable logging until we are fully setup.
|
||||
$this->query_log_prevent();
|
||||
|
||||
$this->query_start("--set_charset()", null, SQL_QUERY_AUX);
|
||||
$this->mysqli->set_charset('utf8');
|
||||
$this->query_end(true);
|
||||
@ -466,6 +469,9 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||
$this->query_end($result);
|
||||
}
|
||||
|
||||
// We can enable logging now.
|
||||
$this->query_log_allow();
|
||||
|
||||
// Connection stabilised and configured, going to instantiate the temptables controller
|
||||
$this->temptables = new mysqli_native_moodle_temptables($this);
|
||||
|
||||
|
@ -189,6 +189,9 @@ class oci_native_moodle_database extends moodle_database {
|
||||
throw new dml_connection_exception($dberr);
|
||||
}
|
||||
|
||||
// Disable logging until we are fully setup.
|
||||
$this->query_log_prevent();
|
||||
|
||||
// Make sure moodle package is installed - now required.
|
||||
if (!$this->oci_package_installed()) {
|
||||
try {
|
||||
@ -216,6 +219,9 @@ class oci_native_moodle_database extends moodle_database {
|
||||
//note: do not send "ALTER SESSION SET NLS_NUMERIC_CHARACTERS='.,'" !
|
||||
// instead fix our PHP code to convert "," to "." properly!
|
||||
|
||||
// We can enable logging now.
|
||||
$this->query_log_allow();
|
||||
|
||||
// Connection stabilised and configured, going to instantiate the temptables controller
|
||||
$this->temptables = new oci_native_moodle_temptables($this, $this->unique_session_id);
|
||||
|
||||
|
@ -200,6 +200,9 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
||||
throw new dml_connection_exception($dberr);
|
||||
}
|
||||
|
||||
// Disable logging until we are fully setup.
|
||||
$this->query_log_prevent();
|
||||
|
||||
// Allow quoted identifiers
|
||||
$sql = "SET QUOTED_IDENTIFIER ON";
|
||||
$this->query_start($sql, null, SQL_QUERY_AUX);
|
||||
@ -246,6 +249,9 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
||||
// Fetch/offset is supported staring from SQL Server 2012.
|
||||
$this->supportsoffsetfetch = $serverinfo['version'] > '11';
|
||||
|
||||
// We can enable logging now.
|
||||
$this->query_log_allow();
|
||||
|
||||
// Connection established and configured, going to instantiate the temptables controller
|
||||
$this->temptables = new sqlsrv_native_moodle_temptables($this);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user