diff --git a/extension.json b/extension.json index 3eba486d0..6969f7934 100644 --- a/extension.json +++ b/extension.json @@ -42,7 +42,12 @@ "SpecialPages": { "DeletedWikis": "Miraheze\\ManageWiki\\Specials\\SpecialDeletedWikis", "ManageWiki": "Miraheze\\ManageWiki\\Specials\\SpecialManageWiki", - "ManageWikiDefaultPermissions": "Miraheze\\ManageWiki\\Specials\\SpecialManageWikiDefaultPermissions" + "ManageWikiDefaultPermissions": { + "class": "Miraheze\\ManageWiki\\Specials\\SpecialManageWikiDefaultPermissions", + "services": [ + "CreateWikiDataFactory" + ] + } }, "JobClasses": { "MWScriptJob": "Miraheze\\ManageWiki\\Jobs\\MWScriptJob", @@ -121,12 +126,6 @@ "CreateWikiDataFactoryBuilder": [ "Miraheze\\ManageWiki\\Hooks::onCreateWikiDataFactoryBuilder" ], - "CreateWikiJsonBuilder": [ - "Miraheze\\ManageWiki\\Hooks::onCreateWikiDataFactoryBuilder" - ], - "CreateWikiPhpBuilder": [ - "Miraheze\\ManageWiki\\Hooks::onCreateWikiDataFactoryBuilder" - ], "CreateWikiStatePrivate": [ "Miraheze\\ManageWiki\\Hooks::onCreateWikiStatePrivate" ], diff --git a/includes/Helpers/ManageWikiExtensions.php b/includes/Helpers/ManageWikiExtensions.php index 8f706739b..18ae248b7 100644 --- a/includes/Helpers/ManageWikiExtensions.php +++ b/includes/Helpers/ManageWikiExtensions.php @@ -4,8 +4,6 @@ use MediaWiki\Config\Config; use MediaWiki\MediaWikiServices; -use Miraheze\CreateWiki\CreateWikiJson; -use Miraheze\CreateWiki\CreateWikiPhp; use Miraheze\CreateWiki\RemoteWiki; use Wikimedia\Rdbms\DBConnRef; @@ -141,7 +139,6 @@ public function hasChanges(): bool { */ public function commit() { $createWikiHookRunner = MediaWikiServices::getInstance()->get( 'CreateWikiHookRunner' ); - $remoteWiki = new RemoteWiki( $this->wiki, $createWikiHookRunner ); foreach ( $this->liveExts as $name => $extConfig ) { @@ -196,13 +193,11 @@ public function commit() { } $this->write(); - if ( $this->config->get( 'CreateWikiUsePhpCache' ) ) { - $cWP = new CreateWikiPhp( $this->wiki, $createWikiHookRunner ); - $cWP->resetWiki(); - } else { - $cWJ = new CreateWikiJson( $this->wiki, $createWikiHookRunner ); - $cWJ->resetWiki(); - } + + $dataFactory = MediaWikiServices::getInstance()->get( 'CreateWikiDataFactory' ); + $data = $dataFactory->newInstance( $this->wiki ); + $data->resetWikiData( isNewChanges: true ); + $this->committed = true; $this->logParams = [ diff --git a/includes/Helpers/ManageWikiNamespaces.php b/includes/Helpers/ManageWikiNamespaces.php index 6cafe7872..c0bef8c6d 100644 --- a/includes/Helpers/ManageWikiNamespaces.php +++ b/includes/Helpers/ManageWikiNamespaces.php @@ -5,8 +5,6 @@ use MediaWiki\Config\Config; use MediaWiki\MediaWikiServices; use MediaWiki\SpecialPage\SpecialPage; -use Miraheze\CreateWiki\CreateWikiJson; -use Miraheze\CreateWiki\CreateWikiPhp; use Miraheze\ManageWiki\Jobs\NamespaceMigrationJob; use Wikimedia\Rdbms\DBConnRef; @@ -243,21 +241,16 @@ public function commit( bool $runNamespaceMigrationJob = true ) { } } - if ( $this->wiki != 'default' && $runNamespaceMigrationJob ) { + if ( $this->wiki !== 'default' && $runNamespaceMigrationJob ) { $job = new NamespaceMigrationJob( SpecialPage::getTitleFor( 'ManageWiki' ), $jobParams ); MediaWikiServices::getInstance()->getJobQueueGroupFactory()->makeJobQueueGroup()->push( $job ); } } if ( $this->wiki !== 'default' ) { - $createWikiHookRunner = MediaWikiServices::getInstance()->get( 'CreateWikiHookRunner' ); - if ( $this->config->get( 'CreateWikiUsePhpCache' ) ) { - $cWP = new CreateWikiPhp( $this->wiki, $createWikiHookRunner ); - $cWP->resetWiki(); - } else { - $cWJ = new CreateWikiJson( $this->wiki, $createWikiHookRunner ); - $cWJ->resetWiki(); - } + $dataFactory = MediaWikiServices::getInstance()->get( 'CreateWikiDataFactory' ); + $data = $dataFactory->newInstance( $this->wiki ); + $data->resetWikiData( isNewChanges: true ); } $this->committed = true; diff --git a/includes/Helpers/ManageWikiPermissions.php b/includes/Helpers/ManageWikiPermissions.php index c8eea7c41..5f5fbf962 100644 --- a/includes/Helpers/ManageWikiPermissions.php +++ b/includes/Helpers/ManageWikiPermissions.php @@ -5,8 +5,6 @@ use MediaWiki\Config\Config; use MediaWiki\MediaWikiServices; use MediaWiki\User\User; -use Miraheze\CreateWiki\CreateWikiJson; -use Miraheze\CreateWiki\CreateWikiPhp; use Wikimedia\Rdbms\DBConnRef; /** @@ -214,15 +212,11 @@ public function commit() { } if ( $this->wiki !== 'default' ) { - $createWikiHookRunner = MediaWikiServices::getInstance()->get( 'CreateWikiHookRunner' ); - if ( $this->config->get( 'CreateWikiUsePhpCache' ) ) { - $cWP = new CreateWikiPhp( $this->wiki, $createWikiHookRunner ); - $cWP->resetWiki(); - } else { - $cWJ = new CreateWikiJson( $this->wiki, $createWikiHookRunner ); - $cWJ->resetWiki(); - } + $dataFactory = MediaWikiServices::getInstance()->get( 'CreateWikiDataFactory' ); + $data = $dataFactory->newInstance( $this->wiki ); + $data->resetWikiData( isNewChanges: true ); } + $this->committed = true; } diff --git a/includes/Helpers/ManageWikiSettings.php b/includes/Helpers/ManageWikiSettings.php index 942dd1177..803a6fc35 100644 --- a/includes/Helpers/ManageWikiSettings.php +++ b/includes/Helpers/ManageWikiSettings.php @@ -4,8 +4,6 @@ use MediaWiki\Config\Config; use MediaWiki\MediaWikiServices; -use Miraheze\CreateWiki\CreateWikiJson; -use Miraheze\CreateWiki\CreateWikiPhp; use Wikimedia\Rdbms\DBConnRef; /** @@ -166,14 +164,10 @@ public function commit() { ManageWikiInstaller::process( $this->wiki, [ 'mwscript' => $this->scripts ] ); } - $createWikiHookRunner = MediaWikiServices::getInstance()->get( 'CreateWikiHookRunner' ); - if ( $this->config->get( 'CreateWikiUsePhpCache' ) ) { - $cWP = new CreateWikiPhp( $this->wiki, $createWikiHookRunner ); - $cWP->resetWiki(); - } else { - $cWJ = new CreateWikiJson( $this->wiki, $createWikiHookRunner ); - $cWJ->resetWiki(); - } + $dataFactory = MediaWikiServices::getInstance()->get( 'CreateWikiDataFactory' ); + $data = $dataFactory->newInstance( $this->wiki ); + $data->resetWikiData( isNewChanges: true ); + $this->committed = true; $this->logParams = [ diff --git a/includes/Specials/SpecialManageWikiDefaultPermissions.php b/includes/Specials/SpecialManageWikiDefaultPermissions.php index 801a47376..d7aca9b6a 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() ); @@ -267,8 +254,8 @@ public function onSubmitCacheResetForm( $formData ) { ->getMaintenanceConnectionRef( DB_PRIMARY, [], $this->config->get( 'CreateWikiDatabase' ) ); // Reset the cache or else the changes won't work - $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', 'cache-reset' ); $logEntry->setPerformer( $this->getContext()->getUser() ); diff --git a/maintenance/populateGroupPermissionsWithDefaults.php b/maintenance/populateGroupPermissionsWithDefaults.php index 64e360738..49412d216 100644 --- a/maintenance/populateGroupPermissionsWithDefaults.php +++ b/maintenance/populateGroupPermissionsWithDefaults.php @@ -11,8 +11,6 @@ use Maintenance; use MediaWiki\MainConfigNames; -use Miraheze\CreateWiki\CreateWikiJson; -use Miraheze\CreateWiki\CreateWikiPhp; use Miraheze\ManageWiki\Helpers\ManageWikiPermissions; class PopulateGroupPermissionsWithDefaults extends Maintenance { @@ -69,19 +67,9 @@ public function execute() { $mwPermissions->commit(); - if ( $this->getConfig()->get( 'CreateWikiUsePhpCache' ) ) { - $cWP = new CreateWikiPhp( - $this->getConfig()->get( MainConfigNames::DBname ), - $this->getServiceContainer()->get( 'CreateWikiHookRunner' ) - ); - $cWP->resetWiki(); - } else { - $cWJ = new CreateWikiJson( - $this->getConfig()->get( MainConfigNames::DBname ), - $this->getServiceContainer()->get( 'CreateWikiHookRunner' ) - ); - $cWJ->resetWiki(); - } + $dataFactory = $this->getServiceContainer()->get( 'CreateWikiDataFactory' ); + $data = $dataFactory->newInstance( $this->getConfig()->get( MainConfigNames::DBname ) ); + $data->resetWikiData( isNewChanges: true ); } } } diff --git a/maintenance/populateNamespacesWithDefaults.php b/maintenance/populateNamespacesWithDefaults.php index c3fa51424..7da4d8cd4 100644 --- a/maintenance/populateNamespacesWithDefaults.php +++ b/maintenance/populateNamespacesWithDefaults.php @@ -11,8 +11,6 @@ use Maintenance; use MediaWiki\MainConfigNames; -use Miraheze\CreateWiki\CreateWikiJson; -use Miraheze\CreateWiki\CreateWikiPhp; use Miraheze\ManageWiki\Helpers\ManageWikiNamespaces; class PopulateNamespacesWithDefaults extends Maintenance { @@ -57,19 +55,9 @@ public function execute() { $mwNamespaces->commit(); } - if ( $this->getConfig()->get( 'CreateWikiUsePhpCache' ) ) { - $cWP = new CreateWikiPhp( - $this->getConfig()->get( MainConfigNames::DBname ), - $this->getServiceContainer()->get( 'CreateWikiHookRunner' ) - ); - $cWP->resetWiki(); - } else { - $cWJ = new CreateWikiJson( - $this->getConfig()->get( MainConfigNames::DBname ), - $this->getServiceContainer()->get( 'CreateWikiHookRunner' ) - ); - $cWJ->resetWiki(); - } + $dataFactory = $this->getServiceContainer()->get( 'CreateWikiDataFactory' ); + $data = $dataFactory->newInstance( $this->getConfig()->get( MainConfigNames::DBname ) ); + $data->resetWikiData( isNewChanges: true ); } } }