From a5c9d99b00a4347b5f0ae25b120ae5855d18b0ed Mon Sep 17 00:00:00 2001 From: CosmicAlpha Date: Wed, 9 Oct 2024 03:19:36 +0800 Subject: [PATCH] Use CreateWikiDataFactory --- .../SpecialManageWikiDefaultPermissions.php | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/includes/Specials/SpecialManageWikiDefaultPermissions.php b/includes/Specials/SpecialManageWikiDefaultPermissions.php index 801a47376..b849f778f 100644 --- a/includes/Specials/SpecialManageWikiDefaultPermissions.php +++ b/includes/Specials/SpecialManageWikiDefaultPermissions.php @@ -11,10 +11,9 @@ use MediaWiki\HTMLForm\HTMLForm; use MediaWiki\MediaWikiServices; use MediaWiki\SpecialPage\SpecialPage; -use Miraheze\CreateWiki\CreateWikiJson; -use Miraheze\CreateWiki\CreateWikiPhp; use Miraheze\CreateWiki\Hooks\CreateWikiHookRunner; use Miraheze\CreateWiki\RemoteWiki; +use Miraheze\CreateWiki\Services\CreateWikiDataFactory; use Miraheze\ManageWiki\FormFactory\ManageWikiFormFactory; use Miraheze\ManageWiki\Helpers\ManageWikiPermissions; use Miraheze\ManageWiki\Hooks; @@ -22,17 +21,16 @@ class SpecialManageWikiDefaultPermissions extends SpecialPage { - /** @var Config */ - private $config; + private Config $config; + private CreateWikiDataFactory $dataFactory; + private CreateWikiHookRunner $createWikiHookRunner; - /** @var CreateWikiHookRunner */ - private $createWikiHookRunner; - - public function __construct() { + public function __construct( CreateWikiDataFactory $dataFactory ) { parent::__construct( 'ManageWikiDefaultPermissions' ); $this->config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'managewiki' ); $this->createWikiHookRunner = MediaWikiServices::getInstance()->get( 'CreateWikiHookRunner' ); + $this->dataFactory = $dataFactory; } public function canModify() { @@ -224,19 +222,8 @@ public function onSubmitSettingsResetForm( $formData ) { ); // Reset the cache or else the changes won't work - if ( $this->config->get( 'CreateWikiUsePhpCache' ) ) { - $cWP = new CreateWikiPhp( - $this->config->get( 'DBname' ), - $this->createWikiHookRunner - ); - $cWP->resetWiki(); - } else { - $cWJ = new CreateWikiJson( - $this->config->get( 'DBname' ), - $this->createWikiHookRunner - ); - $cWJ->resetWiki(); - } + $data = $this->dataFactory->newInstance( $this->config->get( 'DBname' ) ); + $data->resetWikiData( isNewChanges: true ); $logEntry = new ManualLogEntry( 'managewiki', 'settings-reset' ); $logEntry->setPerformer( $this->getContext()->getUser() );