Merge "Revert "rdbms: add domain sanity checks to LoadBalancer connection methods""
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 13 Oct 2018 00:58:11 +0000 (00:58 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 13 Oct 2018 00:58:11 +0000 (00:58 +0000)
12 files changed:
RELEASE-NOTES-1.32
includes/DefaultSettings.php
includes/OutputPage.php
includes/ServiceWiring.php
includes/cache/localisation/LCStoreDB.php
includes/htmlform/fields/HTMLFormFieldCloner.php
includes/objectcache/SqlBagOStuff.php
includes/watcheditem/WatchedItemStore.php
resources/src/mediawiki.htmlform/cloner.js
tests/phpunit/includes/HtmlTest.php
tests/phpunit/includes/OutputPageTest.php
tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php

index 40dd295..a63a16d 100644 (file)
@@ -531,6 +531,9 @@ because of Phabricator reports.
 * In Skin::doEditSectionLink omitting the parameters $tooltip and $lang is
   deprecated. For the $lang parameter, types other than Language are
   deprecated.
+* The $wgUseKeyHeader configuration option and the
+  OutputPage::getKeyHeader() method have been deprecated; the relevant
+  draft IETF spec expired without becoming a standard.
 
 === Other changes in 1.32 ===
 * (T198811) The following tables have had their UNIQUE indexes turned into
index 4ed1707..6a1ed92 100644 (file)
@@ -2741,8 +2741,9 @@ $wgUseESI = false;
 
 /**
  * Send the Key HTTP header for better caching.
- * See https://datatracker.ietf.org/doc/draft-fielding-http-key/ for details.
+ * See https://datatracker.ietf.org/doc/draft-ietf-httpbis-key/ for details.
  * @since 1.27
+ * @deprecated in 1.32, the IETF spec expired without becoming a standard.
  */
 $wgUseKeyHeader = false;
 
index 17e92cb..cde92e8 100644 (file)
@@ -2281,8 +2281,12 @@ class OutputPage extends ContextSource {
         * Get a complete Key header
         *
         * @return string
+        * @deprecated in 1.32; the IETF spec for this header expired w/o becoming
+        *   a standard.
         */
        public function getKeyHeader() {
+               wfDeprecated( '$wgUseKeyHeader', '1.32' );
+
                $cvCookies = $this->getCacheVaryCookies();
 
                $cookiesOption = [];
@@ -2330,6 +2334,16 @@ class OutputPage extends ContextSource {
                                        continue;
                                }
 
+                               // XXX Note that this code is not strictly correct: we
+                               // do a case-insensitive match in
+                               // LanguageConverter::getHeaderVariant() while the
+                               // (abandoned, draft) spec for the `Key` header only
+                               // allows case-sensitive matches.  To match the logic
+                               // in LanguageConverter::getHeaderVariant() we should
+                               // also be looking at fallback variants and deprecated
+                               // mediawiki-internal codes, as well as BCP 47
+                               // normalized forms.
+
                                $aloption[] = "substr=$variant";
 
                                // IE and some other browsers use BCP 47 standards in their Accept-Language header,
index c1ac932..ed203ad 100644 (file)
@@ -571,7 +571,7 @@ return [
 
        'WatchedItemStore' => function ( MediaWikiServices $services ) : WatchedItemStore {
                $store = new WatchedItemStore(
-                       $services->getDBLoadBalancer(),
+                       $services->getDBLoadBalancerFactory(),
                        new HashBagOStuff( [ 'maxKeys' => 100 ] ),
                        $services->getReadOnlyMode(),
                        $services->getMainConfig()->get( 'UpdateRowsPerQuery' )
index 2d8e4d2..88a7042 100644 (file)
@@ -85,22 +85,28 @@ class LCStoreDB implements LCStore {
                        throw new MWException( __CLASS__ . ': must call startWrite() before finishWrite()' );
                }
 
-               $dbw = $this->getWriteConnection();
-               $dbw->startAtomic( __METHOD__ );
+               $trxProfiler = Profiler::instance()->getTransactionProfiler();
+               $oldSilenced = $trxProfiler->setSilenced( true );
                try {
-                       $dbw->delete( 'l10n_cache', [ 'lc_lang' => $this->currentLang ], __METHOD__ );
-                       foreach ( array_chunk( $this->batch, 500 ) as $rows ) {
-                               $dbw->insert( 'l10n_cache', $rows, __METHOD__ );
-                       }
-                       $this->writesDone = true;
-               } catch ( DBQueryError $e ) {
-                       if ( $dbw->wasReadOnlyError() ) {
-                               $this->readOnly = true; // just avoid site down time
-                       } else {
-                               throw $e;
+                       $dbw = $this->getWriteConnection();
+                       $dbw->startAtomic( __METHOD__ );
+                       try {
+                               $dbw->delete( 'l10n_cache', [ 'lc_lang' => $this->currentLang ], __METHOD__ );
+                               foreach ( array_chunk( $this->batch, 500 ) as $rows ) {
+                                       $dbw->insert( 'l10n_cache', $rows, __METHOD__ );
+                               }
+                               $this->writesDone = true;
+                       } catch ( DBQueryError $e ) {
+                               if ( $dbw->wasReadOnlyError() ) {
+                                       $this->readOnly = true; // just avoid site down time
+                               } else {
+                                       throw $e;
+                               }
                        }
+                       $dbw->endAtomic( __METHOD__ );
+               } finally {
+                       $trxProfiler->setSilenced( $oldSilenced );
                }
-               $dbw->endAtomic( __METHOD__ );
 
                $this->currentLang = null;
                $this->batch = [];
index aae3af2..cdbd84d 100644 (file)
@@ -11,7 +11,7 @@
  *     of fields.
  *   required - If specified, at least one group of fields must be submitted.
  *   format - HTMLForm display format to use when displaying the subfields:
- *     'table', 'div', or 'raw'.
+ *     'table', 'div', or 'raw'. This is ignored when using OOUI.
  *   row-legend - If non-empty, each group of subfields will be enclosed in a
  *     fieldset. The value is the name of a message key to use as the legend.
  *   create-button-message - Message to use as the text of the button to
@@ -303,22 +303,12 @@ class HTMLFormFieldCloner extends HTMLFormField {
                }
 
                if ( !isset( $fields['delete'] ) ) {
-                       $name = "{$this->mName}[$key][delete]";
-                       $label = $this->mParams['delete-button-message'] ?? 'htmlform-cloner-delete';
-                       $field = HTMLForm::loadInputFromParameters( $name, [
-                               'type' => 'submit',
-                               'formnovalidate' => true,
-                               'name' => $name,
-                               'id' => Sanitizer::escapeIdForAttribute( "{$this->mID}--$key--delete" ),
-                               'cssclass' => 'mw-htmlform-cloner-delete-button',
-                               'default' => $this->getMessage( $label )->text(),
-                       ], $this->mParent );
-                       $v = $field->getDefault();
+                       $field = $this->getDeleteButtonHtml( $key );
 
                        if ( $displayFormat === 'table' ) {
-                               $html .= $field->$getFieldHtmlMethod( $v );
+                               $html .= $field->$getFieldHtmlMethod( $field->getDefault() );
                        } else {
-                               $html .= $field->getInputHTML( $v );
+                               $html .= $field->getInputHTML( $field->getDefault() );
                        }
                }
 
@@ -354,6 +344,37 @@ class HTMLFormFieldCloner extends HTMLFormField {
                return $html;
        }
 
+       /**
+        * @param string $key Array key indicating to which field the delete button belongs
+        * @return HTMLFormField
+        */
+       protected function getDeleteButtonHtml( $key ) : HTMLFormField {
+               $name = "{$this->mName}[$key][delete]";
+               $label = $this->mParams['delete-button-message'] ?? 'htmlform-cloner-delete';
+               $field = HTMLForm::loadInputFromParameters( $name, [
+                       'type' => 'submit',
+                       'formnovalidate' => true,
+                       'name' => $name,
+                       'id' => Sanitizer::escapeIdForAttribute( "{$this->mID}--$key--delete" ),
+                       'cssclass' => 'mw-htmlform-cloner-delete-button',
+                       'default' => $this->getMessage( $label )->text(),
+               ], $this->mParent );
+               return $field;
+       }
+
+       protected function getCreateButtonHtml() : HTMLFormField {
+               $name = "{$this->mName}[create]";
+               $label = $this->mParams['create-button-message'] ?? 'htmlform-cloner-create';
+               return HTMLForm::loadInputFromParameters( $name, [
+                       'type' => 'submit',
+                       'formnovalidate' => true,
+                       'name' => $name,
+                       'id' => Sanitizer::escapeIdForAttribute( "{$this->mID}--create" ),
+                       'cssclass' => 'mw-htmlform-cloner-create-button',
+                       'default' => $this->getMessage( $label )->text(),
+               ], $this->mParent );
+       }
+
        public function getInputHTML( $values ) {
                $html = '';
 
@@ -374,18 +395,92 @@ class HTMLFormFieldCloner extends HTMLFormField {
                        'data-unique-id' => $this->uniqueId,
                ], $html );
 
-               $name = "{$this->mName}[create]";
-               $label = $this->mParams['create-button-message'] ?? 'htmlform-cloner-create';
-               $field = HTMLForm::loadInputFromParameters( $name, [
-                       'type' => 'submit',
-                       'formnovalidate' => true,
-                       'name' => $name,
-                       'id' => Sanitizer::escapeIdForAttribute( "{$this->mID}--create" ),
-                       'cssclass' => 'mw-htmlform-cloner-create-button',
-                       'default' => $this->getMessage( $label )->text(),
-               ], $this->mParent );
+               $field = $this->getCreateButtonHtml();
                $html .= $field->getInputHTML( $field->getDefault() );
 
                return $html;
        }
+
+       /**
+        * Get the input OOUI HTML for the specified key.
+        *
+        * @param string $key Array key under which the fields should be named
+        * @param array $values
+        * @return string
+        */
+       protected function getInputOOUIForKey( $key, array $values ) {
+               $html = '';
+               $hidden = '';
+
+               $fields = $this->createFieldsForKey( $key );
+               foreach ( $fields as $fieldname => $field ) {
+                       $v = array_key_exists( $fieldname, $values )
+                               ? $values[$fieldname]
+                               : $field->getDefault();
+
+                       if ( $field instanceof HTMLHiddenField ) {
+                               // HTMLHiddenField doesn't generate its own HTML
+                               list( $name, $value, $params ) = $field->getHiddenFieldData( $v );
+                               $hidden .= Html::hidden( $name, $value, $params ) . "\n";
+                       } else {
+                               $html .= $field->getOOUI( $v );
+                       }
+               }
+
+               if ( !isset( $fields['delete'] ) ) {
+                       $field = $this->getDeleteButtonHtml( $key );
+                       $fieldHtml = $field->getInputOOUI( $field->getDefault() );
+                       $fieldHtml->setInfusable( true );
+
+                       $html .= $fieldHtml;
+               }
+
+               $classes = [
+                       'mw-htmlform-cloner-row',
+               ];
+
+               $attribs = [
+                       'class' => implode( ' ', $classes ),
+               ];
+
+               $html = Html::rawElement( 'div', $attribs, "\n$html\n" );
+
+               $html .= $hidden;
+
+               if ( !empty( $this->mParams['row-legend'] ) ) {
+                       $legend = $this->msg( $this->mParams['row-legend'] )->text();
+                       $html = Xml::fieldset( $legend, $html );
+               }
+
+               return $html;
+       }
+
+       public function getInputOOUI( $values ) {
+               $html = '';
+
+               foreach ( (array)$values as $key => $value ) {
+                       if ( $key === 'nonjs' ) {
+                               continue;
+                       }
+                       $html .= Html::rawElement( 'li', [ 'class' => 'mw-htmlform-cloner-li' ],
+                               $this->getInputOOUIForKey( $key, $value )
+                       );
+               }
+
+               $template = $this->getInputOOUIForKey( $this->uniqueId, [] );
+               $html = Html::rawElement( 'ul', [
+                       'id' => "mw-htmlform-cloner-list-{$this->mID}",
+                       'class' => 'mw-htmlform-cloner-ul',
+                       'data-template' => $template,
+                       'data-unique-id' => $this->uniqueId,
+               ], $html );
+
+               $field = $this->getCreateButtonHtml();
+               $fieldHtml = $field->getInputOOUI( $field->getDefault() );
+               $fieldHtml->setInfusable( true );
+
+               $html .= $fieldHtml;
+
+               return $html;
+       }
 }
index 076f208..a581ac8 100644 (file)
@@ -28,7 +28,7 @@ use Wikimedia\Rdbms\DBError;
 use Wikimedia\Rdbms\DBQueryError;
 use Wikimedia\Rdbms\DBConnectionError;
 use Wikimedia\Rdbms\LoadBalancer;
-use Wikimedia\Rdbms\TransactionProfiler;
+use Wikimedia\ScopedCallback;
 use Wikimedia\WaitConditionLoop;
 
 /**
@@ -171,8 +171,6 @@ class SqlBagOStuff extends BagOStuff {
                                $type = $info['type'] ?? 'mysql';
                                $host = $info['host'] ?? '[unknown]';
                                $this->logger->debug( __CLASS__ . ": connecting to $host" );
-                               // Use a blank trx profiler to ignore expections as this is a cache
-                               $info['trxProfiler'] = new TransactionProfiler();
                                $db = Database::factory( $type, $info );
                                $db->clearFlag( DBO_TRX ); // auto-commit mode
                        } else {
@@ -182,7 +180,6 @@ class SqlBagOStuff extends BagOStuff {
                                if ( $lb->getServerType( $lb->getWriterIndex() ) !== 'sqlite' ) {
                                        // Keep a separate connection to avoid contention and deadlocks
                                        $db = $lb->getConnection( $index, [], false, $lb::CONN_TRX_AUTOCOMMIT );
-                                       // @TODO: Use a blank trx profiler to ignore expections as this is a cache
                                } else {
                                        // However, SQLite has the opposite behavior due to DB-level locking.
                                        // Stock sqlite MediaWiki installs use a separate sqlite cache DB instead.
@@ -323,6 +320,7 @@ class SqlBagOStuff extends BagOStuff {
 
                $result = true;
                $exptime = (int)$expiry;
+               $silenceScope = $this->silenceTransactionProfiler();
                foreach ( $keysByTable as $serverIndex => $serverKeys ) {
                        $db = null;
                        try {
@@ -384,6 +382,7 @@ class SqlBagOStuff extends BagOStuff {
        protected function cas( $casToken, $key, $value, $exptime = 0 ) {
                list( $serverIndex, $tableName ) = $this->getTableByKey( $key );
                $db = null;
+               $silenceScope = $this->silenceTransactionProfiler();
                try {
                        $db = $this->getDB( $serverIndex );
                        $exptime = intval( $exptime );
@@ -425,6 +424,7 @@ class SqlBagOStuff extends BagOStuff {
        public function delete( $key ) {
                list( $serverIndex, $tableName ) = $this->getTableByKey( $key );
                $db = null;
+               $silenceScope = $this->silenceTransactionProfiler();
                try {
                        $db = $this->getDB( $serverIndex );
                        $db->delete(
@@ -442,6 +442,7 @@ class SqlBagOStuff extends BagOStuff {
        public function incr( $key, $step = 1 ) {
                list( $serverIndex, $tableName ) = $this->getTableByKey( $key );
                $db = null;
+               $silenceScope = $this->silenceTransactionProfiler();
                try {
                        $db = $this->getDB( $serverIndex );
                        $step = intval( $step );
@@ -496,6 +497,7 @@ class SqlBagOStuff extends BagOStuff {
        public function changeTTL( $key, $expiry = 0 ) {
                list( $serverIndex, $tableName ) = $this->getTableByKey( $key );
                $db = null;
+               $silenceScope = $this->silenceTransactionProfiler();
                try {
                        $db = $this->getDB( $serverIndex );
                        $db->update(
@@ -564,6 +566,7 @@ class SqlBagOStuff extends BagOStuff {
         * @return bool
         */
        public function deleteObjectsExpiringBefore( $timestamp, $progressCallback = false ) {
+               $silenceScope = $this->silenceTransactionProfiler();
                for ( $serverIndex = 0; $serverIndex < $this->numServers; $serverIndex++ ) {
                        $db = null;
                        try {
@@ -641,6 +644,7 @@ class SqlBagOStuff extends BagOStuff {
         * @return bool
         */
        public function deleteAll() {
+               $silenceScope = $this->silenceTransactionProfiler();
                for ( $serverIndex = 0; $serverIndex < $this->numServers; $serverIndex++ ) {
                        $db = null;
                        try {
@@ -822,4 +826,18 @@ class SqlBagOStuff extends BagOStuff {
 
                return ( $loop->invoke() === $loop::CONDITION_REACHED );
        }
+
+       /**
+        * Returns a ScopedCallback which resets the silence flag in the transaction profiler when it is
+        * destroyed on the end of a scope, for example on return or throw
+        * @return ScopedCallback
+        * @since 1.32
+        */
+       protected function silenceTransactionProfiler() {
+               $trxProfiler = Profiler::instance()->getTransactionProfiler();
+               $oldSilenced = $trxProfiler->setSilenced( true );
+               return new ScopedCallback( function () use ( $trxProfiler, $oldSilenced ) {
+                       $trxProfiler->setSilenced( $oldSilenced );
+               } );
+       }
 }
index 1b92f51..c763010 100644 (file)
@@ -3,9 +3,9 @@
 use Wikimedia\Rdbms\IDatabase;
 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
 use MediaWiki\Linker\LinkTarget;
-use MediaWiki\MediaWikiServices;
 use Wikimedia\Assert\Assert;
 use Wikimedia\ScopedCallback;
+use Wikimedia\Rdbms\ILBFactory;
 use Wikimedia\Rdbms\LoadBalancer;
 
 /**
@@ -18,6 +18,11 @@ use Wikimedia\Rdbms\LoadBalancer;
  */
 class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterface {
 
+       /**
+        * @var ILBFactory
+        */
+       private $lbFactory;
+
        /**
         * @var LoadBalancer
         */
@@ -62,18 +67,19 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
        private $stats;
 
        /**
-        * @param LoadBalancer $loadBalancer
+        * @param ILBFactory $lbFactory
         * @param HashBagOStuff $cache
         * @param ReadOnlyMode $readOnlyMode
         * @param int $updateRowsPerQuery
         */
        public function __construct(
-               LoadBalancer $loadBalancer,
+               ILBFactory $lbFactory,
                HashBagOStuff $cache,
                ReadOnlyMode $readOnlyMode,
                $updateRowsPerQuery
        ) {
-               $this->loadBalancer = $loadBalancer;
+               $this->lbFactory = $lbFactory;
+               $this->loadBalancer = $lbFactory->getMainLB();
                $this->cache = $cache;
                $this->readOnlyMode = $readOnlyMode;
                $this->stats = new NullStatsdDataFactory();
@@ -819,13 +825,10 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
                        $fname = __METHOD__;
                        DeferredUpdates::addCallableUpdate(
                                function () use ( $timestamp, $watchers, $target, $fname ) {
-                                       global $wgUpdateRowsPerQuery;
-
                                        $dbw = $this->getConnectionRef( DB_MASTER );
-                                       $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
-                                       $ticket = $factory->getEmptyTransactionTicket( $fname );
+                                       $ticket = $this->lbFactory->getEmptyTransactionTicket( $fname );
 
-                                       $watchersChunks = array_chunk( $watchers, $wgUpdateRowsPerQuery );
+                                       $watchersChunks = array_chunk( $watchers, $this->updateRowsPerQuery );
                                        foreach ( $watchersChunks as $watchersChunk ) {
                                                $dbw->update( 'watchlist',
                                                        [ /* SET */
@@ -837,7 +840,7 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac
                                                        ], $fname
                                                );
                                                if ( count( $watchersChunks ) > 1 ) {
-                                                       $factory->commitAndWaitForReplication(
+                                                       $this->lbFactory->commitAndWaitForReplication(
                                                                $fname, $ticket, [ 'domain' => $dbw->getDomainID() ]
                                                        );
                                                }
index 4d94deb..6e33856 100644 (file)
@@ -6,31 +6,62 @@
 
        var cloneCounter = 0;
 
-       mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
-               $root.find( '.mw-htmlform-cloner-delete-button' ).filter( ':input' ).click( function ( ev ) {
-                       ev.preventDefault();
-                       $( this ).closest( 'li.mw-htmlform-cloner-li' ).remove();
-               } );
-
-               $root.find( '.mw-htmlform-cloner-create-button' ).filter( ':input' ).click( function ( ev ) {
-                       var $ul, $li, html;
-
-                       ev.preventDefault();
-
-                       $ul = $( this ).prev( 'ul.mw-htmlform-cloner-ul' );
-
+       /**
+        * Appends a new row with fields to the cloner.
+        *
+        * @ignore
+        * @param {jQuery} $createButton
+        */
+       function appendToCloner( $createButton ) {
+               var $li,
+                       $ul = $createButton.prev( 'ul.mw-htmlform-cloner-ul' ),
                        html = $ul.data( 'template' ).replace(
                                new RegExp( mw.RegExp.escape( $ul.data( 'uniqueId' ) ), 'g' ),
                                'clone' + ( ++cloneCounter )
                        );
 
-                       $li = $( '<li>' )
-                               .addClass( 'mw-htmlform-cloner-li' )
-                               .html( html )
-                               .appendTo( $ul );
+               $li = $( '<li>' )
+                       .addClass( 'mw-htmlform-cloner-li' )
+                       .html( html )
+                       .appendTo( $ul );
 
-                       mw.hook( 'htmlform.enhance' ).fire( $li );
+               mw.hook( 'htmlform.enhance' ).fire( $li );
+       }
+
+       mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
+               var $deleteElement = $root.find( '.mw-htmlform-cloner-delete-button' ),
+                       $createElement = $root.find( '.mw-htmlform-cloner-create-button' ),
+                       createButton;
+
+               $deleteElement.each( function () {
+                       var $element = $( this ),
+                               deleteButton;
+
+                       if ( $element.hasClass( 'oo-ui-widget' ) ) {
+                               deleteButton = OO.ui.infuse( $element );
+                               deleteButton.on( 'click', function () {
+                                       deleteButton.$element.closest( 'li.mw-htmlform-cloner-li' ).remove();
+                               } );
+                       } else {
+                               $element.filter( ':input' ).click( function ( ev ) {
+                                       ev.preventDefault();
+                                       $( this ).closest( 'li.mw-htmlform-cloner-li' ).remove();
+                               } );
+                       }
                } );
+
+               if ( $createElement.hasClass( 'oo-ui-widget' ) ) {
+                       createButton = OO.ui.infuse( $createElement );
+                       createButton.on( 'click', function () {
+                               appendToCloner( createButton.$element );
+                       } );
+               } else {
+                       $createElement.filter( ':input' ).click( function ( ev ) {
+                               ev.preventDefault();
+
+                               appendToCloner( $( this ) );
+                       } );
+               }
        } );
 
 }() );
index 5cc59b3..156f702 100644 (file)
@@ -10,12 +10,12 @@ class HtmlTest extends MediaWikiTestCase {
                        'wgUseMediaWikiUIEverywhere' => false,
                ] );
 
-               $langObj = Language::factory( 'en' );
+               $contLangObj = Language::factory( 'en' );
 
                // Hardcode namespaces during test runs,
                // so that html output based on existing namespaces
                // can be properly evaluated.
-               $langObj->setNamespaces( [
+               $contLangObj->setNamespaces( [
                        -2 => 'Media',
                        -1 => 'Special',
                        0 => '',
@@ -35,8 +35,33 @@ class HtmlTest extends MediaWikiTestCase {
                        100 => 'Custom',
                        101 => 'Custom_talk',
                ] );
-               $this->setUserLang( $langObj );
-               $this->setContentLang( $langObj );
+               $this->setContentLang( $contLangObj );
+
+               $userLangObj = Language::factory( 'es' );
+               $userLangObj->setNamespaces( [
+                       -2 => "Medio",
+                       -1 => "Especial",
+                       0 => "",
+                       1 => "Discusión",
+                       2 => "Usuario",
+                       3 => "Usuario discusión",
+                       4 => "Wiki",
+                       5 => "Wiki discusión",
+                       6 => "Archivo",
+                       7 => "Archivo discusión",
+                       8 => "MediaWiki",
+                       9 => "MediaWiki discusión",
+                       10 => "Plantilla",
+                       11 => "Plantilla discusión",
+                       12 => "Ayuda",
+                       13 => "Ayuda discusión",
+                       14 => "Categoría",
+                       15 => "Categoría discusión",
+                       100 => "Personalizado",
+                       101 => "Personalizado discusión",
+               ] );
+               $this->setUserLang( $userLangObj );
+
                $this->restoreWarnings = false;
        }
 
@@ -322,7 +347,7 @@ class HtmlTest extends MediaWikiTestCase {
        public function testNamespaceSelector() {
                $this->assertEquals(
                        '<select id="namespace" name="namespace">' . "\n" .
-                               '<option value="0">(Main)</option>' . "\n" .
+                               '<option value="0">(Principal)</option>' . "\n" .
                                '<option value="1">Talk</option>' . "\n" .
                                '<option value="2">User</option>' . "\n" .
                                '<option value="3">User talk</option>' . "\n" .
@@ -346,8 +371,8 @@ class HtmlTest extends MediaWikiTestCase {
                $this->assertEquals(
                        '<label for="mw-test-namespace">Select a namespace:</label>' . "\u{00A0}" .
                                '<select id="mw-test-namespace" name="wpNamespace">' . "\n" .
-                               '<option value="all">all</option>' . "\n" .
-                               '<option value="0">(Main)</option>' . "\n" .
+                               '<option value="all">todos</option>' . "\n" .
+                               '<option value="0">(Principal)</option>' . "\n" .
                                '<option value="1">Talk</option>' . "\n" .
                                '<option value="2" selected="">User</option>' . "\n" .
                                '<option value="3">User talk</option>' . "\n" .
@@ -374,7 +399,7 @@ class HtmlTest extends MediaWikiTestCase {
                $this->assertEquals(
                        '<label for="namespace">Select a namespace:</label>' . "\u{00A0}" .
                                '<select id="namespace" name="namespace">' . "\n" .
-                               '<option value="0">(Main)</option>' . "\n" .
+                               '<option value="0">(Principal)</option>' . "\n" .
                                '<option value="1">Talk</option>' . "\n" .
                                '<option value="2">User</option>' . "\n" .
                                '<option value="3">User talk</option>' . "\n" .
@@ -429,7 +454,7 @@ class HtmlTest extends MediaWikiTestCase {
        public function testCanDisableANamespaces() {
                $this->assertEquals(
                        '<select id="namespace" name="namespace">' . "\n" .
-                               '<option disabled="" value="0">(Main)</option>' . "\n" .
+                               '<option disabled="" value="0">(Principal)</option>' . "\n" .
                                '<option disabled="" value="1">Talk</option>' . "\n" .
                                '<option disabled="" value="2">User</option>' . "\n" .
                                '<option disabled="" value="3">User talk</option>' . "\n" .
index 19494f2..53e6f46 100644 (file)
@@ -2083,6 +2083,7 @@ class OutputPageTest extends MediaWikiTestCase {
                        ->will( $this->returnValue( $cookies ) );
                TestingAccessWrapper::newFromObject( $op )->mVaryHeader = [];
 
+               $this->hideDeprecated( '$wgUseKeyHeader' );
                foreach ( $calls as $call ) {
                        $op->addVaryHeader( ...$call );
                }
@@ -2235,6 +2236,7 @@ class OutputPageTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideAddAcceptLanguage
         * @covers OutputPage::addAcceptLanguage
+        * @covers OutputPage::getKeyHeader
         */
        public function testAddAcceptLanguage(
                $code, array $variants, array $expected, array $options = []
@@ -2262,6 +2264,7 @@ class OutputPageTest extends MediaWikiTestCase {
                // This will run addAcceptLanguage()
                $op->sendCacheControl();
 
+               $this->hideDeprecated( '$wgUseKeyHeader' );
                $keyHeader = $op->getKeyHeader();
 
                if ( !$expected ) {
index 8ef8cb0..f60f92c 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 use MediaWiki\Linker\LinkTarget;
 use Wikimedia\Rdbms\LoadBalancer;
+use Wikimedia\Rdbms\LBFactory;
 use Wikimedia\ScopedCallback;
 use Wikimedia\TestingAccessWrapper;
 
@@ -41,6 +42,23 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                return $mock;
        }
 
+       /**
+        * @return PHPUnit_Framework_MockObject_MockObject|LBFactory
+        */
+       private function getMockLBFactory(
+               $mockDb,
+               $expectedConnectionType = null
+       ) {
+               $loadBalancer = $this->getMockLoadBalancer( $mockDb, $expectedConnectionType );
+               $mock = $this->getMockBuilder( LBFactory::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $mock->expects( $this->any() )
+                       ->method( 'getMainLB' )
+                       ->will( $this->returnValue( $loadBalancer ) );
+               return $mock;
+       }
+
        /**
         * @return PHPUnit_Framework_MockObject_MockObject|HashBagOStuff
         */
@@ -100,11 +118,11 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                return $fakeRow;
        }
 
-       private function newWatchedItemStore( LoadBalancer $loadBalancer, HashBagOStuff $cache,
+       private function newWatchedItemStore( LBFactory $lbFactory, HashBagOStuff $cache,
                ReadOnlyMode $readOnlyMode
        ) {
                return new WatchedItemStore(
-                       $loadBalancer,
+                       $lbFactory,
                        $cache,
                        $readOnlyMode,
                        1000
@@ -142,7 +160,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( 'RM-KEY' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -174,7 +192,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -204,7 +222,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -235,7 +253,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -287,7 +305,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -354,7 +372,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -403,7 +421,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -485,7 +503,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -590,7 +608,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -644,7 +662,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -682,7 +700,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -717,7 +735,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -755,7 +773,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -786,7 +804,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->will( $this->returnValue( new FakeResultWrapper( [] ) ) );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $this->getMockCache(),
                        $this->getMockReadOnlyMode()
                );
@@ -845,7 +863,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -892,7 +910,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -986,7 +1004,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1019,7 +1037,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '0:Some_Page:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1040,7 +1058,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1053,7 +1071,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
        public function testAddWatchBatchForUser_readOnlyDBReturnsFalse() {
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $this->getMockDb() ),
+                       $this->getMockLBFactory( $this->getMockDb() ),
                        $this->getMockCache(),
                        $this->getMockReadOnlyMode( true )
                );
@@ -1099,7 +1117,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '1:Some_Page:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1124,7 +1142,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1148,7 +1166,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1183,7 +1201,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1218,7 +1236,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1241,7 +1259,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1277,7 +1295,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '0:SomeDbKey:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1313,7 +1331,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '0:SomeDbKey:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1337,7 +1355,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1382,7 +1400,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1417,7 +1435,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->will( $this->returnValue( $cachedItem ) );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1455,7 +1473,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->will( $this->returnValue( false ) );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1479,7 +1497,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1520,7 +1538,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1556,7 +1574,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
        public function testGetWatchedItemsForUser_optionsAndEmptyResult( $forWrite, $dbType ) {
                $mockDb = $this->getMockDb();
                $mockCache = $this->getMockCache();
-               $mockLoadBalancer = $this->getMockLoadBalancer( $mockDb, $dbType );
+               $mockLoadBalancer = $this->getMockLBFactory( $mockDb, $dbType );
                $user = $this->getMockNonAnonUserWithId( 1 );
 
                $mockDb->expects( $this->once() )
@@ -1585,7 +1603,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
        public function testGetWatchedItemsForUser_badSortOptionThrowsException() {
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $this->getMockDb() ),
+                       $this->getMockLBFactory( $this->getMockDb() ),
                        $this->getMockCache(),
                        $this->getMockReadOnlyMode()
                );
@@ -1627,7 +1645,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1664,7 +1682,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->will( $this->returnValue( false ) );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1688,7 +1706,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1756,7 +1774,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1807,7 +1825,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1869,7 +1887,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1910,7 +1928,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1937,7 +1955,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( $this->anything() );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1962,7 +1980,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -1996,7 +2014,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -2042,7 +2060,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '0:SomeDbKey:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -2082,7 +2100,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '0:SomeDbKey:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -2175,7 +2193,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '0:SomeTitle:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -2243,7 +2261,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '0:SomeDbKey:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -2318,7 +2336,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '0:SomeDbKey:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -2386,7 +2404,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '0:SomeDbKey:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -2465,7 +2483,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '0:SomeDbKey:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -2511,7 +2529,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
        public function testSetNotificationTimestampsForUser_anonUser() {
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $this->getMockDb() ),
+                       $this->getMockLBFactory( $this->getMockDb() ),
                        $this->getMockCache(),
                        $this->getMockReadOnlyMode()
                );
@@ -2538,7 +2556,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        } ) );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $this->getMockCache(),
                        $this->getMockReadOnlyMode()
                );
@@ -2568,7 +2586,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        } ) );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $this->getMockCache(),
                        $this->getMockReadOnlyMode()
                );
@@ -2607,7 +2625,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $this->getMockCache(),
                        $this->getMockReadOnlyMode()
                );
@@ -2650,7 +2668,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -2691,7 +2709,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                $mockCache->expects( $this->never() )->method( 'delete' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );
@@ -2735,7 +2753,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase {
                        ->with( '0:SomeDbKey:1' );
 
                $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockLBFactory( $mockDb ),
                        $mockCache,
                        $this->getMockReadOnlyMode()
                );