Index: branches/5.2.x/core/kernel/db/i_db_connection.php =================================================================== diff -u -N -r16432 -r16662 --- branches/5.2.x/core/kernel/db/i_db_connection.php (.../i_db_connection.php) (revision 16432) +++ branches/5.2.x/core/kernel/db/i_db_connection.php (.../i_db_connection.php) (revision 16662) @@ -95,11 +95,11 @@ * * @param string $sql * @param string $key_field - * @param bool $no_debug + * @param boolean|null $no_debug * @return Array * @access public */ - public function Query($sql, $key_field = null, $no_debug = false); + public function Query($sql, $key_field = null, $no_debug = null); /** * Returns iterator to a recordset, produced from running $sql query. @@ -109,12 +109,12 @@ * * @param string $sql * @param string $key_field - * @param bool $no_debug + * @param boolean|null $no_debug * @param string $iterator_class * @return kMySQLQuery|bool * @access public */ - public function GetIterator($sql, $key_field = null, $no_debug = false, $iterator_class = 'kMySQLQuery'); + public function GetIterator($sql, $key_field = null, $no_debug = null, $iterator_class = 'kMySQLQuery'); /** * Free memory used to hold recordset handle. Index: branches/5.2.x/core/kernel/application.php =================================================================== diff -u -N -r16661 -r16662 --- branches/5.2.x/core/kernel/application.php (.../application.php) (revision 16661) +++ branches/5.2.x/core/kernel/application.php (.../application.php) (revision 16662) @@ -1,6 +1,6 @@ Conn->noDebuggingState = true; $script_time = microtime(true) - $start; $query_statistics = $this->Conn->getQueryStatistics(); // time & count @@ -1267,6 +1268,8 @@ $data['LastHit'] = adodb_mktime(); $this->Conn->doInsert($data, TABLE_PREFIX . 'StatisticsCapture'); } + + $this->Conn->noDebuggingState = false; } /** @@ -1301,12 +1304,13 @@ */ public function logSlowQuery($slow_sql, $time) { + $this->Conn->noDebuggingState = true; $query_crc = kUtil::crc32($slow_sql); $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'SlowSqlCapture WHERE QueryCrc = ' . $query_crc; - $data = $this->Conn->Query($sql, null, true); + $data = $this->Conn->Query($sql); if ( $data ) { $data = array_shift($data); // Because "Query" method (supports $no_debug) is used instead of "GetRow". @@ -1332,6 +1336,8 @@ $this->Conn->doInsert($data, TABLE_PREFIX . 'SlowSqlCapture'); } + + $this->Conn->noDebuggingState = false; } /** Index: branches/5.2.x/core/kernel/db/db_connection.php =================================================================== diff -u -N -r16653 -r16662 --- branches/5.2.x/core/kernel/db/db_connection.php (.../db_connection.php) (revision 16653) +++ branches/5.2.x/core/kernel/db/db_connection.php (.../db_connection.php) (revision 16662) @@ -1,6 +1,6 @@ noDebuggingState; + } + if ( !is_object($this->connectionID) ) { // no connection while doing mysql_query $this->errorCode = mysqli_connect_errno(); @@ -500,13 +511,20 @@ * * @param string $sql * @param string $key_field - * @param bool $no_debug + * @param boolean|null $no_debug * @return Array * @access public */ - public function Query($sql, $key_field = null, $no_debug = false) + public function Query($sql, $key_field = null, $no_debug = null) { - $this->_queryCount++; + if ( $no_debug === null ) { + $no_debug = $this->noDebuggingState; + } + + if ( !$no_debug ) { + $this->_queryCount++; + } + $this->lastQuery = $sql; // set 1st checkpoint: begin @@ -530,20 +548,20 @@ } } + $this->Destroy(); + // set 2nd checkpoint: begin if ( $this->_captureStatistics ) { $query_time = microtime(true) - $start_time; - if ( $query_time > DBG_MAX_SQL_TIME ) { + if ( $query_time > DBG_MAX_SQL_TIME && !$no_debug ) { $this->Application->logSlowQuery($sql, $query_time); } $this->_queryTime += $query_time; } // set 2nd checkpoint: end - $this->Destroy(); - return $ret; } else { @@ -565,14 +583,21 @@ * * @param string $sql * @param string $key_field - * @param bool $no_debug + * @param boolean|null $no_debug * @param string $iterator_class * @return kMySQLQuery|bool * @access public */ - public function GetIterator($sql, $key_field = null, $no_debug = false, $iterator_class = 'kMySQLQuery') + public function GetIterator($sql, $key_field = null, $no_debug = null, $iterator_class = 'kMySQLQuery') { - $this->_queryCount++; + if ( $no_debug === null ) { + $no_debug = $this->noDebuggingState; + } + + if ( !$no_debug ) { + $this->_queryCount++; + } + $this->lastQuery = $sql; // set 1st checkpoint: begin @@ -590,7 +615,7 @@ if ( $this->_captureStatistics ) { $query_time = microtime(true) - $start_time; - if ( $query_time > DBG_MAX_SQL_TIME ) { + if ( $query_time > DBG_MAX_SQL_TIME && !$no_debug ) { $this->Application->logSlowQuery($sql, $query_time); } @@ -968,12 +993,16 @@ * * @param string $sql * @param string $key_field - * @param bool $no_debug + * @param boolean|null $no_debug * @return Array * @access public */ - public function Query($sql, $key_field = null, $no_debug = false) + public function Query($sql, $key_field = null, $no_debug = null) { + if ( $no_debug === null ) { + $no_debug = $this->noDebuggingState; + } + if ( $no_debug ) { return parent::Query($sql, $key_field, $no_debug); } @@ -1047,15 +1076,19 @@ * * @param string $sql * @param string $key_field - * @param bool $no_debug + * @param boolean|null $no_debug * @param string $iterator_class * @return kMySQLQuery|bool * @access public */ - public function GetIterator($sql, $key_field = null, $no_debug = false, $iterator_class = 'kMySQLQuery') + public function GetIterator($sql, $key_field = null, $no_debug = null, $iterator_class = 'kMySQLQuery') { + if ( $no_debug === null ) { + $no_debug = $this->noDebuggingState; + } + if ( $no_debug ) { - return parent::Query($sql, $key_field, $no_debug, $iterator_class); + return parent::GetIterator($sql, $key_field, $no_debug, $iterator_class); } global $debugger; Index: branches/5.2.x/core/kernel/db/db_load_balancer.php =================================================================== diff -u -N -r16658 -r16662 --- branches/5.2.x/core/kernel/db/db_load_balancer.php (.../db_load_balancer.php) (revision 16658) +++ branches/5.2.x/core/kernel/db/db_load_balancer.php (.../db_load_balancer.php) (revision 16662) @@ -1,6 +1,6 @@ nextQueryCachable && is_object($conn) ) { - $conn->nextQueryCachable = true; - $this->nextQueryCachable = false; + if ( is_object($conn) ) { + $conn->noDebuggingState = $this->noDebuggingState; + + if ( $this->nextQueryCachable ) { + $conn->nextQueryCachable = true; + $this->nextQueryCachable = false; + } } return $conn; @@ -569,11 +580,11 @@ * * @param string $sql * @param string $key_field - * @param bool $no_debug + * @param boolean|null $no_debug * @return Array * @access public */ - public function Query($sql, $key_field = null, $no_debug = false) + public function Query($sql, $key_field = null, $no_debug = null) { $conn =& $this->chooseConnection($sql); @@ -588,12 +599,12 @@ * * @param string $sql * @param string $key_field - * @param bool $no_debug + * @param boolean|null $no_debug * @param string $iterator_class * @return kMySQLQuery|bool * @access public */ - public function GetIterator($sql, $key_field = null, $no_debug = false, $iterator_class = 'kMySQLQuery') + public function GetIterator($sql, $key_field = null, $no_debug = null, $iterator_class = 'kMySQLQuery') { $conn =& $this->chooseConnection($sql);