* @param $request WebRequest
*/
function initialize( &$title, &$article, &$output, &$user, $request ) {
- wfProfileIn( __METHOD__ );
$this->preliminaryChecks( $title, $output, $request ) ;
- if ( !$this->initializeSpecialCases( $title, $output, $request ) ) {
+ if( !$this->initializeSpecialCases( $title, $output, $request ) ) {
$new_article = $this->initializeArticle( $title, $request );
if( is_object( $new_article ) ) {
$article = $new_article;
} elseif( is_string( $new_article ) ) {
$output->redirect( $new_article );
} else {
- wfProfileOut( __METHOD__ );
throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL" );
}
}
- wfProfileOut( __METHOD__ );
}
/**
*/
function checkMaxLag( $maxLag ) {
list( $host, $lag ) = wfGetLB()->getMaxLag();
- if ( $lag > $maxLag ) {
+ if( $lag > $maxLag ) {
wfMaxlagError( $host, $lag, $maxLag );
return false;
} else {
*/
function checkInitialQueries( $title, $action ) {
global $wgOut, $wgRequest, $wgContLang;
- if( $wgRequest->getVal( 'printable' ) == 'yes' ){
+ if( $wgRequest->getVal( 'printable' ) === 'yes' ) {
$wgOut->setPrintable();
}
-
$ret = NULL;
-
- if ( $curid = $wgRequest->getInt( 'curid' ) ) {
+ 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 && 'delete' != $action ) {
$ret = Title::newMainPage();
} else {
$ret = Title::newFromURL( $title );
$wgContLang->findVariantLink( $title, $ret );
}
- if ( ( $oldid = $wgRequest->getInt( 'oldid' ) )
+ if( ( $oldid = $wgRequest->getInt( 'oldid' ) )
&& ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) ) {
// Allow oldid to override a changed or missing title.
$rev = Revision::newFromId( $oldid );
* @param $request WebRequest
*/
function preliminaryChecks( &$title, &$output, $request ) {
-
if( $request->getCheck( 'search' ) ) {
// Compatibility with old search URLs which didn't use Special:Search
// Just check for presence here, so blank requests still
// Do this above the read whitelist check for security...
$title = SpecialPage::getTitleFor( 'Search' );
}
-
# If the user is not logged in, the Namespace:title of the article must be in
# the Read array in order for the user to see it. (We have to check here to
# catch special pages etc. We check again in Article::view())
- if ( !is_null( $title ) && !$title->userCanRead() ) {
+ if( !is_null( $title ) && !$title->userCanRead() ) {
$output->loginToUse();
$output->output();
exit;
}
-
}
/**
$title = SpecialPage::getTitleFor( 'Badtitle' );
# Die now before we mess up $wgArticle and the skin stops working
throw new ErrorPageError( 'badtitle', 'badtitletext' );
- } else if ( $title->getInterwiki() != '' ) {
+ } else if( $title->getInterwiki() != '' ) {
if( $rdfrom = $request->getVal( 'rdfrom' ) ) {
$url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
} else {
$url = $title->getFullURL();
}
/* Check for a redirect loop */
- if ( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) {
+ if( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) {
$output->redirect( $url );
} else {
$title = SpecialPage::getTitleFor( 'Badtitle' );
throw new ErrorPageError( 'badtitle', 'badtitletext' );
}
- } else if ( $action == 'view' && !$request->wasPosted() &&
+ } else if( $action == 'view' && !$request->wasPosted() &&
( !isset($this->GET['title']) || $title->getPrefixedDBKey() != $this->GET['title'] ) &&
!count( array_diff( array_keys( $this->GET ), array( 'action', 'title' ) ) ) )
{
$output->setSquidMaxage( 1200 );
$output->redirect( $targetUrl, '301' );
}
- } else if ( NS_SPECIAL == $title->getNamespace() ) {
+ } else if( NS_SPECIAL == $title->getNamespace() ) {
/* actions that need to be made when we have a special pages */
SpecialPage::executePath( $title );
} else {
// Rewrite environment to redirected article
$rarticle = self::articleFromTitle( $target );
$rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) );
- if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) {
+ if( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) {
$rarticle->setRedirectedFrom( $title );
$article = $rarticle;
$title = $target;
* @param $updates array of objects that hold an update to do
*/
function doUpdates( &$updates ) {
- wfProfileIn( __METHOD__ );
/* No need to get master connections in case of empty updates array */
- if (!$updates) {
- wfProfileOut( __METHOD__ );
+ if( !$updates ) {
return;
}
-
+ wfProfileIn( __METHOD__ );
$dbw = wfGetDB( DB_MASTER );
foreach( $updates as $up ) {
$up->doUpdate();
# Commit after every update to prevent lock contention
- if ( $dbw->trxLevel() ) {
+ if( $dbw->trxLevel() ) {
$dbw->commit();
}
}
function doJobs() {
$jobRunRate = $this->getVal( 'JobRunRate' );
- if ( $jobRunRate <= 0 || wfReadOnly() ) {
+ if( $jobRunRate <= 0 || wfReadOnly() ) {
return;
}
- if ( $jobRunRate < 1 ) {
+ if( $jobRunRate < 1 ) {
$max = mt_getrandmax();
- if ( mt_rand( 0, $max ) > $max * $jobRunRate ) {
+ if( mt_rand( 0, $max ) > $max * $jobRunRate ) {
return;
}
$n = 1;
$success = $job->run();
$t += wfTime();
$t = round( $t*1000 );
- if ( !$success ) {
+ if( !$success ) {
$output .= "Error: " . $job->getLastError() . ", Time: $t ms\n";
} else {
$output .= "Success, Time: $t ms\n";
* @param $request WebRequest
*/
function performAction( &$output, &$article, &$title, &$user, &$request ) {
- wfProfileIn( __METHOD__ );
-
- if ( !wfRunHooks( 'MediaWikiPerformAction', array( $output, $article, $title, $user, $request, $this ) ) ) {
- wfProfileOut( __METHOD__ );
+ if( !wfRunHooks( 'MediaWikiPerformAction', array( $output, $article, $title, $user, $request, $this ) ) ) {
return;
}
$output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) );
$article->view();
break;
+ case 'raw': // includes JS/CSS
+ $raw = new RawPage( $article );
+ $raw->view();
+ break;
case 'watch':
case 'unwatch':
case 'delete':
$history = new PageHistory( $article );
$history->history();
break;
- case 'raw':
- $raw = new RawPage( $article );
- $raw->view();
- break;
default:
if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) {
$output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
}
}
- wfProfileOut( __METHOD__ );
}