Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace usages of RemoteWiki (T12714) #488

Merged
merged 25 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"ManageWikiDefaultPermissions": {
"class": "Miraheze\\ManageWiki\\Specials\\SpecialManageWikiDefaultPermissions",
"services": [
"CreateWikiDataFactory"
"CreateWikiDataFactory",
"RemoteWikiFactory"
]
}
},
Expand Down
5 changes: 2 additions & 3 deletions includes/Api/ApiModifyServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use ApiBase;
use MediaWiki\MediaWikiServices;
use Miraheze\CreateWiki\RemoteWiki;
use Miraheze\ManageWiki\ManageWiki;
use Wikimedia\ParamValidator\ParamValidator;

Expand Down Expand Up @@ -44,8 +43,8 @@ public function execute() {
}

private function setServer( string $wiki, string $server ) {
$createWikiHookRunner = MediaWikiServices::getInstance()->get( 'CreateWikiHookRunner' );
$remoteWiki = new RemoteWiki( $wiki, $createWikiHookRunner );
$remoteWikiFactory = MediaWikiServices::getInstance()->get( 'RemoteWikiFactory' );
$remoteWiki = $remoteWikiFactory->newInstance( $wiki );
$remoteWiki->setServerName( $server );
$remoteWiki->commit();
}
Expand Down
21 changes: 11 additions & 10 deletions includes/Api/QueryWikiConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
use ApiBase;
use ApiQueryBase;
use MediaWiki\MediaWikiServices;
use Miraheze\CreateWiki\RemoteWiki;
use Miraheze\CreateWiki\Exceptions\MissingWikiError;
use Miraheze\ManageWiki\Helpers\ManageWikiExtensions;
use Miraheze\ManageWiki\Helpers\ManageWikiPermissions;
use Miraheze\ManageWiki\Helpers\ManageWikiSettings;
use RuntimeException;
use Wikimedia\ParamValidator\ParamValidator;

class QueryWikiConfig extends ApiQueryBase {
Expand All @@ -24,23 +25,23 @@ public function execute() {

$data = [];

$createWikiHookRunner = MediaWikiServices::getInstance()->get( 'CreateWikiHookRunner' );
$remoteWikiFactory = MediaWikiServices::getInstance()->get( 'RemoteWikiFactory' );

foreach ( $params['wikis'] as $wiki ) {
$wikiObj = new RemoteWiki( $wiki, $createWikiHookRunner );

if ( $wikiObj === null ) {
try {
$remoteWiki = $remoteWikiFactory->newInstance( $wiki );
} catch ( MissingWikiError | RuntimeException $e ) {
$this->addWarning( [ 'apiwarn-wikiconfig-wikidoesnotexist', $wiki ] );
continue;
}

$wikiData = [
'name' => $wiki,
'sitename' => $wikiObj->getSitename(),
'closed' => (bool)$wikiObj->isClosed(),
'inactive' => (bool)$wikiObj->isInactive(),
'inactive-exempt' => (bool)$wikiObj->isInactiveExempt(),
'private' => (bool)$wikiObj->isPrivate()
'sitename' => $remoteWiki->getSitename(),
'closed' => $remoteWiki->isClosed(),
'inactive' => $remoteWiki->isInactive(),
'inactive-exempt' => $remoteWiki->isInactiveExempt(),
'private' => $remoteWiki->isPrivate(),
];

$mwSet = new ManageWikiSettings( $wiki );
Expand Down
12 changes: 6 additions & 6 deletions includes/FormFactory/ManageWikiFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use MediaWiki\HTMLForm\HTMLForm;
use MediaWiki\MediaWikiServices;
use MediaWiki\Output\OutputPage;
use Miraheze\CreateWiki\RemoteWiki;
use Miraheze\CreateWiki\Services\RemoteWikiFactory;
use Miraheze\ManageWiki\Helpers\ManageWikiOOUIForm;
use Miraheze\ManageWiki\ManageWiki;
use UnexpectedValueException;
Expand All @@ -21,7 +21,7 @@ public function getFormDescriptor(
string $dbName,
bool $ceMW,
IContextSource $context,
RemoteWiki $wiki,
RemoteWikiFactory $remoteWiki,
Config $config,
string $special = '',
string $filtered = ''
Expand All @@ -31,12 +31,12 @@ public function getFormDescriptor(
$context->getLanguage()->getDir()
);

return ManageWikiFormFactoryBuilder::buildDescriptor( $module, $dbName, $ceMW, $context, $wiki, $special, $filtered, $config );
return ManageWikiFormFactoryBuilder::buildDescriptor( $module, $dbName, $ceMW, $context, $remoteWiki, $special, $filtered, $config );
}

public function getForm(
string $wiki,
RemoteWiki $remoteWiki,
RemoteWikiFactory $remoteWiki,
IContextSource $context,
Config $config,
string $module,
Expand Down Expand Up @@ -78,7 +78,7 @@ protected function submitForm(
string $module,
bool $ceMW,
string $dbName,
RemoteWiki $wiki,
RemoteWikiFactory $remoteWiki,
DBConnRef $dbw,
Config $config,
string $special = '',
Expand All @@ -94,7 +94,7 @@ protected function submitForm(
$form->getButtons();
$formData['reason'] = $form->getField( 'reason' )->loadDataFromRequest( $form->getRequest() );

$mwReturn = ManageWikiFormFactoryBuilder::submissionHandler( $formData, $form, $module, $dbName, $context, $wiki, $dbw, $config, $special, $filtered );
$mwReturn = ManageWikiFormFactoryBuilder::submissionHandler( $formData, $form, $module, $dbName, $context, $remoteWiki, $dbw, $config, $special, $filtered );

if ( !empty( $mwReturn ) ) {
$errorOut = [];
Expand Down
Loading
Loading