* @ingroup SpecialPage
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A special page that allows users to change page titles
*
$this->outputHeader();
$request = $this->getRequest();
- $target = !is_null( $par ) ? $par : $request->getVal( 'target' );
+ $target = $par ?? $request->getVal( 'target' );
// Yes, the use of getVal() and getText() is wanted, see T22365
$deleteAndMove = false;
$moveOverShared = false;
+ $user = $this->getUser();
+
$newTitle = $this->newTitle;
if ( !$newTitle ) {
# If a title was supplied, probably from the move log revert
# link, check for validity. We can then show some diagnostic
# information and save a click.
- $newerr = $this->oldTitle->isValidMoveOperation( $newTitle );
- if ( is_array( $newerr ) ) {
- $err = $newerr;
+ $mp = new MovePage( $this->oldTitle, $newTitle );
+ $status = $mp->isValidMove();
+ $status->merge( $mp->checkPermissions( $user, null ) );
+ if ( $status->getErrors() ) {
+ $err = $status->getErrorsArray();
}
}
- $user = $this->getUser();
-
if ( count( $err ) == 1 && isset( $err[0][0] ) && $err[0][0] == 'articleexists'
&& $newTitle->quickUserCan( 'delete', $user )
) {
$immovableNamespaces = [];
foreach ( array_keys( $this->getLanguage()->getNamespaces() ) as $nsId ) {
- if ( !MWNamespace::isMovable( $nsId ) ) {
+ if ( !MediaWikiServices::getInstance()->getNamespaceInfo()->isMovable( $nsId ) ) {
$immovableNamespaces[] = $nsId;
}
}
# Do the actual move.
$mp = new MovePage( $ot, $nt );
- $valid = $mp->isValidMove();
- if ( !$valid->isOK() ) {
- $this->showForm( $valid->getErrorsArray() );
- return;
- }
- $permStatus = $mp->checkPermissions( $user, $this->reason );
- if ( !$permStatus->isOK() ) {
- $this->showForm( $permStatus->getErrorsArray(), true );
- return;
- }
+ $userPermitted = $mp->checkPermissions( $user, $this->reason )->isOK();
- $status = $mp->move( $user, $this->reason, $createRedirect );
+ $status = $mp->moveIfAllowed( $user, $this->reason, $createRedirect );
if ( !$status->isOK() ) {
- $this->showForm( $status->getErrorsArray() );
+ $this->showForm( $status->getErrorsArray(), !$userPermitted );
return;
}
*/
// @todo FIXME: Use Title::moveSubpages() here
+ $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
$dbr = wfGetDB( DB_MASTER );
if ( $this->moveSubpages && (
- MWNamespace::hasSubpages( $nt->getNamespace() ) || (
+ $nsInfo->hasSubpages( $nt->getNamespace() ) || (
$this->moveTalk
- && MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
+ && $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
)
) ) {
$conds = [
. ' OR page_title = ' . $dbr->addQuotes( $ot->getDBkey() )
];
$conds['page_namespace'] = [];
- if ( MWNamespace::hasSubpages( $nt->getNamespace() ) ) {
+ if ( $nsInfo->hasSubpages( $nt->getNamespace() ) ) {
$conds['page_namespace'][] = $ot->getNamespace();
}
if ( $this->moveTalk &&
- MWNamespace::hasSubpages( $nt->getTalkPage()->getNamespace() )
+ $nsInfo->hasSubpages( $nt->getTalkPage()->getNamespace() )
) {
$conds['page_namespace'][] = $ot->getTalkPage()->getNamespace();
}
continue;
}
+ $mp = new MovePage( $oldSubpage, $newSubpage );
# This was copy-pasted from Renameuser, bleh.
- if ( $newSubpage->exists() && !$oldSubpage->isValidMoveTarget( $newSubpage ) ) {
+ if ( $newSubpage->exists() && !$mp->isValidMove()->isOk() ) {
$link = $linkRenderer->makeKnownLink( $newSubpage );
$extraOutput[] = $this->msg( 'movepage-page-exists' )->rawParams( $link )->escaped();
} else {
- $success = $oldSubpage->moveTo( $newSubpage, true, $this->reason, $createRedirect );
+ $status = $mp->moveIfAllowed( $user, $this->reason, $createRedirect );
- if ( $success === true ) {
+ if ( $status->isOK() ) {
if ( $this->fixRedirects ) {
DoubleRedirectJob::fixRedirects( 'move', $oldSubpage, $newSubpage );
}
* @param Title $title Page being moved.
*/
function showSubpages( $title ) {
- $nsHasSubpages = MWNamespace::hasSubpages( $title->getNamespace() );
+ $nsHasSubpages = MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $title->getNamespace() );
$subpages = $title->getSubpages();
$count = $subpages instanceof TitleArray ? $subpages->count() : 0;