<?php
/**
* MediaWiki is the to-be base class for this whole project
+ *
+ * @internal documentation reviewed 15 Mar 2010
*/
class MediaWiki {
* Note that keys are case-insensitive!
*
* @param $key String: key to get
- * @param $default Mixed: default value if if the key doesn't exist
+ * @param $default string default value, defaults to empty string
+ * @return $default Mixed: default value if if the key doesn't exist
*/
function getVal( $key, $default = '' ) {
$key = strtolower( $key );
if( $wgRequest->getVal( 'printable' ) === 'yes' ) {
$wgOut->setPrintable();
}
- $ret = NULL;
+ $ret = null;
if( $curid = $wgRequest->getInt( 'curid' ) ) {
# URLs like this are generated by RC, because rc_title isn't always accurate
$ret = Title::newFromID( $curid );
- } elseif( '' == $title && 'delete' != $action ) {
+ } elseif( $title == '' && $action != 'delete' ) {
$ret = Title::newMainPage();
} else {
$ret = Title::newFromURL( $title );
* @param $title Title
* @param $output OutputPage
* @param $request WebRequest
+ * @return boolean true if successful
*/
function preliminaryChecks( &$title, &$output, $request ) {
if( $request->getCheck( 'search' ) ) {
global $wgContLang, $wgUser;
$action = $this->getVal( 'Action' );
$perferred = $wgContLang->getPreferredVariant( false );
- // Invalid titles
- if( is_null($title) || $title->getDBkey() == '' ) {
+
+ // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
+ if( is_null($title) || ( ($title->getDBkey() == '') && ($title->getInterwiki() == '') ) ) {
$title = SpecialPage::getTitleFor( 'Badtitle' );
# Die now before we mess up $wgArticle and the skin stops working
throw new ErrorPageError( 'badtitle', 'badtitletext' );
+
// Interwiki redirects
} else if( $title->getInterwiki() != '' ) {
if( $rdfrom = $request->getVal( 'rdfrom' ) ) {
$output->redirect( $url );
} else {
$title = SpecialPage::getTitleFor( 'Badtitle' );
+ $output->setTitle( $title ); // bug 21456
wfProfileOut( __METHOD__ );
throw new ErrorPageError( 'badtitle', 'badtitletext' );
}
- // Redirect loops, no title in URL, $wgUsePathInfo URLs
+ // Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
} else if( $action == 'view' && !$request->wasPosted() &&
( ( !isset($this->GET['title']) || $title->getPrefixedDBKey() != $this->GET['title'] ) ||
// No valid variant in URL (if the main-language has multi-variants), to ensure
- // the Accept-Language would only be added to XVO when a 301 redirection happened
- ( !isset($this->GET['variant']) && $perferred != $wgContLang->getCode() &&
- $wgContLang->hasVariants() && !$wgUser->isLoggedIn() ) ) &&
+ // anonymous access would always be redirect to a URL with 'variant' parameter
+ ( !isset($this->GET['variant']) && $wgContLang->hasVariants() && !$wgUser->isLoggedIn() ) ) &&
!count( array_diff( array_keys( $this->GET ), array( 'action', 'title' ) ) ) )
{
- $targetUrl = $title->getFullURL();
+ if( !$wgUser->isLoggedIn() ) {
+ $pref = $wgContLang->getPreferredVariant( false, $fromHeader = true );
+ $targetUrl = $title->getFullURL( '', $variant = $pref );
+ }
+ else
+ $targetUrl = $title->getFullURL();
// Redirect to canonical url, make it a 301 to allow caching
if( $targetUrl == $request->getFullRequestURL() ) {
$message = "Redirect loop detected!\n\n" .
$file = ($title->getNamespace() == NS_FILE) ? $article->getFile() : null;
if( ( $action == 'view' || $action == 'render' ) // ... for actions that show content
&& !$request->getVal( 'oldid' ) && // ... and are not old revisions
+ !$request->getVal( 'diff' ) && // ... and not when showing diff
$request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to
// ... and the article is not a non-redirect image page with associated file
!( is_object( $file ) && $file->exists() && !$file->getRedirected() ) )
if ( $action === 'historysubmit' ) {
if ( $request->getBool( 'revisiondelete' ) ) {
$action = 'revisiondelete';
+ } elseif ( $request->getBool( 'revisionmove' ) ) {
+ $action = 'revisionmove';
} else {
$action = 'view';
}
$special = SpecialPage::getPage( 'Revisiondelete' );
$special->execute( '' );
break;
+ case 'revisionmove':
+ # For revision move submission from history page
+ $special = SpecialPage::getPage( 'RevisionMove' );
+ $special->execute( '' );
+ break;
default:
if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) {
$output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );