/**
* Move this page's subpages to be subpages of $nt
*
+ * @deprecated since 1.34, use MovePage instead
* @param Title $nt Move target
* @param bool $auth Whether $wgUser's permissions should be checked
* @param string $reason The reason for the move
public function moveSubpages( $nt, $auth = true, $reason = '', $createRedirect = true,
array $changeTags = []
) {
- global $wgMaximumMovedPages;
// Check permissions
if ( !$this->userCan( 'move-subpages' ) ) {
return [
];
}
- $subpages = $this->getSubpages( $wgMaximumMovedPages + 1 );
- $retval = [];
- $count = 0;
- foreach ( $subpages as $oldSubpage ) {
- $count++;
- if ( $count > $wgMaximumMovedPages ) {
- $retval[$oldSubpage->getPrefixedText()] = [
- [ 'movepage-max-pages', $wgMaximumMovedPages ],
- ];
- break;
- }
+ global $wgUser;
+ $mp = new MovePage( $this, $nt );
+ $method = $auth ? 'moveSubpagesIfAllowed' : 'moveSubpages';
+ $result = $mp->$method( $wgUser, $reason, $createRedirect, $changeTags );
- // We don't know whether this function was called before
- // or after moving the root page, so check both
- // $this and $nt
- if ( $oldSubpage->getArticleID() == $this->getArticleID()
- || $oldSubpage->getArticleID() == $nt->getArticleID()
- ) {
- // When moving a page to a subpage of itself,
- // don't move it twice
- continue;
- }
- $newPageName = preg_replace(
- '#^' . preg_quote( $this->mDbkeyform, '#' ) . '#',
- StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # T23234
- $oldSubpage->getDBkey() );
- if ( $oldSubpage->isTalkPage() ) {
- $newNs = $nt->getTalkPage()->getNamespace();
- } else {
- $newNs = $nt->getSubjectPage()->getNamespace();
- }
- # T16385: we need makeTitleSafe because the new page names may
- # be longer than 255 characters.
- $newSubpage = self::makeTitleSafe( $newNs, $newPageName );
+ if ( !$result->isOk() ) {
+ return $result->getErrorsArray();
+ }
- $success = $oldSubpage->moveTo( $newSubpage, $auth, $reason, $createRedirect, $changeTags );
- if ( $success === true ) {
- $retval[$oldSubpage->getPrefixedText()] = $newSubpage->getPrefixedText();
+ $retval = [];
+ foreach ( $result->getValue() as $key => $status ) {
+ if ( $status->isOK() ) {
+ $retval[$key] = $status->getValue();
} else {
- $retval[$oldSubpage->getPrefixedText()] = $success;
+ $retval[$key] = $status->getErrorsArray();
}
}
return $retval;