Skip to content

Commit

Permalink
Use CreateWikiDataFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal-Omega authored Oct 8, 2024
1 parent cfda50c commit a5c9d99
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions includes/Specials/SpecialManageWikiDefaultPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,26 @@
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;
use Miraheze\ManageWiki\ManageWiki;

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() {
Expand Down Expand Up @@ -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() );
Expand Down

0 comments on commit a5c9d99

Please sign in to comment.