}
$r = array( 'from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason'] );
- if ( !$params['noredirect'] || !$user->isAllowed( 'suppressredirect' ) ) {
+
+ if ( $fromTitle->exists() ) {
+ //NOTE: we assume that if the old title exists, it's because it was re-created as
+ // a redirect to the new title. This is not safe, but what we did before was
+ // even worse: we just determined whether a redirect should have been created,
+ // and reported that it was created if it should have, without any checks.
+ // Also note that isRedirect() is unreliable because of bug 37209.
$r['redirectcreated'] = '';
}
+
if( $toTitleExists ) {
$r['moveoverredirect'] = '';
}
* This default implementation always returns null. Subclasses supporting redirects
* must override this method.
*
+ * Note that subclasses that override this method to return a Content object
+ * should also override supportsRedirects() to return true.
+ *
* @since 1.21
*
* @param Title $destination the page to redirect to.
/**
* Returns true if this content model supports sections.
- *
* This default implementation returns false.
*
+ * Content models that return true here should also implement
+ * Content::getSection, Content::replaceSection, etc. to handle sections..
+ *
* @return boolean whether sections are supported.
*/
public function supportsSections() {
return false;
}
+ /**
+ * Returns true if this content model supports redirects.
+ * This default implementation returns false.
+ *
+ * Content models that return true here should also implement
+ * ContentHandler::makeRedirectContent to return a Content object.
+ *
+ * @return boolean whether redirects are supported.
+ */
+ public function supportsRedirects() {
+ return false;
+ }
+
/**
* Logs a deprecation warning, visible if $wgDevelopmentWarnings, but only if
* self::$enableDeprecationWarnings is set to true.
return new WikitextContent( $redirectText );
}
+ /**
+ * Returns true because wikitext supports redirects.
+ *
+ * @see ContentHandler::supportsRedirects
+ *
+ * @return boolean whether redirects are supported.
+ */
+ public function supportsRedirects() {
+ return true;
+ }
+
/**
* Returns true because wikitext supports sections.
*
}
}
+ $handler = ContentHandler::getForTitle( $this->oldTitle );
+
$out->addHTML(
Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL( 'action=submit' ), 'id' => 'movepage' ) ) .
Xml::openElement( 'fieldset' ) .
);
}
- if ( $user->isAllowed( 'suppressredirect' ) ) {
+ if ( $user->isAllowed( 'suppressredirect' ) && $handler->supportsRedirects() ) {
$out->addHTML( "
<tr>
<td></td>
}
}
- if ( $user->isAllowed( 'suppressredirect' ) ) {
+ $handler = ContentHandler::getForTitle( $ot );
+
+ if ( !$handler->supportsRedirects() ) {
+ $createRedirect = false;
+ } elseif ( $user->isAllowed( 'suppressredirect' ) ) {
$createRedirect = $this->leaveRedirect;
} else {
$createRedirect = true;
$oldText = $ot->getPrefixedText();
$newText = $nt->getPrefixedText();
- $msgName = $createRedirect ? 'movepage-moved-redirect' : 'movepage-moved-noredirect';
+ if ( $ot->exists() ) {
+ //NOTE: we assume that if the old title exists, it's because it was re-created as
+ // a redirect to the new title. This is not safe, but what we did before was
+ // even worse: we just determined whether a redirect should have been created,
+ // and reported that it was created if it should have, without any checks.
+ // Also note that isRedirect() is unreliable because of bug 37209.
+ $msgName = 'movepage-moved-redirect';
+ } else {
+ $msgName = 'movepage-moved-noredirect';
+ }
+
+
$out->addHTML( $this->msg( 'movepage-moved' )->rawParams( $oldLink,
$newLink )->params( $oldText, $newText )->parseAsBlock() );
$out->addWikiMsg( $msgName );