r44369 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44368‎ | r44369 | r44370 >
Date:23:00, 9 December 2008
Author:aaron
Status:ok
Tags:
Comment:
Whitespace/style consistency
Modified paths:
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Wiki.php
@@ -52,7 +52,7 @@
5353 function initialize( &$title, &$article, &$output, &$user, $request ) {
5454 wfProfileIn( __METHOD__ );
5555 $this->preliminaryChecks( $title, $output, $request ) ;
56 - if ( !$this->initializeSpecialCases( $title, $output, $request ) ) {
 56+ if( !$this->initializeSpecialCases( $title, $output, $request ) ) {
5757 $new_article = $this->initializeArticle( $title, $request );
5858 if( is_object( $new_article ) ) {
5959 $article = $new_article;
@@ -77,7 +77,7 @@
7878 */
7979 function checkMaxLag( $maxLag ) {
8080 list( $host, $lag ) = wfGetLB()->getMaxLag();
81 - if ( $lag > $maxLag ) {
 81+ if( $lag > $maxLag ) {
8282 wfMaxlagError( $host, $lag, $maxLag );
8383 return false;
8484 } else {
@@ -96,16 +96,14 @@
9797 */
9898 function checkInitialQueries( $title, $action ) {
9999 global $wgOut, $wgRequest, $wgContLang;
100 - if( $wgRequest->getVal( 'printable' ) == 'yes' ){
 100+ if( $wgRequest->getVal( 'printable' ) === 'yes' ) {
101101 $wgOut->setPrintable();
102102 }
103 -
104103 $ret = NULL;
105 -
106 - if ( $curid = $wgRequest->getInt( 'curid' ) ) {
 104+ if( $curid = $wgRequest->getInt( 'curid' ) ) {
107105 # URLs like this are generated by RC, because rc_title isn't always accurate
108106 $ret = Title::newFromID( $curid );
109 - } elseif ( '' == $title && 'delete' != $action ) {
 107+ } elseif( '' == $title && 'delete' != $action ) {
110108 $ret = Title::newMainPage();
111109 } else {
112110 $ret = Title::newFromURL( $title );
@@ -115,7 +113,7 @@
116114 $wgContLang->findVariantLink( $title, $ret );
117115
118116 }
119 - if ( ( $oldid = $wgRequest->getInt( 'oldid' ) )
 117+ if( ( $oldid = $wgRequest->getInt( 'oldid' ) )
120118 && ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) ) {
121119 // Allow oldid to override a changed or missing title.
122120 $rev = Revision::newFromId( $oldid );
@@ -147,7 +145,7 @@
148146 # If the user is not logged in, the Namespace:title of the article must be in
149147 # the Read array in order for the user to see it. (We have to check here to
150148 # catch special pages etc. We check again in Article::view())
151 - if ( !is_null( $title ) && !$title->userCanRead() ) {
 149+ if( !is_null( $title ) && !$title->userCanRead() ) {
152150 $output->loginToUse();
153151 $output->output();
154152 exit;
@@ -175,20 +173,20 @@
176174 $title = SpecialPage::getTitleFor( 'Badtitle' );
177175 # Die now before we mess up $wgArticle and the skin stops working
178176 throw new ErrorPageError( 'badtitle', 'badtitletext' );
179 - } else if ( $title->getInterwiki() != '' ) {
 177+ } else if( $title->getInterwiki() != '' ) {
180178 if( $rdfrom = $request->getVal( 'rdfrom' ) ) {
181179 $url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
182180 } else {
183181 $url = $title->getFullURL();
184182 }
185183 /* Check for a redirect loop */
186 - if ( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) {
 184+ if( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) {
187185 $output->redirect( $url );
188186 } else {
189187 $title = SpecialPage::getTitleFor( 'Badtitle' );
190188 throw new ErrorPageError( 'badtitle', 'badtitletext' );
191189 }
192 - } else if ( $action == 'view' && !$request->wasPosted() &&
 190+ } else if( $action == 'view' && !$request->wasPosted() &&
193191 ( !isset($this->GET['title']) || $title->getPrefixedDBKey() != $this->GET['title'] ) &&
194192 !count( array_diff( array_keys( $this->GET ), array( 'action', 'title' ) ) ) )
195193 {
@@ -220,7 +218,7 @@
221219 $output->setSquidMaxage( 1200 );
222220 $output->redirect( $targetUrl, '301' );
223221 }
224 - } else if ( NS_SPECIAL == $title->getNamespace() ) {
 222+ } else if( NS_SPECIAL == $title->getNamespace() ) {
225223 /* actions that need to be made when we have a special pages */
226224 SpecialPage::executePath( $title );
227225 } else {
@@ -307,7 +305,7 @@
308306 // Rewrite environment to redirected article
309307 $rarticle = self::articleFromTitle( $target );
310308 $rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) );
311 - if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) {
 309+ if( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) {
312310 $rarticle->setRedirectedFrom( $title );
313311 $article = $rarticle;
314312 $title = $target;
@@ -361,7 +359,7 @@
362360 $up->doUpdate();
363361
364362 # Commit after every update to prevent lock contention
365 - if ( $dbw->trxLevel() ) {
 363+ if( $dbw->trxLevel() ) {
366364 $dbw->commit();
367365 }
368366 }
@@ -374,12 +372,12 @@
375373 function doJobs() {
376374 $jobRunRate = $this->getVal( 'JobRunRate' );
377375
378 - if ( $jobRunRate <= 0 || wfReadOnly() ) {
 376+ if( $jobRunRate <= 0 || wfReadOnly() ) {
379377 return;
380378 }
381 - if ( $jobRunRate < 1 ) {
 379+ if( $jobRunRate < 1 ) {
382380 $max = mt_getrandmax();
383 - if ( mt_rand( 0, $max ) > $max * $jobRunRate ) {
 381+ if( mt_rand( 0, $max ) > $max * $jobRunRate ) {
384382 return;
385383 }
386384 $n = 1;
@@ -393,7 +391,7 @@
394392 $success = $job->run();
395393 $t += wfTime();
396394 $t = round( $t*1000 );
397 - if ( !$success ) {
 395+ if( !$success ) {
398396 $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n";
399397 } else {
400398 $output .= "Success, Time: $t ms\n";
@@ -422,7 +420,7 @@
423421 function performAction( &$output, &$article, &$title, &$user, &$request ) {
424422 wfProfileIn( __METHOD__ );
425423
426 - if ( !wfRunHooks( 'MediaWikiPerformAction', array( $output, $article, $title, $user, $request, $this ) ) ) {
 424+ if( !wfRunHooks( 'MediaWikiPerformAction', array( $output, $article, $title, $user, $request, $this ) ) ) {
427425 wfProfileOut( __METHOD__ );
428426 return;
429427 }
Index: trunk/phase3/index.php
@@ -47,10 +47,8 @@
4848 OutputPage::setEncodings(); # Not really used yet
4949
5050 $maxLag = $wgRequest->getVal( 'maxlag' );
51 -if ( !is_null( $maxLag ) ) {
52 - if ( !$mediaWiki->checkMaxLag( $maxLag ) ) {
53 - exit;
54 - }
 51+if( !is_null($maxLag) && !$mediaWiki->checkMaxLag( $maxLag ) ) {
 52+ exit;
5553 }
5654
5755 # Query string fields
@@ -58,7 +56,7 @@
5957 $title = $wgRequest->getVal( 'title' );
6058
6159 $wgTitle = $mediaWiki->checkInitialQueries( $title, $action );
62 -if ($wgTitle == NULL) {
 60+if( $wgTitle === NULL ) {
6361 unset( $wgTitle );
6462 }
6563
@@ -67,7 +65,7 @@
6866 #
6967 # Send Ajax requests to the Ajax dispatcher.
7068 #
71 -if ( $wgUseAjax && $action == 'ajax' ) {
 69+if( $wgUseAjax && $action == 'ajax' ) {
7270 require_once( $IP . '/includes/AjaxDispatcher.php' );
7371
7472 $dispatcher = new AjaxDispatcher();

Status & tagging log