Index: core/kernel/db/db_connection.php =================================================================== --- core/kernel/db/db_connection.php +++ 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 @@ -161,10 +160,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); @@ -910,6 +909,19 @@ return false; } + + /** + * Sets an error handler. + * + * @param callable $error_handler Error handler. + * + * @return void + */ + public function setErrorHandler(callable $error_handler) + { + $this->errorHandler = $error_handler; + } + } Index: core/kernel/db/db_load_balancer.php =================================================================== --- core/kernel/db/db_load_balancer.php +++ 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 (); @@ -123,7 +121,7 @@ parent::__construct(); $this->dbType = $db_type; - $this->errorHandler = $error_handler; + $this->setErrorHandler($error_handler); $this->DBClusterTimeout *= 1e6; // convert to milliseconds } @@ -867,4 +865,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: core/kernel/db/i_db_connection.php =================================================================== --- core/kernel/db/i_db_connection.php +++ 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: core/units/helpers/deployment_helper.php =================================================================== --- core/units/helpers/deployment_helper.php +++ 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 ... ');