Merge "build: Enable karma debug log and use progress reporter"
[lhc/web/wiklou.git] / includes / db / IDatabase.php
index 19eb126..c72218a 100644 (file)
@@ -174,7 +174,7 @@ interface IDatabase {
        public function writesOrCallbacksPending();
 
        /**
-        * Get the time spend running write queries for this
+        * Get the time spend running write queries for this transaction
         *
         * High times could be due to scanning, updates, locking, and such
         *
@@ -183,6 +183,14 @@ interface IDatabase {
         */
        public function pendingWriteQueryDuration();
 
+       /**
+        * Get the list of method names that did write queries for this transaction
+        *
+        * @return array
+        * @since 1.27
+        */
+       public function pendingWriteCallers();
+
        /**
         * Is a connection to the database open?
         * @return bool
@@ -1268,6 +1276,34 @@ interface IDatabase {
         */
        public function endAtomic( $fname = __METHOD__ );
 
+       /**
+        * Run a callback to do an atomic set of updates for this database
+        *
+        * The $callback takes the following arguments:
+        *   - This database object
+        *   - The value of $fname
+        *
+        * If any exception occurs in the callback, then rollback() will be called and the error will
+        * be re-thrown. It may also be that the rollback itself fails with an exception before then.
+        * In any case, such errors are expected to terminate the request, without any outside caller
+        * attempting to catch errors and commit anyway. Note that any rollback undoes all prior
+        * atomic section and uncommitted updates, which trashes the current request, requiring an
+        * error to be displayed.
+        *
+        * This can be an alternative to explicit startAtomic()/endAtomic() calls.
+        *
+        * @see DatabaseBase::startAtomic
+        * @see DatabaseBase::endAtomic
+        *
+        * @param string $fname Caller name (usually __METHOD__)
+        * @param callable $callback Callback that issues DB updates
+        * @throws DBError
+        * @throws RuntimeException
+        * @throws UnexpectedValueException
+        * @since 1.27
+        */
+       public function doAtomicSection( $fname, $callback );
+
        /**
         * Begin a transaction. If a transaction is already in progress,
         * that transaction will be committed before the new transaction is started.
@@ -1369,7 +1405,7 @@ interface IDatabase {
         * installations. Most callers should use LoadBalancer::safeGetLag()
         * instead.
         *
-        * @return int Database replication lag in seconds
+        * @return int|bool Database replication lag in seconds or false on error
         */
        public function getLag();
 
@@ -1383,7 +1419,7 @@ interface IDatabase {
         * safe to be pessimistic. In AUTO-COMMIT mode, this still gives an
         * indication of the staleness of subsequent reads.
         *
-        * @return array ('lag': seconds, 'since': UNIX timestamp of BEGIN)
+        * @return array ('lag': seconds or false on error, 'since': UNIX timestamp of BEGIN)
         * @since 1.27
         */
        public function getSessionLagStatus();