Skip to content

Commit 1f53cfb

Browse files
committed
wfGetDB() → MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection()
Newly deprecated in MediaWiki 1.39. The satire just keeps continuing.
1 parent eb44d7d commit 1f53cfb

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

TPCPatchMap.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* @author Nmlgc
88
*/
99

10+
use MediaWiki\MediaWikiServices;
11+
1012
class TPCPatchMap {
1113

1214
protected static function mergePatch( &$map, &$patch ) {
@@ -27,7 +29,7 @@ protected static function mergePatch( &$map, &$patch ) {
2729
* @return bool `true` if the given page is part of `tpc_tl_source_pages`.
2830
*/
2931
public static function isTLIncludedPage( int $namespace, string $title ): bool {
30-
$dbr = wfGetDB( DB_REPLICA );
32+
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_REPLICA );
3133
return $dbr->selectRow( 'tpc_tl_source_pages', 1, array(
3234
'tlsp_namespace' => $namespace,
3335
'tlsp_title' => $title
@@ -39,7 +41,7 @@ public static function isTLIncludedPage( int $namespace, string $title ): bool {
3941
* See tpc_patch_map.sql for the format.
4042
*/
4143
public static function buildTLMapping( string $game, string $lang ) {
42-
$dbr = wfGetDB( DB_REPLICA );
44+
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_REPLICA );
4345
$tl = $dbr->selectRow( 'tpc_tl_patches', 'tl_patch', array( 'tl_code' => $lang ) );
4446
if ( $tl === false ) {
4547
return null;
@@ -52,7 +54,7 @@ public static function buildTLMapping( string $game, string $lang ) {
5254
}
5355

5456
protected static function getMapping( Title &$title ) {
55-
$dbr = wfGetDB( DB_REPLICA );
57+
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_REPLICA );
5658
// Get old value
5759
$map = $dbr->selectRow( 'tpc_patch_map', '*', array(
5860
'pm_namespace' => $title->getNamespace(),
@@ -77,7 +79,7 @@ public static function update( $title, $patch, $game = null, $target = null ) {
7779
return;
7880
}
7981

80-
$dbw = wfGetDB( DB_MASTER );
82+
$dbw = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_PRIMARY );
8183
$inserts = array(
8284
'pm_namespace' => $title->getNamespace(),
8385
'pm_title' => $title->getText(),
@@ -139,7 +141,7 @@ public static function isPatchRootPage( $title ) {
139141
}
140142

141143
public static function getPatchRootPages() {
142-
$dbr = wfGetDB( DB_REPLICA );
144+
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_REPLICA );
143145
return $dbr->select(
144146
'page',
145147
array( 'page_namespace', 'page_title'),

TouhouPatchCenter.body.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public static function onDatabaseUpdate( DatabaseUpdater $updater ) {
286286
// ---------------
287287

288288
public static function clearDatabase() {
289-
$dbw = wfGetDB( DB_MASTER );
289+
$dbw = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_PRIMARY );
290290
$dbw->delete( 'tpc_patch_map', '*' );
291291
$dbw->delete( 'tpc_tl_patches', '*' );
292292
$dbw->delete( 'tpc_tl_source_pages', '*' );

hooks/TPCInclude.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* {{thcrap_prefix_file_include}}
1212
*/
1313

14+
use MediaWiki\MediaWikiServices;
15+
1416
class TPCInclude {
1517

1618
protected static function getGame( &$tpcState, &$temp ) {
@@ -70,7 +72,7 @@ public static function onTLInclude( &$tpcState, &$title, &$temp ) {
7072
$page = $temp->params[1];
7173
$targetTitle = self::getTitleFromLink( $title, $page );
7274

73-
$dbw = wfGetDB( DB_MASTER );
75+
$dbw = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_PRIMARY );
7476
$insert = array(
7577
'tlsp_namespace' => $targetTitle->getNamespace(),
7678
'tlsp_title' => $targetTitle->getText(),

hooks/TPCTLPatches.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* @author Nmlgc
1111
*/
1212

13+
use MediaWiki\MediaWikiServices;
14+
1315
class TPCTLPatches {
1416

1517
// All mappings that have been written to or read from the database.
@@ -31,7 +33,7 @@ public static function get() {
3133

3234
public static function update( $mappings ) {
3335
self::$patches = array_merge( self::$patches, $mappings );
34-
$dbw = wfGetDB( DB_MASTER );
36+
$dbw = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_PRIMARY );
3537
$rows = array();
3638
foreach ( $mappings as $patch => $lang ) {
3739
$rows[] = array(

maintenance/parseall.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* @author Nmlgc
88
*/
99

10+
use MediaWiki\MediaWikiServices;
11+
1012
require_once( dirname( __FILE__ ) . "/../../../maintenance/Maintenance.php" );
1113

1214
class TPCRebuild extends Maintenance {
@@ -23,7 +25,7 @@ public function logAndEval( $i, $num, $pad, Title $title ) {
2325
}
2426

2527
public function parsePatchMap() {
26-
$dbr = wfGetDB( DB_REPLICA );
28+
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_REPLICA );
2729
$files = $dbr->select( 'tpc_patch_map', array( 'pm_namespace', 'pm_title' ) );
2830
$num = $files->numRows();
2931
$i = 1;
@@ -36,7 +38,7 @@ public function parsePatchMap() {
3638
}
3739

3840
public function parseTranslatablePages() {
39-
$dbr = wfGetDB( DB_REPLICA );
41+
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getConnection( DB_REPLICA );
4042
$sourcePages = $dbr->select( 'tpc_tl_source_pages', '*' );
4143
$patches = $dbr->select( 'tpc_tl_patches', 'tl_code' );
4244
$num = ( $sourcePages->numRows() * $patches->numRows() );

0 commit comments

Comments
 (0)