Replace some of the deprecated wfGetLBFactory() calls
authorWMDE-Fisch <christoph.jauera@wikimedia.de>
Tue, 7 Feb 2017 13:31:46 +0000 (14:31 +0100)
committerWMDE-Fisch <christoph.jauera@wikimedia.de>
Tue, 7 Feb 2017 13:41:09 +0000 (14:41 +0100)
Change-Id: I87aa0ebe273706438f1634167de8c60f51432878

includes/AjaxDispatcher.php
includes/FileDeleteForm.php
includes/WatchedItemStore.php
includes/filebackend/filejournal/DBFileJournal.php
includes/installer/MysqlUpdater.php
includes/jobqueue/jobs/HTMLCacheUpdateJob.php
includes/revisiondelete/RevDelList.php
includes/specials/SpecialExport.php

index d444a27..2adbc80 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup Ajax
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * @defgroup Ajax Ajax
  */
@@ -135,7 +137,8 @@ class AjaxDispatcher {
                                        }
 
                                        // Make sure DB commit succeeds before sending a response
-                                       wfGetLBFactory()->commitMasterChanges( __METHOD__ );
+                                       $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+                                       $lbFactory->commitMasterChanges( __METHOD__ );
 
                                        $result->sendHeaders();
                                        $result->printText();
index 82af081..f284d92 100644 (file)
@@ -206,7 +206,8 @@ class FileDeleteForm {
                                        $dbw->endAtomic( __METHOD__ );
                                } else {
                                        // Page deleted but file still there? rollback page delete
-                                       wfGetLBFactory()->rollbackMasterChanges( __METHOD__ );
+                                       $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+                                       $lbFactory->rollbackMasterChanges( __METHOD__ );
                                }
                        } else {
                                // Done; nothing changed
index 3cdc59c..858d87b 100644 (file)
@@ -2,6 +2,7 @@
 
 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
 use MediaWiki\Linker\LinkTarget;
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Assert\Assert;
 use Wikimedia\ScopedCallback;
 
@@ -734,7 +735,7 @@ class WatchedItemStore implements StatsdAwareInterface {
                                        global $wgUpdateRowsPerQuery;
 
                                        $dbw = $this->getConnectionRef( DB_MASTER );
-                                       $factory = wfGetLBFactory();
+                                       $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
                                        $ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
 
                                        $watchersChunks = array_chunk( $watchers, $wgUpdateRowsPerQuery );
index 2e06c40..62e635d 100644 (file)
@@ -22,6 +22,8 @@
  * @author Aaron Schulz
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Version of FileJournal that logs to a DB table
  * @since 1.20
@@ -180,7 +182,7 @@ class DBFileJournal extends FileJournal {
        protected function getMasterDB() {
                if ( !$this->dbw ) {
                        // Get a separate connection in autocommit mode
-                       $lb = wfGetLBFactory()->newMainLB();
+                       $lb =  MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->newMainLB();
                        $this->dbw = $lb->getConnection( DB_MASTER, [], $this->wiki );
                        $this->dbw->clearFlag( DBO_TRX );
                }
index 9be6c3d..7fa5a3d 100644 (file)
@@ -20,6 +20,7 @@
  * @file
  * @ingroup Deployment
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * Mysql update list and mysql-specific update functions.
@@ -853,7 +854,8 @@ class MysqlUpdater extends DatabaseUpdater {
                        foreach ( $res as $row ) {
                                $count = ( $count + 1 ) % 100;
                                if ( $count == 0 ) {
-                                       wfGetLBFactory()->waitForReplication( [ 'wiki' => wfWikiID() ] );
+                                       $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+                                       $lbFactory->waitForReplication( [ 'wiki' => wfWikiID() ] );
                                }
                                $this->db->insert( 'templatelinks',
                                        [
index f09ba57..2d816f9 100644 (file)
@@ -22,6 +22,8 @@
  * @ingroup Cache
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Job to purge the cache for all pages that link to or use another page or file
  *
@@ -113,7 +115,7 @@ class HTMLCacheUpdateJob extends Job {
                $touchTimestamp = wfTimestampNow();
 
                $dbw = wfGetDB( DB_MASTER );
-               $factory = wfGetLBFactory();
+               $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
                $ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
                // Update page_touched (skipping pages already touched since the root job).
                // Check $wgUpdateRowsPerQuery for sanity; batch jobs are sized by that already.
index 833e38b..64a6aec 100644 (file)
@@ -19,6 +19,8 @@
  * @ingroup RevisionDelete
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Abstract base class for a list of deletable items. The list class
  * needs to be able to make a query from a set of identifiers to pull
@@ -255,7 +257,8 @@ abstract class RevDelList extends RevisionListBase {
                $status->merge( $this->doPreCommitUpdates() );
                if ( !$status->isOK() ) {
                        // Fatal error, such as no configured archive directory or I/O failures
-                       wfGetLBFactory()->rollbackMasterChanges( __METHOD__ );
+                       $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+                       $lbFactory->rollbackMasterChanges( __METHOD__ );
                        return $status;
                }
 
index bf535a6..2d6ba4a 100644 (file)
@@ -23,6 +23,8 @@
  * @ingroup SpecialPage
  */
 
+use Mediawiki\MediaWikiServices;
+
 /**
  * A special page that allows users to export pages in a XML file
  *
@@ -374,7 +376,7 @@ class SpecialExport extends SpecialPage {
                        $buffer = WikiExporter::BUFFER;
                } else {
                        // Use an unbuffered query; histories may be very long!
-                       $lb = wfGetLBFactory()->newMainLB();
+                       $lb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->newMainLB();
                        $db = $lb->getConnection( DB_REPLICA );
                        $buffer = WikiExporter::STREAM;