From b3d0a9767ec056a959a7e7404cc83d551e75f185 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 9 Dec 2008 23:00:28 +0000 Subject: [PATCH] Whitespace/style consistency --- includes/Wiki.php | 38 ++++++++++++++++++-------------------- index.php | 10 ++++------ 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/includes/Wiki.php b/includes/Wiki.php index 96fca6683b..343e829301 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -52,7 +52,7 @@ class MediaWiki { 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; @@ -77,7 +77,7 @@ class MediaWiki { */ function checkMaxLag( $maxLag ) { list( $host, $lag ) = wfGetLB()->getMaxLag(); - if ( $lag > $maxLag ) { + if( $lag > $maxLag ) { wfMaxlagError( $host, $lag, $maxLag ); return false; } else { @@ -96,16 +96,14 @@ class MediaWiki { */ 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 ); @@ -115,7 +113,7 @@ class MediaWiki { $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 ); @@ -147,7 +145,7 @@ class MediaWiki { # 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; @@ -175,20 +173,20 @@ class MediaWiki { $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' ) ) ) ) { @@ -220,7 +218,7 @@ class MediaWiki { $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 { @@ -307,7 +305,7 @@ class MediaWiki { // 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; @@ -361,7 +359,7 @@ class MediaWiki { $up->doUpdate(); # Commit after every update to prevent lock contention - if ( $dbw->trxLevel() ) { + if( $dbw->trxLevel() ) { $dbw->commit(); } } @@ -374,12 +372,12 @@ class MediaWiki { 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; @@ -393,7 +391,7 @@ class MediaWiki { $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"; @@ -422,7 +420,7 @@ class MediaWiki { function performAction( &$output, &$article, &$title, &$user, &$request ) { wfProfileIn( __METHOD__ ); - if ( !wfRunHooks( 'MediaWikiPerformAction', array( $output, $article, $title, $user, $request, $this ) ) ) { + if( !wfRunHooks( 'MediaWikiPerformAction', array( $output, $article, $title, $user, $request, $this ) ) ) { wfProfileOut( __METHOD__ ); return; } diff --git a/index.php b/index.php index 4cadf7887f..88585792f8 100644 --- a/index.php +++ b/index.php @@ -47,10 +47,8 @@ wfProfileIn( 'main-misc-setup' ); OutputPage::setEncodings(); # Not really used yet $maxLag = $wgRequest->getVal( 'maxlag' ); -if ( !is_null( $maxLag ) ) { - if ( !$mediaWiki->checkMaxLag( $maxLag ) ) { - exit; - } +if( !is_null($maxLag) && !$mediaWiki->checkMaxLag( $maxLag ) ) { + exit; } # Query string fields @@ -58,7 +56,7 @@ $action = $wgRequest->getVal( 'action', 'view' ); $title = $wgRequest->getVal( 'title' ); $wgTitle = $mediaWiki->checkInitialQueries( $title, $action ); -if ($wgTitle == NULL) { +if( $wgTitle === NULL ) { unset( $wgTitle ); } @@ -67,7 +65,7 @@ wfProfileOut( 'main-misc-setup' ); # # Send Ajax requests to the Ajax dispatcher. # -if ( $wgUseAjax && $action == 'ajax' ) { +if( $wgUseAjax && $action == 'ajax' ) { require_once( $IP . '/includes/AjaxDispatcher.php' ); $dispatcher = new AjaxDispatcher(); -- 2.20.1