Merge "Show user names as subpages of special pages in autocomplete search"
[lhc/web/wiklou.git] / includes / db / Database.php
index dea4a59..3fec522 100644 (file)
@@ -148,6 +148,9 @@ abstract class DatabaseBase implements IDatabase {
         */
        private $mTrxWriteDuration = 0.0;
 
+       /** @var IDatabase|null Lazy handle to the master DB this server replicates from */
+       private $lazyMasterHandle;
+
        /**
         * @since 1.21
         * @var resource File handle for upgrade
@@ -328,6 +331,25 @@ abstract class DatabaseBase implements IDatabase {
                }
        }
 
+       /**
+        * Set a lazy-connecting DB handle to the master DB (for replication status purposes)
+        *
+        * @param IDatabase $conn
+        * @since 1.27
+        */
+       public function setLazyMasterHandle( IDatabase $conn ) {
+               $this->lazyMasterHandle = $conn;
+       }
+
+       /**
+        * @return IDatabase|null
+        * @see setLazyMasterHandle()
+        * @since 1.27
+        */
+       public function getLazyMasterHandle() {
+               return $this->lazyMasterHandle;
+       }
+
        /**
         * @return TransactionProfiler
         */
@@ -1264,13 +1286,14 @@ abstract class DatabaseBase implements IDatabase {
         * @param string|array $cond The condition array. See DatabaseBase::select() for details.
         * @param string $fname The function name of the caller.
         * @param string|array $options The query options. See DatabaseBase::select() for details.
+        * @param string|array $join_conds The join conditions. See DatabaseBase::select() for details.
         *
         * @return bool|array The values from the field, or false on failure
         * @throws DBUnexpectedError
         * @since 1.25
         */
        public function selectFieldValues(
-               $table, $var, $cond = '', $fname = __METHOD__, $options = array()
+               $table, $var, $cond = '', $fname = __METHOD__, $options = array(), $join_conds = array()
        ) {
                if ( $var === '*' ) { // sanity
                        throw new DBUnexpectedError( $this, "Cannot use a * field: got '$var'" );
@@ -1280,7 +1303,7 @@ abstract class DatabaseBase implements IDatabase {
                        $options = array( $options );
                }
 
-               $res = $this->select( $table, $var, $cond, $fname, $options );
+               $res = $this->select( $table, $var, $cond, $fname, $options, $join_conds );
                if ( $res === false ) {
                        return false;
                }
@@ -3424,6 +3447,21 @@ abstract class DatabaseBase implements IDatabase {
                }
        }
 
+       final public function doAtomicSection( $fname, $callback ) {
+               if ( !is_callable( $callback ) ) {
+                       throw new UnexpectedValueException( "Invalid callback." );
+               };
+
+               $this->startAtomic( $fname );
+               try {
+                       call_user_func_array( $callback, array( $this, $fname ) );
+               } catch ( Exception $e ) {
+                       $this->rollback( $fname );
+                       throw $e;
+               }
+               $this->endAtomic( $fname );
+       }
+
        /**
         * Begin a transaction. If a transaction is already in progress,
         * that transaction will be committed before the new transaction is started.