Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F804009
D359.id898.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 26, 9:03 AM
Size
8 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 9:03 AM (4 h, 42 m)
Engine
blob
Format
Raw Data
Handle
576726
Attached To
D359: INP-1762 - Destroy query object before logging
D359.id898.diff
View Options
Index: core/kernel/application.php
===================================================================
--- core/kernel/application.php
+++ core/kernel/application.php
@@ -1239,6 +1239,7 @@
{
global $start;
+ $this->Conn->noDebuggingState = true;
$script_time = microtime(true) - $start;
$query_statistics = $this->Conn->getQueryStatistics(); // time & count
@@ -1266,6 +1267,8 @@
$data['LastHit'] = adodb_mktime();
$this->Conn->doInsert($data, TABLE_PREFIX . 'StatisticsCapture');
}
+
+ $this->Conn->noDebuggingState = false;
}
/**
@@ -1300,12 +1303,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 ) {
$this->_updateAverageStatistics($data, 'Time', $time);
@@ -1329,6 +1333,8 @@
$this->Conn->doInsert($data, TABLE_PREFIX . 'SlowSqlCapture');
}
+
+ $this->Conn->noDebuggingState = false;
}
/**
Index: core/kernel/db/db_connection.php
===================================================================
--- core/kernel/db/db_connection.php
+++ core/kernel/db/db_connection.php
@@ -135,6 +135,13 @@
public $nextQueryCachable = false;
/**
+ * The "no debugging" tate of the SQL queries.
+ *
+ * @var boolean
+ */
+ public $noDebuggingState = false;
+
+ /**
* For backwards compatibility with kDBLoadBalancer class
*
* @var bool
@@ -320,14 +327,18 @@
*
* @param string $sql
* @param string $key_field
- * @param bool $no_debug
+ * @param boolean|null $no_debug
* @return bool
* @access protected
*/
- protected function showError($sql = '', $key_field = null, $no_debug = false)
+ protected function showError($sql = '', $key_field = null, $no_debug = null)
{
static $retry_count = 0;
+ if ( $no_debug === null ) {
+ $no_debug = $this->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,11 +548,13 @@
}
}
+ $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);
}
@@ -542,8 +562,6 @@
}
// 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);
}
@@ -971,12 +996,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);
}
@@ -1050,15 +1079,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: core/kernel/db/db_load_balancer.php
===================================================================
--- core/kernel/db/db_load_balancer.php
+++ core/kernel/db/db_load_balancer.php
@@ -106,6 +106,13 @@
public $nextQueryCachable = false;
/**
+ * The "no debugging" tate of the SQL queries.
+ *
+ * @var boolean
+ */
+ public $noDebuggingState = false;
+
+ /**
* Indicates, that next query should be sent to maser database
*
* @var bool
@@ -441,9 +448,13 @@
}
}
- if ( $this->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;
@@ -568,11 +579,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);
@@ -587,12 +598,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);
Index: core/kernel/db/i_db_connection.php
===================================================================
--- core/kernel/db/i_db_connection.php
+++ core/kernel/db/i_db_connection.php
@@ -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.
Event Timeline
Log In to Comment