Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal-Omega authored Nov 20, 2024
1 parent e6224e8 commit b5dbd21
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 40 deletions.
9 changes: 4 additions & 5 deletions includes/FormFactory/ManageWikiFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Miraheze\ManageWiki\Helpers\ManageWikiOOUIForm;
use Miraheze\ManageWiki\ManageWiki;
use UnexpectedValueException;
use Wikimedia\Rdbms\DBConnRef;
use Wikimedia\Rdbms\IDatabase;

class ManageWikiFormFactory {

Expand Down Expand Up @@ -44,9 +44,8 @@ public function getForm(
string $filtered = '',
string $formClass = ManageWikiOOUIForm::class
) {
$dbw = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
->getMainLB( $config->get( 'CreateWikiDatabase' ) )
->getMaintenanceConnectionRef( DB_PRIMARY, [], $config->get( 'CreateWikiDatabase' ) );
$dbw = MediaWikiServices::getInstance()->getConnectionProvider()
->getPrimaryDatabase( 'virtual-createwiki' );

$ceMW = ManageWiki::checkPermission( $remoteWiki, $context->getUser(), $module );

Expand Down Expand Up @@ -79,7 +78,7 @@ protected function submitForm(
bool $ceMW,
string $dbName,
RemoteWikiFactory $remoteWiki,
DBConnRef $dbw,
IDatabase $dbw,
Config $config,
string $special = '',
string $filtered = ''
Expand Down
6 changes: 3 additions & 3 deletions includes/FormFactory/ManageWikiFormFactoryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Miraheze\ManageWiki\Helpers\ManageWikiSettings;
use Miraheze\ManageWiki\Helpers\ManageWikiTypes;
use Miraheze\ManageWiki\ManageWiki;
use Wikimedia\Rdbms\DBConnRef;
use Wikimedia\Rdbms\IDatabase;

class ManageWikiFormFactoryBuilder {

Expand Down Expand Up @@ -816,7 +816,7 @@ public static function submissionHandler(
string $dbName,
IContextSource $context,
RemoteWikiFactory $remoteWiki,
DBConnRef $dbw,
IDatabase $dbw,
Config $config,
string $special = '',
string $filtered = ''
Expand Down Expand Up @@ -872,7 +872,7 @@ private static function submissionCore(
string $dbName,
IContextSource $context,
RemoteWikiFactory $remoteWiki,
DBConnRef $dbw,
IDatabase $dbw,
Config $config
) {
$mwActions = [
Expand Down
5 changes: 2 additions & 3 deletions includes/Helpers/ManageWikiDeletedWikiPager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ class ManageWikiDeletedWikiPager extends TablePager {

public function __construct( $page ) {
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'managewiki' );
$this->mDb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
->getMainLB( $config->get( 'CreateWikiDatabase' ) )
->getMaintenanceConnectionRef( DB_REPLICA, [], $config->get( 'CreateWikiDatabase' ) );
$this->mDb = MediaWikiServices::getInstance()->getConnectionProvider()
->getReplicaDatabase( 'virtual-createwiki' );

parent::__construct( $page->getContext(), $page->getLinkRenderer() );
}
Expand Down
9 changes: 4 additions & 5 deletions includes/Helpers/ManageWikiExtensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use MediaWiki\Config\Config;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\DBConnRef;
use Wikimedia\Rdbms\IDatabase;

/**
* Handler for all interactions with Extension changes within ManageWiki
Expand All @@ -16,7 +16,7 @@ class ManageWikiExtensions {
private $committed = false;
/** @var Config Configuration Object */
private $config;
/** @var DBConnRef Database Connection */
/** @var IDatabase Database Connection */
private $dbw;
/** @var array Extension configuration ($wgManageWikiExtensions) */
private $extConfig;
Expand Down Expand Up @@ -44,9 +44,8 @@ public function __construct( string $wiki ) {
$this->config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'managewiki' );
$this->extConfig = $this->config->get( 'ManageWikiExtensions' );

$this->dbw = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
->getMainLB( $this->config->get( 'CreateWikiDatabase' ) )
->getMaintenanceConnectionRef( DB_PRIMARY, [], $this->config->get( 'CreateWikiDatabase' ) );
$this->dbw = MediaWikiServices::getInstance()->getConnectionProvider()
->getPrimaryDatabase( 'virtual-createwiki' );

$exts = $this->dbw->selectRow(
'mw_settings',
Expand Down
9 changes: 4 additions & 5 deletions includes/Helpers/ManageWikiNamespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use MediaWiki\MediaWikiServices;
use MediaWiki\SpecialPage\SpecialPage;
use Miraheze\ManageWiki\Jobs\NamespaceMigrationJob;
use Wikimedia\Rdbms\DBConnRef;
use Wikimedia\Rdbms\IDatabase;

/**
* Handler for interacting with Namespace configuration
Expand All @@ -17,7 +17,7 @@ class ManageWikiNamespaces {
private $committed = false;
/** @var Config Configuration object */
private $config;
/** @var DBConnRef Database connection */
/** @var IDatabase Database connection */
private $dbw;
/** @var array Namespace IDs to be deleted */
private $deleteNamespaces = [];
Expand All @@ -44,9 +44,8 @@ public function __construct( string $wiki ) {
$this->wiki = $wiki;
$this->config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'managewiki' );

$this->dbw = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
->getMainLB( $this->config->get( 'CreateWikiDatabase' ) )
->getMaintenanceConnectionRef( DB_PRIMARY, [], $this->config->get( 'CreateWikiDatabase' ) );
$this->dbw = MediaWikiServices::getInstance()->getConnectionProvider()
->getPrimaryDatabase( 'virtual-createwiki' );

$namespaces = $this->dbw->select(
'mw_namespaces',
Expand Down
9 changes: 4 additions & 5 deletions includes/Helpers/ManageWikiPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use MediaWiki\Config\Config;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\User;
use Wikimedia\Rdbms\DBConnRef;
use Wikimedia\Rdbms\IDatabase;

/**
* Handler for interacting with Permissions
Expand All @@ -16,7 +16,7 @@ class ManageWikiPermissions {
private $committed = false;
/** @var Config Configuration object */
private $config;
/** @var DBConnRef Database connection */
/** @var IDatabase Database connection */
private $dbw;
/** @var array Deletion queue */
private $deleteGroups = [];
Expand All @@ -41,9 +41,8 @@ class ManageWikiPermissions {
public function __construct( string $wiki ) {
$this->wiki = $wiki;
$this->config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'managewiki' );
$this->dbw = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
->getMainLB( $this->config->get( 'CreateWikiDatabase' ) )
->getMaintenanceConnectionRef( DB_PRIMARY, [], $this->config->get( 'CreateWikiDatabase' ) );
$this->dbw = MediaWikiServices::getInstance()->getConnectionProvider()
->getPrimaryDatabase( 'virtual-createwiki' );

$perms = $this->dbw->select(
'mw_permissions',
Expand Down
9 changes: 4 additions & 5 deletions includes/Helpers/ManageWikiSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use MediaWiki\Config\Config;
use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\DBConnRef;
use Wikimedia\Rdbms\IDatabase;

/**
* Handler class for managing settings
Expand All @@ -15,7 +15,7 @@ class ManageWikiSettings {
private $committed = false;
/** @var Config Configuration object */
private $config;
/** @var DBConnRef Database object */
/** @var IDatabase Database object */
private $dbw;
/** @var array Current settings with their respective values */
private $liveSettings;
Expand Down Expand Up @@ -44,9 +44,8 @@ public function __construct( string $wiki ) {
$this->config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'managewiki' );
$this->settingsConfig = $this->config->get( 'ManageWikiSettings' );

$this->dbw = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
->getMainLB( $this->config->get( 'CreateWikiDatabase' ) )
->getMaintenanceConnectionRef( DB_PRIMARY, [], $this->config->get( 'CreateWikiDatabase' ) );
$this->dbw = MediaWikiServices::getInstance()->getConnectionProvider()
->getPrimaryDatabase( 'virtual-createwiki' );

$settings = $this->dbw->selectRow(
'mw_settings',
Expand Down
4 changes: 2 additions & 2 deletions includes/Hooks/ManageWikiCoreFormSubmissionHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

use MediaWiki\Context\IContextSource;
use Miraheze\CreateWiki\Services\RemoteWikiFactory;
use Wikimedia\Rdbms\DBConnRef;
use Wikimedia\Rdbms\IDatabase;

interface ManageWikiCoreFormSubmissionHook {

/**
* @param IContextSource $context
* @param string $dbName
* @param DBConnRef $dbw
* @param IDatabase $dbw
* @param array $formData
* @param RemoteWikiFactory &$remoteWiki
* @return void
Expand Down
5 changes: 2 additions & 3 deletions includes/ManageWiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ public static function handleMatrix( $conversion, $to ) {
public static function namespaceID( string $namespace ) {
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'managewiki' );

$dbr = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()
->getMainLB( $config->get( 'CreateWikiDatabase' ) )
->getMaintenanceConnectionRef( DB_REPLICA, [], $config->get( 'CreateWikiDatabase' ) );
$dbr = MediaWikiServices::getInstance()->getConnectionProvider()
->getReplicaDatabase( 'virtual-createwiki' );

$nsID = ( $namespace == '' ) ? false : $dbr->selectRow(
'mw_namespaces',
Expand Down
3 changes: 2 additions & 1 deletion maintenance/populateGroupPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public function execute() {
}
}

$dbw = $this->getDB( DB_PRIMARY, [], $this->getConfig()->get( 'CreateWikiDatabase' ) );
$connectionProvider = $this->getServiceContainer()->getConnectionProvider();
$dbw = $connectionProvider->getPrimaryDatabase( 'virtual-createwiki' );

foreach ( $grouparray as $groupname => $groupatr ) {
$check = $dbw->selectRow(
Expand Down
3 changes: 2 additions & 1 deletion maintenance/populateGroupPermissionsWithDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public function __construct() {
}

public function execute() {
$dbw = $this->getDB( DB_PRIMARY, [], $this->getConfig()->get( 'CreateWikiDatabase' ) );
$connectionProvider = $this->getServiceContainer()->getConnectionProvider();
$dbw = $connectionProvider->getPrimaryDatabase( 'virtual-createwiki' );

if ( $this->getOption( 'overwrite' ) ) {
$dbw->delete(
Expand Down
3 changes: 2 additions & 1 deletion maintenance/populateNamespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function execute() {
$this->fatalError( 'Disable ManageWiki Namespaces on this wiki.' );
}

$dbw = $this->getDB( DB_PRIMARY, [], $this->getConfig()->get( 'CreateWikiDatabase' ) );
$connectionProvider = $this->getServiceContainer()->getConnectionProvider();
$dbw = $connectionProvider->getPrimaryDatabase( 'virtual-createwiki' );

$namespaces = $this->getConfig()->get( MainConfigNames::CanonicalNamespaceNames ) + [ 0 => '<Main>' ];

Expand Down
3 changes: 2 additions & 1 deletion maintenance/populateNamespacesWithDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public function __construct() {
}

public function execute() {
$dbw = $this->getDB( DB_PRIMARY, [], $this->getConfig()->get( 'CreateWikiDatabase' ) );
$connectionProvider = $this->getServiceContainer()->getConnectionProvider();
$dbw = $connectionProvider->getPrimaryDatabase( 'virtual-createwiki' );

if ( $this->getOption( 'overwrite' ) ) {
$dbw->delete(
Expand Down

0 comments on commit b5dbd21

Please sign in to comment.