Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F803807
D394.id1058.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, 8:58 AM
Size
3 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 8:58 AM (13 h, 36 m)
Engine
blob
Format
Raw Data
Handle
576531
Attached To
D394: INP-1796 - Add method for setting database error handler
D394.id1058.diff
View Options
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
Log In to Comment