Page MenuHomeIn-Portal Phabricator

D394.id1058.diff
No OneTemporary

File Metadata

Created
Wed, Feb 26, 8:58 AM

D394.id1058.diff

Index: branches/5.2.x/core/kernel/db/db_connection.php
===================================================================
--- branches/5.2.x/core/kernel/db/db_connection.php
+++ branches/5.2.x/core/kernel/db/db_connection.php
@@ -63,10 +63,9 @@
/**
* Function to handle sql errors
*
- * @var Array|string
- * @access public
+ * @var callable
*/
- public $errorHandler = '';
+ protected $errorHandler = '';
/**
* Error code
@@ -168,10 +167,10 @@
$this->serverIndex = $server_index;
if ( !$error_handler ) {
- $this->errorHandler = Array(&$this, 'handleError');
+ $this->setErrorHandler(array(&$this, 'handleError'));
}
else {
- $this->errorHandler = $error_handler;
+ $this->setErrorHandler($error_handler);
}
$this->_captureStatistics = defined('DBG_CAPTURE_STATISTICS') && DBG_CAPTURE_STATISTICS && !(defined('ADMIN') && ADMIN);
@@ -932,6 +931,18 @@
return is_numeric($row['Seconds_Behind_Master']) ? $row['Seconds_Behind_Master'] : false;
}
+ /**
+ * Sets an error handler.
+ *
+ * @param callable $error_handler Error handler.
+ *
+ * @return void
+ */
+ public function setErrorHandler(callable $error_handler)
+ {
+ $this->errorHandler = $error_handler;
+ }
+
}
Index: branches/5.2.x/core/kernel/db/db_load_balancer.php
===================================================================
--- branches/5.2.x/core/kernel/db/db_load_balancer.php
+++ branches/5.2.x/core/kernel/db/db_load_balancer.php
@@ -27,10 +27,9 @@
/**
* Function to handle sql errors
*
- * @var string
- * @access public
+ * @var callable
*/
- public $errorHandler = '';
+ protected $errorHandler = '';
/**
* Database connection settings
@@ -59,8 +58,7 @@
/**
* Connection references to opened connections
*
- * @var Array
- * @access protected
+ * @var IDBConnection[]
*/
protected $connections = Array ();
@@ -130,7 +128,7 @@
parent::__construct();
$this->dbType = $db_type;
- $this->errorHandler = $error_handler;
+ $this->setErrorHandler($error_handler);
$this->DBClusterTimeout *= 1e6; // convert to milliseconds
}
@@ -879,4 +877,21 @@
return $conn->getSlaveLag();
}
+
+ /**
+ * Sets an error handler.
+ *
+ * @param callable $error_handler Error handler.
+ *
+ * @return void
+ */
+ public function setErrorHandler(callable $error_handler)
+ {
+ $this->errorHandler = $error_handler;
+
+ foreach ( $this->connections as $connection ) {
+ $connection->setErrorHandler($error_handler);
+ }
+ }
+
}
Index: branches/5.2.x/core/kernel/db/i_db_connection.php
===================================================================
--- branches/5.2.x/core/kernel/db/i_db_connection.php
+++ branches/5.2.x/core/kernel/db/i_db_connection.php
@@ -259,4 +259,14 @@
* @access public
*/
public function getSlaveLag();
+
+ /**
+ * Sets an error handler.
+ *
+ * @param callable $error_handler Error handler.
+ *
+ * @return void
+ */
+ public function setErrorHandler(callable $error_handler);
+
}
Index: branches/5.2.x/core/units/helpers/deployment_helper.php
===================================================================
--- branches/5.2.x/core/units/helpers/deployment_helper.php
+++ branches/5.2.x/core/units/helpers/deployment_helper.php
@@ -377,7 +377,7 @@
private function upgradeDatabase()
{
$this->loadAppliedRevisions();
- $this->Conn->errorHandler = Array (&$this, 'handleSqlError');
+ $this->Conn->setErrorHandler(array(&$this, 'handleSqlError'));
$this->out('Verifying Database Revisions ... ');

Event Timeline