From ae3419f53202630837be5887a5539270526c6a63 Mon Sep 17 00:00:00 2001 From: WMDE-Fisch Date: Tue, 7 Feb 2017 14:31:46 +0100 Subject: [PATCH] Replace some of the deprecated wfGetLBFactory() calls Change-Id: I87aa0ebe273706438f1634167de8c60f51432878 --- includes/AjaxDispatcher.php | 5 ++++- includes/FileDeleteForm.php | 3 ++- includes/WatchedItemStore.php | 3 ++- includes/filebackend/filejournal/DBFileJournal.php | 4 +++- includes/installer/MysqlUpdater.php | 4 +++- includes/jobqueue/jobs/HTMLCacheUpdateJob.php | 4 +++- includes/revisiondelete/RevDelList.php | 5 ++++- includes/specials/SpecialExport.php | 4 +++- 8 files changed, 24 insertions(+), 8 deletions(-) diff --git a/includes/AjaxDispatcher.php b/includes/AjaxDispatcher.php index d444a2791f..2adbc80f3b 100644 --- a/includes/AjaxDispatcher.php +++ b/includes/AjaxDispatcher.php @@ -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(); diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 82af08140f..f284d924a0 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -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 diff --git a/includes/WatchedItemStore.php b/includes/WatchedItemStore.php index 3cdc59cda0..858d87bc59 100644 --- a/includes/WatchedItemStore.php +++ b/includes/WatchedItemStore.php @@ -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 ); diff --git a/includes/filebackend/filejournal/DBFileJournal.php b/includes/filebackend/filejournal/DBFileJournal.php index 2e06c40f72..62e635dd23 100644 --- a/includes/filebackend/filejournal/DBFileJournal.php +++ b/includes/filebackend/filejournal/DBFileJournal.php @@ -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 ); } diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 9be6c3d65c..7fa5a3da78 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -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', [ diff --git a/includes/jobqueue/jobs/HTMLCacheUpdateJob.php b/includes/jobqueue/jobs/HTMLCacheUpdateJob.php index f09ba57b53..2d816f9f06 100644 --- a/includes/jobqueue/jobs/HTMLCacheUpdateJob.php +++ b/includes/jobqueue/jobs/HTMLCacheUpdateJob.php @@ -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. diff --git a/includes/revisiondelete/RevDelList.php b/includes/revisiondelete/RevDelList.php index 833e38b2dc..64a6aec806 100644 --- a/includes/revisiondelete/RevDelList.php +++ b/includes/revisiondelete/RevDelList.php @@ -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; } diff --git a/includes/specials/SpecialExport.php b/includes/specials/SpecialExport.php index bf535a6f3a..2d6ba4ad4e 100644 --- a/includes/specials/SpecialExport.php +++ b/includes/specials/SpecialExport.php @@ -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; -- 2.20.1