r62481 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62480‎ | r62481 | r62482 >
Date:22:07, 14 February 2010
Author:siebrand
Status:ok
Tags:
Comment:
Random indentation and code formatting updates. No functional changes.
Modified paths:
  • /trunk/phase3/includes/AjaxDispatcher.php (modified) (history)
  • /trunk/phase3/includes/AjaxFunctions.php (modified) (history)
  • /trunk/phase3/includes/AjaxResponse.php (modified) (history)
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/Autopromote.php (modified) (history)
  • /trunk/phase3/includes/BacklinkCache.php (modified) (history)
  • /trunk/phase3/includes/BagOStuff.php (modified) (history)
  • /trunk/phase3/includes/Block.php (modified) (history)
  • /trunk/phase3/includes/CacheDependency.php (modified) (history)
  • /trunk/phase3/includes/Category.php (modified) (history)
  • /trunk/phase3/includes/CategoryPage.php (modified) (history)
  • /trunk/phase3/includes/Categoryfinder.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Categoryfinder.php
@@ -22,7 +22,6 @@
2323 *
2424 */
2525 class Categoryfinder {
26 -
2726 var $articles = array(); # The original article IDs passed to the seed function
2827 var $deadend = array(); # Array of DBKEY category names for categories that don't have a page
2928 var $parents = array(); # Array of [ID => array()]
@@ -53,7 +52,7 @@
5453 $this->targets = array();
5554 foreach ( $categories as $c ) {
5655 $ct = Title::makeTitleSafe( NS_CATEGORY, $c );
57 - if( $ct ) {
 56+ if ( $ct ) {
5857 $c = $ct->getDBkey();
5958 $this->targets[$c] = $c;
6059 }
@@ -73,6 +72,7 @@
7473
7574 # Now check if this applies to the individual articles
7675 $ret = array();
 76+
7777 foreach ( $this->articles as $article ) {
7878 $conds = $this->targets;
7979 if ( $this->check( $article, $conds ) ) {
@@ -92,14 +92,20 @@
9393 */
9494 function check( $id , &$conds, $path = array() ) {
9595 // Check for loops and stop!
96 - if( in_array( $id, $path ) )
 96+ if ( in_array( $id, $path ) ) {
9797 return false;
 98+ }
 99+
98100 $path[] = $id;
99101
100102 # Shortcut (runtime paranoia): No contitions=all matched
101 - if ( count( $conds ) == 0 ) return true;
 103+ if ( count( $conds ) == 0 ) {
 104+ return true;
 105+ }
102106
103 - if ( !isset( $this->parents[$id] ) ) return false;
 107+ if ( !isset( $this->parents[$id] ) ) {
 108+ return false;
 109+ }
104110
105111 # iterate through the parents
106112 foreach ( $this->parents[$id] as $p ) {
@@ -127,7 +133,7 @@
128134 # No sub-parent
129135 continue ;
130136 }
131 - $done = $this->check( $this->name2id[$pname], $conds,$path );
 137+ $done = $this->check( $this->name2id[$pname], $conds, $path );
132138 if ( $done || count( $conds ) == 0 ) {
133139 # Subparents have done it!
134140 return true;
@@ -143,10 +149,10 @@
144150 # Find all parents of the article currently in $this->next
145151 $layer = array();
146152 $res = $this->dbr->select(
147 - /* FROM */ 'categorylinks',
148 - /* SELECT */ '*',
149 - /* WHERE */ array( 'cl_from' => $this->next ),
150 - __METHOD__ . "-1"
 153+ /* FROM */ 'categorylinks',
 154+ /* SELECT */ '*',
 155+ /* WHERE */ array( 'cl_from' => $this->next ),
 156+ __METHOD__ . "-1"
151157 );
152158 while ( $o = $this->dbr->fetchObject( $res ) ) {
153159 $k = $o->cl_to ;
@@ -159,6 +165,7 @@
160166
161167 # Ignore those we already have
162168 if ( in_array ( $k , $this->deadend ) ) continue;
 169+
163170 if ( isset ( $this->name2id[$k] ) ) continue;
164171
165172 # Hey, new category!
@@ -170,10 +177,10 @@
171178 # Find the IDs of all category pages in $layer, if they exist
172179 if ( count ( $layer ) > 0 ) {
173180 $res = $this->dbr->select(
174 - /* FROM */ 'page',
175 - /* SELECT */ array( 'page_id', 'page_title' ),
176 - /* WHERE */ array( 'page_namespace' => NS_CATEGORY , 'page_title' => $layer ),
177 - __METHOD__ . "-2"
 181+ /* FROM */ 'page',
 182+ /* SELECT */ array( 'page_id', 'page_title' ),
 183+ /* WHERE */ array( 'page_namespace' => NS_CATEGORY , 'page_title' => $layer ),
 184+ __METHOD__ . "-2"
178185 );
179186 while ( $o = $this->dbr->fetchObject( $res ) ) {
180187 $id = $o->page_id;
@@ -190,4 +197,4 @@
191198 }
192199 }
193200
194 -} # END OF CLASS "Categoryfinder"
 201+}
Index: trunk/phase3/includes/CategoryPage.php
@@ -5,7 +5,7 @@
66 *
77 */
88
9 -if( !defined( 'MEDIAWIKI' ) )
 9+if ( !defined( 'MEDIAWIKI' ) )
1010 die( 1 );
1111
1212 /**
@@ -20,7 +20,7 @@
2121 if ( isset( $diff ) && $diffOnly )
2222 return Article::view();
2323
24 - if( !wfRunHooks( 'CategoryPageView', array( &$this ) ) )
 24+ if ( !wfRunHooks( 'CategoryPageView', array( &$this ) ) )
2525 return;
2626
2727 if ( NS_CATEGORY == $this->mTitle->getNamespace() ) {
@@ -33,18 +33,17 @@
3434 $this->closeShowCategory();
3535 }
3636 }
37 -
 37+
3838 /**
3939 * Don't return a 404 for categories in use.
4040 */
4141 function hasViewableContent() {
42 - if( parent::hasViewableContent() ) {
 42+ if ( parent::hasViewableContent() ) {
4343 return true;
4444 } else {
4545 $cat = Category::newFromTitle( $this->mTitle );
4646 return $cat->getId() != 0;
4747 }
48 -
4948 }
5049
5150 function openShowCategory() {
@@ -99,7 +98,7 @@
10099 $this->getPagesSection() .
101100 $this->getImageSection();
102101
103 - if( $r == '' ) {
 102+ if ( $r == '' ) {
104103 // If there is no category content to display, only
105104 // show the top part of the navigation links.
106105 // FIXME: cannot be completely suppressed because it
@@ -118,7 +117,7 @@
119118 }
120119
121120 wfProfileOut( __METHOD__ );
122 - return $wgContLang->convert($r);
 121+ return $wgContLang->convert( $r );
123122 }
124123
125124 function clearCategoryState() {
@@ -126,7 +125,7 @@
127126 $this->articles_start_char = array();
128127 $this->children = array();
129128 $this->children_start_char = array();
130 - if( $this->showGallery ) {
 129+ if ( $this->showGallery ) {
131130 $this->gallery = new ImageGallery();
132131 $this->gallery->setHideBadImages();
133132 }
@@ -149,7 +148,7 @@
150149 }
151150
152151 /**
153 - * Add a subcategory to the internal lists, using a title object
 152+ * Add a subcategory to the internal lists, using a title object
154153 * @deprecated kept for compatibility, please use addSubcategoryObject instead
155154 */
156155 function addSubcategory( $title, $sortkey, $pageLength ) {
@@ -175,7 +174,7 @@
176175 function getSubcategorySortChar( $title, $sortkey ) {
177176 global $wgContLang;
178177
179 - if( $title->getPrefixedText() == $sortkey ) {
 178+ if ( $title->getPrefixedText() == $sortkey ) {
180179 $firstChar = $wgContLang->firstChar( $title->getDBkey() );
181180 } else {
182181 $firstChar = $wgContLang->firstChar( $sortkey );
@@ -189,7 +188,7 @@
190189 */
191190 function addImage( Title $title, $sortkey, $pageLength, $isRedirect = false ) {
192191 if ( $this->showGallery ) {
193 - if( $this->flip ) {
 192+ if ( $this->flip ) {
194193 $this->gallery->insert( $title );
195194 } else {
196195 $this->gallery->add( $title );
@@ -218,7 +217,7 @@
219218 }
220219
221220 function finaliseCategoryState() {
222 - if( $this->flip ) {
 221+ if ( $this->flip ) {
223222 $this->children = array_reverse( $this->children );
224223 $this->children_start_char = array_reverse( $this->children_start_char );
225224 $this->articles = array_reverse( $this->articles );
@@ -228,16 +227,17 @@
229228
230229 function doCategoryQuery() {
231230 $dbr = wfGetDB( DB_SLAVE, 'category' );
232 - if( $this->from != '' ) {
 231+ if ( $this->from != '' ) {
233232 $pageCondition = 'cl_sortkey >= ' . $dbr->addQuotes( $this->from );
234233 $this->flip = false;
235 - } elseif( $this->until != '' ) {
 234+ } elseif ( $this->until != '' ) {
236235 $pageCondition = 'cl_sortkey < ' . $dbr->addQuotes( $this->until );
237236 $this->flip = true;
238237 } else {
239238 $pageCondition = '1 = 1';
240239 $this->flip = false;
241240 }
 241+
242242 $res = $dbr->select(
243243 array( 'page', 'categorylinks', 'category' ),
244244 array( 'page_title', 'page_namespace', 'page_len', 'page_is_redirect', 'cl_sortkey',
@@ -253,8 +253,9 @@
254254
255255 $count = 0;
256256 $this->nextPage = null;
257 - while( $x = $dbr->fetchObject ( $res ) ) {
258 - if( ++$count > $this->limit ) {
 257+
 258+ while ( $x = $dbr->fetchObject ( $res ) ) {
 259+ if ( ++$count > $this->limit ) {
259260 // We've reached the one extra which shows that there are
260261 // additional pages to be had. Stop here...
261262 $this->nextPage = $x->cl_sortkey;
@@ -263,10 +264,10 @@
264265
265266 $title = Title::makeTitle( $x->page_namespace, $x->page_title );
266267
267 - if( $title->getNamespace() == NS_CATEGORY ) {
 268+ if ( $title->getNamespace() == NS_CATEGORY ) {
268269 $cat = Category::newFromRow( $x, $title );
269270 $this->addSubcategoryObject( $cat, $x->cl_sortkey, $x->page_len );
270 - } elseif( $this->showGallery && $title->getNamespace() == NS_FILE ) {
 271+ } elseif ( $this->showGallery && $title->getNamespace() == NS_FILE ) {
271272 $this->addImage( $title, $x->cl_sortkey, $x->page_len, $x->page_is_redirect );
272273 } else {
273274 $this->addPage( $title, $x->cl_sortkey, $x->page_len, $x->page_is_redirect );
@@ -287,7 +288,8 @@
288289 $rescnt = count( $this->children );
289290 $dbcnt = $this->cat->getSubcatCount();
290291 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' );
291 - if( $rescnt > 0 ) {
 292+
 293+ if ( $rescnt > 0 ) {
292294 # Showing subcategories
293295 $r .= "<div id=\"mw-subcategories\">\n";
294296 $r .= '<h2>' . wfMsg( 'subcategories' ) . "</h2>\n";
@@ -312,7 +314,7 @@
313315 $rescnt = count( $this->articles );
314316 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' );
315317
316 - if( $rescnt > 0 ) {
 318+ if ( $rescnt > 0 ) {
317319 $r = "<div id=\"mw-pages\">\n";
318320 $r .= '<h2>' . wfMsg( 'category_header', $ti ) . "</h2>\n";
319321 $r .= $countmsg;
@@ -323,7 +325,7 @@
324326 }
325327
326328 function getImageSection() {
327 - if( $this->showGallery && ! $this->gallery->isEmpty() ) {
 329+ if ( $this->showGallery && ! $this->gallery->isEmpty() ) {
328330 $dbcnt = $this->cat->getFileCount();
329331 $rescnt = $this->gallery->count();
330332 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
@@ -337,9 +339,9 @@
338340 }
339341
340342 function getCategoryBottom() {
341 - if( $this->until != '' ) {
 343+ if ( $this->until != '' ) {
342344 return $this->pagingLinks( $this->title, $this->nextPage, $this->until, $this->limit );
343 - } elseif( $this->nextPage != '' || $this->from != '' ) {
 345+ } elseif ( $this->nextPage != '' || $this->from != '' ) {
344346 return $this->pagingLinks( $this->title, $this->from, $this->nextPage, $this->limit );
345347 } else {
346348 return '';
@@ -359,7 +361,7 @@
360362 function formatList( $articles, $articles_start_char, $cutoff = 6 ) {
361363 if ( count ( $articles ) > $cutoff ) {
362364 return $this->columnList( $articles, $articles_start_char );
363 - } elseif ( count($articles) > 0) {
 365+ } elseif ( count( $articles ) > 0 ) {
364366 // for short lists of articles in categories.
365367 return $this->shortList( $articles, $articles_start_char );
366368 }
@@ -384,7 +386,7 @@
385387 function columnList( $articles, $articles_start_char ) {
386388 $columns = array_combine( $articles, $articles_start_char );
387389 # Split into three columns
388 - $columns = array_chunk( $columns, ceil( count( $columns )/3 ), true /* preserve keys */ );
 390+ $columns = array_chunk( $columns, ceil( count( $columns ) / 3 ), true /* preserve keys */ );
389391
390392 $ret = '<table width="100%"><tr valign="top"><td>';
391393 $prevchar = null;
@@ -435,10 +437,10 @@
436438 */
437439 function shortList( $articles, $articles_start_char ) {
438440 $r = '<h3>' . htmlspecialchars( $articles_start_char[0] ) . "</h3>\n";
439 - $r .= '<ul><li>'.$articles[0].'</li>';
440 - for ($index = 1; $index < count($articles); $index++ )
 441+ $r .= '<ul><li>' . $articles[0] . '</li>';
 442+ for ( $index = 1; $index < count( $articles ); $index++ )
441443 {
442 - if ($articles_start_char[$index] != $articles_start_char[$index - 1])
 444+ if ( $articles_start_char[$index] != $articles_start_char[$index - 1] )
443445 {
444446 $r .= "</ul><h3>" . htmlspecialchars( $articles_start_char[$index] ) . "</h3>\n<ul>";
445447 }
@@ -464,7 +466,8 @@
465467 $limitText = $wgLang->formatNum( $limit );
466468
467469 $prevLink = wfMsgExt( 'prevn', array( 'escape', 'parsemag' ), $limitText );
468 - if( $first != '' ) {
 470+
 471+ if ( $first != '' ) {
469472 $prevQuery = $query;
470473 $prevQuery['until'] = $first;
471474 $prevLink = $sk->linkKnown(
@@ -474,8 +477,10 @@
475478 $prevQuery
476479 );
477480 }
 481+
478482 $nextLink = wfMsgExt( 'nextn', array( 'escape', 'parsemag' ), $limitText );
479 - if( $last != '' ) {
 483+
 484+ if ( $last != '' ) {
480485 $lastQuery = $query;
481486 $lastQuery['from'] = $last;
482487 $nextLink = $sk->linkKnown(
@@ -516,12 +521,14 @@
517522 # know the right figure.
518523 # 3) We have no idea.
519524 $totalrescnt = count( $this->articles ) + count( $this->children ) +
520 - ($this->showGallery ? $this->gallery->count() : 0);
521 - if($dbcnt == $rescnt || (($totalrescnt == $this->limit || $this->from
522 - || $this->until) && $dbcnt > $rescnt)){
 525+ ( $this->showGallery ? $this->gallery->count() : 0 );
 526+
 527+ if ( $dbcnt == $rescnt || ( ( $totalrescnt == $this->limit || $this->from
 528+ || $this->until ) && $dbcnt > $rescnt ) )
 529+ {
523530 # Case 1: seems sane.
524531 $totalcnt = $dbcnt;
525 - } elseif($totalrescnt < $this->limit && !$this->from && !$this->until){
 532+ } elseif ( $totalrescnt < $this->limit && !$this->from && !$this->until ) {
526533 # Case 2: not sane, but salvageable. Use the number of results.
527534 # Since there are fewer than 200, we can also take this opportunity
528535 # to refresh the incorrect category table entry -- which should be
@@ -530,10 +537,14 @@
531538 $this->cat->refreshCounts();
532539 } else {
533540 # Case 3: hopeless. Don't give a total count at all.
534 - return wfMsgExt("category-$type-count-limited", 'parse',
 541+ return wfMsgExt( "category-$type-count-limited", 'parse',
535542 $wgLang->formatNum( $rescnt ) );
536543 }
537 - return wfMsgExt( "category-$type-count", 'parse', $wgLang->formatNum( $rescnt ),
538 - $wgLang->formatNum( $totalcnt ) );
 544+ return wfMsgExt(
 545+ "category-$type-count",
 546+ 'parse',
 547+ $wgLang->formatNum( $rescnt ),
 548+ $wgLang->formatNum( $totalcnt )
 549+ );
539550 }
540551 }
Index: trunk/phase3/includes/BagOStuff.php
@@ -54,7 +54,7 @@
5555 abstract public function get( $key );
5656
5757 /**
58 - * Set an item.
 58+ * Set an item.
5959 * @param $key string
6060 * @param $value mixed
6161 * @param $exptime int Either an interval in seconds or a unix timestamp for expiry
@@ -87,9 +87,11 @@
8888 /* Better performance can likely be got with custom written versions */
8989 public function get_multi( $keys ) {
9090 $out = array();
 91+
9192 foreach ( $keys as $key ) {
9293 $out[$key] = $this->get( $key );
9394 }
 95+
9496 return $out;
9597 }
9698
@@ -140,7 +142,7 @@
141143 }
142144
143145 public function decr( $key, $value = 1 ) {
144 - return $this->incr( $key, -$value );
 146+ return $this->incr( $key, - $value );
145147 }
146148
147149 public function debug( $text ) {
@@ -160,7 +162,6 @@
161163 }
162164 }
163165
164 -
165166 /**
166167 * Functional versions!
167168 * This is a test of the interface, mainly. It stores things in an associative
@@ -254,10 +255,10 @@
255256 $this->debug( "get: key has expired, deleting" );
256257 try {
257258 $db->begin();
258 - # Put the expiry time in the WHERE condition to avoid deleting a
 259+ # Put the expiry time in the WHERE condition to avoid deleting a
259260 # newly-inserted value
260 - $db->delete( 'objectcache',
261 - array(
 261+ $db->delete( 'objectcache',
 262+ array(
262263 'keyname' => $key,
263264 'exptime' => $row->exptime
264265 ), __METHOD__ );
@@ -284,8 +285,8 @@
285286 try {
286287 $db->begin();
287288 $db->delete( 'objectcache', array( 'keyname' => $key ), __METHOD__ );
288 - $db->insert( 'objectcache',
289 - array(
 289+ $db->insert( 'objectcache',
 290+ array(
290291 'keyname' => $key,
291292 'value' => $db->encodeBlob( $this->serialize( $value ) ),
292293 'exptime' => $encExpiry
@@ -458,7 +459,7 @@
459460 /**
460461 * Backwards compatibility alias
461462 */
462 -class MediaWikiBagOStuff extends SqlBagOStuff {}
 463+class MediaWikiBagOStuff extends SqlBagOStuff { }
463464
464465 /**
465466 * This is a wrapper for Turck MMCache's shared memory functions.
@@ -533,14 +534,13 @@
534535 $info = apc_cache_info( 'user' );
535536 $list = $info['cache_list'];
536537 $keys = array();
537 - foreach( $list as $entry ) {
 538+ foreach ( $list as $entry ) {
538539 $keys[] = $entry['info'];
539540 }
540541 return $keys;
541542 }
542543 }
543544
544 -
545545 /**
546546 * This is a wrapper for eAccelerator's shared memory functions.
547547 *
@@ -624,13 +624,12 @@
625625 xcache_unset( $key );
626626 return true;
627627 }
628 -
629628 }
630629
631630 /**
632 - * Cache that uses DBA as a backend.
633 - * Slow due to the need to constantly open and close the file to avoid holding
634 - * writer locks. Intended for development use only, as a memcached workalike
 631+ * Cache that uses DBA as a backend.
 632+ * Slow due to the need to constantly open and close the file to avoid holding
 633+ * writer locks. Intended for development use only, as a memcached workalike
635634 * for systems that don't have it.
636635 *
637636 * @ingroup Cache
@@ -669,7 +668,7 @@
670669 return array(
671670 unserialize( substr( $blob, 11 ) ),
672671 intval( substr( $blob, 0, 10 ) )
673 - );
 672+ );
674673 }
675674 }
676675
Index: trunk/phase3/includes/Article.php
@@ -16,32 +16,32 @@
1717 /**@{{
1818 * @private
1919 */
20 - var $mComment = ''; //!<
21 - var $mContent; //!<
22 - var $mContentLoaded = false; //!<
23 - var $mCounter = -1; //!< Not loaded
24 - var $mCurID = -1; //!< Not loaded
25 - var $mDataLoaded = false; //!<
26 - var $mForUpdate = false; //!<
27 - var $mGoodAdjustment = 0; //!<
28 - var $mIsRedirect = false; //!<
29 - var $mLatest = false; //!<
30 - var $mMinorEdit; //!<
31 - var $mOldId; //!<
32 - var $mPreparedEdit = false; //!< Title object if set
33 - var $mRedirectedFrom = null; //!< Title object if set
34 - var $mRedirectTarget = null; //!< Title object if set
35 - var $mRedirectUrl = false; //!<
36 - var $mRevIdFetched = 0; //!<
37 - var $mRevision; //!<
38 - var $mTimestamp = ''; //!<
39 - var $mTitle; //!<
40 - var $mTotalAdjustment = 0; //!<
41 - var $mTouched = '19700101000000'; //!<
42 - var $mUser = -1; //!< Not loaded
43 - var $mUserText = ''; //!<
44 - var $mParserOptions; //!<
45 - var $mParserOutput; //!<
 20+ var $mComment = ''; // !<
 21+ var $mContent; // !<
 22+ var $mContentLoaded = false; // !<
 23+ var $mCounter = -1; // !< Not loaded
 24+ var $mCurID = -1; // !< Not loaded
 25+ var $mDataLoaded = false; // !<
 26+ var $mForUpdate = false; // !<
 27+ var $mGoodAdjustment = 0; // !<
 28+ var $mIsRedirect = false; // !<
 29+ var $mLatest = false; // !<
 30+ var $mMinorEdit; // !<
 31+ var $mOldId; // !<
 32+ var $mPreparedEdit = false; // !< Title object if set
 33+ var $mRedirectedFrom = null; // !< Title object if set
 34+ var $mRedirectTarget = null; // !< Title object if set
 35+ var $mRedirectUrl = false; // !<
 36+ var $mRevIdFetched = 0; // !<
 37+ var $mRevision; // !<
 38+ var $mTimestamp = ''; // !<
 39+ var $mTitle; // !<
 40+ var $mTotalAdjustment = 0; // !<
 41+ var $mTouched = '19700101000000'; // !<
 42+ var $mUser = -1; // !< Not loaded
 43+ var $mUserText = ''; // !<
 44+ var $mParserOptions; // !<
 45+ var $mParserOutput; // !<
4646 /**@}}*/
4747
4848 /**
@@ -62,7 +62,7 @@
6363 $t = Title::newFromID( $id );
6464 # FIXME: doesn't inherit right
6565 return $t == null ? null : new self( $t );
66 - #return $t == null ? null : new static( $t ); // PHP 5.3
 66+ # return $t == null ? null : new static( $t ); // PHP 5.3
6767 }
6868
6969 /**
@@ -82,19 +82,19 @@
8383 * @return mixed Title object, or null if this page is not a redirect
8484 */
8585 public function getRedirectTarget() {
86 - if( !$this->mTitle || !$this->mTitle->isRedirect() )
 86+ if ( !$this->mTitle || !$this->mTitle->isRedirect() )
8787 return null;
88 - if( !is_null($this->mRedirectTarget) )
 88+ if ( !is_null( $this->mRedirectTarget ) )
8989 return $this->mRedirectTarget;
9090 # Query the redirect table
9191 $dbr = wfGetDB( DB_SLAVE );
9292 $row = $dbr->selectRow( 'redirect',
93 - array('rd_namespace', 'rd_title'),
94 - array('rd_from' => $this->getID() ),
 93+ array( 'rd_namespace', 'rd_title' ),
 94+ array( 'rd_from' => $this->getID() ),
9595 __METHOD__
9696 );
97 - if( $row ) {
98 - return $this->mRedirectTarget = Title::makeTitle($row->rd_namespace, $row->rd_title);
 97+ if ( $row ) {
 98+ return $this->mRedirectTarget = Title::makeTitle( $row->rd_namespace, $row->rd_title );
9999 }
100100 # This page doesn't have an entry in the redirect table
101101 return $this->mRedirectTarget = $this->insertRedirect();
@@ -108,11 +108,11 @@
109109 */
110110 public function insertRedirect() {
111111 $retval = Title::newFromRedirect( $this->getContent() );
112 - if( !$retval ) {
 112+ if ( !$retval ) {
113113 return null;
114114 }
115115 $dbw = wfGetDB( DB_MASTER );
116 - $dbw->replace( 'redirect', array('rd_from'),
 116+ $dbw->replace( 'redirect', array( 'rd_from' ),
117117 array(
118118 'rd_from' => $this->getID(),
119119 'rd_namespace' => $retval->getNamespace(),
@@ -141,9 +141,9 @@
142142 public function followRedirectText( $text ) {
143143 $rt = Title::newFromRedirectRecurse( $text ); // recurse through to only get the final target
144144 # process if title object is valid and not special:userlogout
145 - if( $rt ) {
146 - if( $rt->getInterwiki() != '' ) {
147 - if( $rt->isLocal() ) {
 145+ if ( $rt ) {
 146+ if ( $rt->getInterwiki() != '' ) {
 147+ if ( $rt->isLocal() ) {
148148 // Offsite wikis need an HTTP redirect.
149149 //
150150 // This can be hard to reverse and may produce loops,
@@ -152,13 +152,13 @@
153153 return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) );
154154 }
155155 } else {
156 - if( $rt->getNamespace() == NS_SPECIAL ) {
 156+ if ( $rt->getNamespace() == NS_SPECIAL ) {
157157 // Gotta handle redirects to special pages differently:
158158 // Fill the HTTP response "Location" header and ignore
159159 // the rest of the page we're on.
160160 //
161161 // This can be hard to reverse, so they may be disabled.
162 - if( $rt->isSpecial( 'Userlogout' ) ) {
 162+ if ( $rt->isSpecial( 'Userlogout' ) ) {
163163 // rolleyes
164164 } else {
165165 return $rt->getFullURL();
@@ -211,15 +211,15 @@
212212 public function getContent() {
213213 global $wgUser, $wgContLang, $wgOut, $wgMessageCache;
214214 wfProfileIn( __METHOD__ );
215 - if( $this->getID() === 0 ) {
 215+ if ( $this->getID() === 0 ) {
216216 # If this is a MediaWiki:x message, then load the messages
217217 # and return the message value for x.
218 - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 218+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
219219 # If this is a system message, get the default text.
220220 list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) );
221221 $wgMessageCache->loadAllMessages( $lang );
222222 $text = wfMsgGetKey( $message, false, $lang, false );
223 - if( wfEmptyMsg( $message, $text ) )
 223+ if ( wfEmptyMsg( $message, $text ) )
224224 $text = '';
225225 } else {
226226 $text = wfMsgExt( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag' );
@@ -240,7 +240,7 @@
241241 */
242242 public function getRawText() {
243243 // Check process cache for current revision
244 - if( $this->mContentLoaded && $this->mOldId == 0 ) {
 244+ if ( $this->mContentLoaded && $this->mOldId == 0 ) {
245245 return $this->mContent;
246246 }
247247 $rev = Revision::newFromTitle( $this->mTitle );
@@ -292,7 +292,7 @@
293293 * current revision
294294 */
295295 public function getOldID() {
296 - if( is_null( $this->mOldId ) ) {
 296+ if ( is_null( $this->mOldId ) ) {
297297 $this->mOldId = $this->getOldIDFromRequest();
298298 }
299299 return $this->mOldId;
@@ -307,23 +307,23 @@
308308 global $wgRequest;
309309 $this->mRedirectUrl = false;
310310 $oldid = $wgRequest->getVal( 'oldid' );
311 - if( isset( $oldid ) ) {
 311+ if ( isset( $oldid ) ) {
312312 $oldid = intval( $oldid );
313 - if( $wgRequest->getVal( 'direction' ) == 'next' ) {
 313+ if ( $wgRequest->getVal( 'direction' ) == 'next' ) {
314314 $nextid = $this->mTitle->getNextRevisionID( $oldid );
315 - if( $nextid ) {
 315+ if ( $nextid ) {
316316 $oldid = $nextid;
317317 } else {
318318 $this->mRedirectUrl = $this->mTitle->getFullURL( 'redirect=no' );
319319 }
320 - } elseif( $wgRequest->getVal( 'direction' ) == 'prev' ) {
 320+ } elseif ( $wgRequest->getVal( 'direction' ) == 'prev' ) {
321321 $previd = $this->mTitle->getPreviousRevisionID( $oldid );
322 - if( $previd ) {
 322+ if ( $previd ) {
323323 $oldid = $previd;
324324 }
325325 }
326326 }
327 - if( !$oldid ) {
 327+ if ( !$oldid ) {
328328 $oldid = 0;
329329 }
330330 return $oldid;
@@ -333,7 +333,7 @@
334334 * Load the revision (including text) into this object
335335 */
336336 function loadContent() {
337 - if( $this->mContentLoaded ) return;
 337+ if ( $this->mContentLoaded ) return;
338338 wfProfileIn( __METHOD__ );
339339 # Query variables :P
340340 $oldid = $this->getOldID();
@@ -400,13 +400,13 @@
401401 * @param $data Database row object or "fromdb"
402402 */
403403 public function loadPageData( $data = 'fromdb' ) {
404 - if( $data === 'fromdb' ) {
 404+ if ( $data === 'fromdb' ) {
405405 $dbr = wfGetDB( DB_MASTER );
406406 $data = $this->pageDataFromId( $dbr, $this->getId() );
407407 }
408408
409409 $lc = LinkCache::singleton();
410 - if( $data ) {
 410+ if ( $data ) {
411411 $lc->addGoodLinkObj( $data->page_id, $this->mTitle, $data->page_len, $data->page_is_redirect );
412412
413413 $this->mTitle->mArticleID = intval( $data->page_id );
@@ -419,7 +419,7 @@
420420 $this->mIsRedirect = intval( $data->page_is_redirect );
421421 $this->mLatest = intval( $data->page_latest );
422422 } else {
423 - if( is_object( $this->mTitle ) ) {
 423+ if ( is_object( $this->mTitle ) ) {
424424 $lc->addBadLinkObj( $this->mTitle );
425425 }
426426 $this->mTitle->mArticleID = 0;
@@ -435,7 +435,7 @@
436436 * @return string
437437 */
438438 function fetchContent( $oldid = 0 ) {
439 - if( $this->mContentLoaded ) {
 439+ if ( $this->mContentLoaded ) {
440440 return $this->mContent;
441441 }
442442
@@ -447,31 +447,31 @@
448448 $d = $oldid ? wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid ) : '';
449449 $this->mContent = wfMsgNoTrans( 'missing-article', $t, $d ) ;
450450
451 - if( $oldid ) {
 451+ if ( $oldid ) {
452452 $revision = Revision::newFromId( $oldid );
453 - if( is_null( $revision ) ) {
454 - wfDebug( __METHOD__." failed to retrieve specified revision, id $oldid\n" );
 453+ if ( is_null( $revision ) ) {
 454+ wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" );
455455 return false;
456456 }
457457 $data = $this->pageDataFromId( $dbr, $revision->getPage() );
458 - if( !$data ) {
459 - wfDebug( __METHOD__." failed to get page data linked to revision id $oldid\n" );
 458+ if ( !$data ) {
 459+ wfDebug( __METHOD__ . " failed to get page data linked to revision id $oldid\n" );
460460 return false;
461461 }
462462 $this->mTitle = Title::makeTitle( $data->page_namespace, $data->page_title );
463463 $this->loadPageData( $data );
464464 } else {
465 - if( !$this->mDataLoaded ) {
 465+ if ( !$this->mDataLoaded ) {
466466 $data = $this->pageDataFromTitle( $dbr, $this->mTitle );
467 - if( !$data ) {
468 - wfDebug( __METHOD__." failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" );
 467+ if ( !$data ) {
 468+ wfDebug( __METHOD__ . " failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" );
469469 return false;
470470 }
471471 $this->loadPageData( $data );
472472 }
473473 $revision = Revision::newFromId( $this->mLatest );
474 - if( is_null( $revision ) ) {
475 - wfDebug( __METHOD__." failed to retrieve current page, rev_id {$this->mLatest}\n" );
 474+ if ( is_null( $revision ) ) {
 475+ wfDebug( __METHOD__ . " failed to retrieve current page, rev_id {$this->mLatest}\n" );
476476 return false;
477477 }
478478 }
@@ -522,8 +522,8 @@
523523 * @return Array: options
524524 */
525525 protected function getSelectOptions( $options = '' ) {
526 - if( $this->mForUpdate ) {
527 - if( is_array( $options ) ) {
 526+ if ( $this->mForUpdate ) {
 527+ if ( is_array( $options ) ) {
528528 $options[] = 'FOR UPDATE';
529529 } else {
530530 $options = 'FOR UPDATE';
@@ -536,7 +536,7 @@
537537 * @return int Page ID
538538 */
539539 public function getID() {
540 - if( $this->mTitle ) {
 540+ if ( $this->mTitle ) {
541541 return $this->mTitle->getArticleID();
542542 } else {
543543 return 0;
@@ -566,9 +566,9 @@
567567 * @return int The view count for the page
568568 */
569569 public function getCount() {
570 - if( -1 == $this->mCounter ) {
 570+ if ( -1 == $this->mCounter ) {
571571 $id = $this->getID();
572 - if( $id == 0 ) {
 572+ if ( $id == 0 ) {
573573 $this->mCounter = 0;
574574 } else {
575575 $dbr = wfGetDB( DB_SLAVE );
@@ -594,7 +594,7 @@
595595 global $wgUseCommaCount;
596596
597597 $token = $wgUseCommaCount ? ',' : '[[';
598 - return $this->mTitle->isContentPage() && !$this->isRedirect($text) && in_string($token,$text);
 598+ return $this->mTitle->isContentPage() && !$this->isRedirect( $text ) && in_string( $token, $text );
599599 }
600600
601601 /**
@@ -604,8 +604,8 @@
605605 * @return bool
606606 */
607607 public function isRedirect( $text = false ) {
608 - if( $text === false ) {
609 - if( $this->mDataLoaded ) {
 608+ if ( $text === false ) {
 609+ if ( $this->mDataLoaded ) {
610610 return $this->mIsRedirect;
611611 }
612612 // Apparently loadPageData was never called
@@ -624,10 +624,10 @@
625625 */
626626 public function isCurrent() {
627627 # If no oldid, this is the current version.
628 - if( $this->getOldID() == 0 ) {
 628+ if ( $this->getOldID() == 0 ) {
629629 return true;
630630 }
631 - return $this->exists() && isset($this->mRevision) && $this->mRevision->isCurrent();
 631+ return $this->exists() && isset( $this->mRevision ) && $this->mRevision->isCurrent();
632632 }
633633
634634 /**
@@ -635,15 +635,15 @@
636636 * This isn't necessary for all uses, so it's only done if needed.
637637 */
638638 protected function loadLastEdit() {
639 - if( -1 != $this->mUser )
 639+ if ( -1 != $this->mUser )
640640 return;
641641
642642 # New or non-existent articles have no user information
643643 $id = $this->getID();
644 - if( 0 == $id ) return;
 644+ if ( 0 == $id ) return;
645645
646646 $this->mLastRevision = Revision::loadFromPageId( wfGetDB( DB_MASTER ), $id );
647 - if( !is_null( $this->mLastRevision ) ) {
 647+ if ( !is_null( $this->mLastRevision ) ) {
648648 $this->mUser = $this->mLastRevision->getUser();
649649 $this->mUserText = $this->mLastRevision->getUserText();
650650 $this->mTimestamp = $this->mLastRevision->getTimestamp();
@@ -655,10 +655,10 @@
656656
657657 public function getTimestamp() {
658658 // Check if the field has been filled by ParserCache::get()
659 - if( !$this->mTimestamp ) {
 659+ if ( !$this->mTimestamp ) {
660660 $this->loadLastEdit();
661661 }
662 - return wfTimestamp(TS_MW, $this->mTimestamp);
 662+ return wfTimestamp( TS_MW, $this->mTimestamp );
663663 }
664664
665665 public function getUser() {
@@ -691,7 +691,7 @@
692692 * @param $limit Integer: default 0.
693693 * @param $offset Integer: default 0.
694694 */
695 - public function getContributors($limit = 0, $offset = 0) {
 695+ public function getContributors( $limit = 0, $offset = 0 ) {
696696 # XXX: this is expensive; cache this info somewhere.
697697
698698 $dbr = wfGetDB( DB_SLAVE );
@@ -749,19 +749,19 @@
750750 }
751751
752752 # Try client and file cache
753 - if( $oldid === 0 && $this->checkTouched() ) {
 753+ if ( $oldid === 0 && $this->checkTouched() ) {
754754 global $wgUseETag;
755 - if( $wgUseETag ) {
 755+ if ( $wgUseETag ) {
756756 $wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) );
757757 }
758758 # Is is client cached?
759 - if( $wgOut->checkLastModified( $this->getTouched() ) ) {
760 - wfDebug( __METHOD__.": done 304\n" );
 759+ if ( $wgOut->checkLastModified( $this->getTouched() ) ) {
 760+ wfDebug( __METHOD__ . ": done 304\n" );
761761 wfProfileOut( __METHOD__ );
762762 return;
763763 # Try file cache
764 - } else if( $wgUseFileCache && $this->tryFileCache() ) {
765 - wfDebug( __METHOD__.": done file cache\n" );
 764+ } else if ( $wgUseFileCache && $this->tryFileCache() ) {
 765+ wfDebug( __METHOD__ . ": done file cache\n" );
766766 # tell wgOut that output is taken care of
767767 $wgOut->disable();
768768 $this->viewUpdates();
@@ -773,9 +773,9 @@
774774 $sk = $wgUser->getSkin();
775775
776776 # getOldID may want us to redirect somewhere else
777 - if( $this->mRedirectUrl ) {
 777+ if ( $this->mRedirectUrl ) {
778778 $wgOut->redirect( $this->mRedirectUrl );
779 - wfDebug( __METHOD__.": redirecting due to oldid\n" );
 779+ wfDebug( __METHOD__ . ": redirecting due to oldid\n" );
780780 wfProfileOut( __METHOD__ );
781781 return;
782782 }
@@ -785,8 +785,8 @@
786786 $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
787787
788788 # If we got diff in the query, we want to see a diff page instead of the article.
789 - if( !is_null( $wgRequest->getVal( 'diff' ) ) ) {
790 - wfDebug( __METHOD__.": showing diff page\n" );
 789+ if ( !is_null( $wgRequest->getVal( 'diff' ) ) ) {
 790+ wfDebug( __METHOD__ . ": showing diff page\n" );
791791 $this->showDiffPage();
792792 wfProfileOut( __METHOD__ );
793793 return;
@@ -794,16 +794,16 @@
795795
796796 # Should the parser cache be used?
797797 $useParserCache = $this->useParserCache( $oldid );
798 - wfDebug( 'Article::view using parser cache: ' . ($useParserCache ? 'yes' : 'no' ) . "\n" );
799 - if( $wgUser->getOption( 'stubthreshold' ) ) {
 798+ wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
 799+ if ( $wgUser->getOption( 'stubthreshold' ) ) {
800800 wfIncrStats( 'pcache_miss_stub' );
801801 }
802802
803803 # For the main page, overwrite the <title> element with the con-
804804 # tents of 'pagetitle-view-mainpage' instead of the default (if
805805 # that's not empty).
806 - if( $this->mTitle->equals( Title::newMainPage() )
807 - && ($m=wfMsgForContent( 'pagetitle-view-mainpage' )) !== '' )
 806+ if ( $this->mTitle->equals( Title::newMainPage() )
 807+ && ( $m = wfMsgForContent( 'pagetitle-view-mainpage' ) ) !== '' )
808808 {
809809 $wgOut->setHTMLTitle( $m );
810810 }
@@ -815,18 +815,18 @@
816816 # Keep going until $outputDone is set, or we run out of things to do.
817817 $pass = 0;
818818 $outputDone = false;
819 - while( !$outputDone && ++$pass ){
820 - switch( $pass ){
 819+ while ( !$outputDone && ++$pass ) {
 820+ switch( $pass ) {
821821 case 1:
822822 wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) );
823823 break;
824824
825825 case 2:
826826 # Try the parser cache
827 - if( $useParserCache ) {
 827+ if ( $useParserCache ) {
828828 $this->mParserOutput = $parserCache->get( $this, $parserOptions );
829829 if ( $this->mParserOutput !== false ) {
830 - wfDebug( __METHOD__.": showing parser cache contents\n" );
 830+ wfDebug( __METHOD__ . ": showing parser cache contents\n" );
831831 $wgOut->addParserOutput( $this->mParserOutput );
832832 # Ensure that UI elements requiring revision ID have
833833 # the correct version information.
@@ -838,16 +838,16 @@
839839
840840 case 3:
841841 $text = $this->getContent();
842 - if( $text === false || $this->getID() == 0 ) {
843 - wfDebug( __METHOD__.": showing missing article\n" );
 842+ if ( $text === false || $this->getID() == 0 ) {
 843+ wfDebug( __METHOD__ . ": showing missing article\n" );
844844 $this->showMissingArticle();
845845 wfProfileOut( __METHOD__ );
846846 return;
847847 }
848848
849849 # Another whitelist check in case oldid is altering the title
850 - if( !$this->mTitle->userCanRead() ) {
851 - wfDebug( __METHOD__.": denied on secondary read check\n" );
 850+ if ( !$this->mTitle->userCanRead() ) {
 851+ wfDebug( __METHOD__ . ": denied on secondary read check\n" );
852852 $wgOut->loginToUse();
853853 $wgOut->output();
854854 $wgOut->disable();
@@ -856,10 +856,10 @@
857857 }
858858
859859 # Are we looking at an old revision
860 - if( $oldid && !is_null( $this->mRevision ) ) {
 860+ if ( $oldid && !is_null( $this->mRevision ) ) {
861861 $this->setOldSubtitle( $oldid );
862862 if ( !$this->showDeletedRevisionHeader() ) {
863 - wfDebug( __METHOD__.": cannot view deleted revision\n" );
 863+ wfDebug( __METHOD__ . ": cannot view deleted revision\n" );
864864 wfProfileOut( __METHOD__ );
865865 return;
866866 }
@@ -867,7 +867,7 @@
868868 if ( $oldid === $this->getLatest() && $this->useParserCache( false ) ) {
869869 $this->mParserOutput = $parserCache->get( $this, $parserOptions );
870870 if ( $this->mParserOutput ) {
871 - wfDebug( __METHOD__.": showing parser cache for current rev permalink\n" );
 871+ wfDebug( __METHOD__ . ": showing parser cache for current rev permalink\n" );
872872 $wgOut->addParserOutput( $this->mParserOutput );
873873 $wgOut->setRevisionId( $this->mLatest );
874874 $this->showViewFooter();
@@ -883,12 +883,12 @@
884884 $wgOut->setRevisionId( $this->getRevIdFetched() );
885885
886886 # Pages containing custom CSS or JavaScript get special treatment
887 - if( $this->mTitle->isCssOrJsPage() || $this->mTitle->isCssJsSubpage() ) {
888 - wfDebug( __METHOD__.": showing CSS/JS source\n" );
 887+ if ( $this->mTitle->isCssOrJsPage() || $this->mTitle->isCssJsSubpage() ) {
 888+ wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
889889 $this->showCssOrJsPage();
890890 $outputDone = true;
891 - } else if( $rt = Title::newFromRedirectArray( $text ) ) {
892 - wfDebug( __METHOD__.": showing redirect=no page\n" );
 891+ } else if ( $rt = Title::newFromRedirectArray( $text ) ) {
 892+ wfDebug( __METHOD__ . ": showing redirect=no page\n" );
893893 # Viewing a redirect page (e.g. with parameter redirect=no)
894894 # Don't append the subtitle if this was an old revision
895895 $wgOut->addHTML( $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ) );
@@ -901,7 +901,7 @@
902902
903903 case 4:
904904 # Run the parse, protected by a pool counter
905 - wfDebug( __METHOD__.": doing uncached parse\n" );
 905+ wfDebug( __METHOD__ . ": doing uncached parse\n" );
906906 $key = $parserCache->getKey( $this, $parserOptions );
907907 $poolCounter = PoolCounter::factory( 'Article::view', $key );
908908 $dirtyCallback = $useParserCache ? array( $this, 'tryDirtyCache' ) : false;
@@ -945,7 +945,7 @@
946946 $rcid = $wgRequest->getVal( 'rcid' );
947947 $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
948948 $purge = $wgRequest->getVal( 'action' ) == 'purge';
949 - $unhide = $wgRequest->getInt('unhide') == 1;
 949+ $unhide = $wgRequest->getInt( 'unhide' ) == 1;
950950 $oldid = $this->getOldID();
951951
952952 $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge, $unhide );
@@ -955,7 +955,7 @@
956956
957957 // Needed to get the page's current revision
958958 $this->loadPageData();
959 - if( $diff == 0 || $diff == $this->mLatest ) {
 959+ if ( $diff == 0 || $diff == $this->mLatest ) {
960960 # Run view updates for current revision only
961961 $this->viewUpdates();
962962 }
@@ -972,7 +972,7 @@
973973 global $wgOut;
974974 $wgOut->addHTML( wfMsgExt( 'clearyourcache', 'parse' ) );
975975 // Give hooks a chance to customise the output
976 - if( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->mTitle, $wgOut ) ) ) {
 976+ if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->mTitle, $wgOut ) ) ) {
977977 // Wrap the whole lot in a <pre> and don't parse
978978 $m = array();
979979 preg_match( '!\.(css|js)$!u', $this->mTitle->getText(), $m );
@@ -1000,32 +1000,32 @@
10011001 * @return Array the policy that should be set
10021002 * TODO: actions other than 'view'
10031003 */
1004 - public function getRobotPolicy( $action ){
 1004+ public function getRobotPolicy( $action ) {
10051005
10061006 global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies;
10071007 global $wgDefaultRobotPolicy, $wgRequest;
10081008
10091009 $ns = $this->mTitle->getNamespace();
1010 - if( $ns == NS_USER || $ns == NS_USER_TALK ) {
 1010+ if ( $ns == NS_USER || $ns == NS_USER_TALK ) {
10111011 # Don't index user and user talk pages for blocked users (bug 11443)
1012 - if( !$this->mTitle->isSubpage() ) {
 1012+ if ( !$this->mTitle->isSubpage() ) {
10131013 $block = new Block();
1014 - if( $block->load( $this->mTitle->getText() ) ) {
 1014+ if ( $block->load( $this->mTitle->getText() ) ) {
10151015 return array( 'index' => 'noindex',
10161016 'follow' => 'nofollow' );
10171017 }
10181018 }
10191019 }
10201020
1021 - if( $this->getID() === 0 || $this->getOldID() ) {
 1021+ if ( $this->getID() === 0 || $this->getOldID() ) {
10221022 # Non-articles (special pages etc), and old revisions
10231023 return array( 'index' => 'noindex',
10241024 'follow' => 'nofollow' );
1025 - } elseif( $wgOut->isPrintable() ) {
 1025+ } elseif ( $wgOut->isPrintable() ) {
10261026 # Discourage indexing of printable versions, but encourage following
10271027 return array( 'index' => 'noindex',
10281028 'follow' => 'follow' );
1029 - } elseif( $wgRequest->getInt('curid') ) {
 1029+ } elseif ( $wgRequest->getInt( 'curid' ) ) {
10301030 # For ?curid=x urls, disallow indexing
10311031 return array( 'index' => 'noindex',
10321032 'follow' => 'follow' );
@@ -1034,19 +1034,19 @@
10351035 # Otherwise, construct the policy based on the various config variables.
10361036 $policy = self::formatRobotPolicy( $wgDefaultRobotPolicy );
10371037
1038 - if( isset( $wgNamespaceRobotPolicies[$ns] ) ){
 1038+ if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
10391039 # Honour customised robot policies for this namespace
10401040 $policy = array_merge( $policy,
10411041 self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] ) );
10421042 }
1043 - if( $this->mTitle->canUseNoindex() && is_object( $this->mParserOutput ) && $this->mParserOutput->getIndexPolicy() ){
 1043+ if ( $this->mTitle->canUseNoindex() && is_object( $this->mParserOutput ) && $this->mParserOutput->getIndexPolicy() ) {
10441044 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
10451045 # a final sanity check that we have really got the parser output.
10461046 $policy = array_merge( $policy,
10471047 array( 'index' => $this->mParserOutput->getIndexPolicy() ) );
10481048 }
10491049
1050 - if( isset( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) ){
 1050+ if ( isset( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) ) {
10511051 # (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
10521052 $policy = array_merge( $policy,
10531053 self::formatRobotPolicy( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) );
@@ -1063,10 +1063,10 @@
10641064 * to already-converted arrays, converts String.
10651065 * @return associative Array: 'index' => <indexpolicy>, 'follow' => <followpolicy>
10661066 */
1067 - public static function formatRobotPolicy( $policy ){
1068 - if( is_array( $policy ) ){
 1067+ public static function formatRobotPolicy( $policy ) {
 1068+ if ( is_array( $policy ) ) {
10691069 return $policy;
1070 - } elseif( !$policy ){
 1070+ } elseif ( !$policy ) {
10711071 return array();
10721072 }
10731073
@@ -1074,10 +1074,10 @@
10751075 $policy = array_map( 'trim', $policy );
10761076
10771077 $arr = array();
1078 - foreach( $policy as $var ){
1079 - if( in_array( $var, array('index','noindex') ) ){
 1078+ foreach ( $policy as $var ) {
 1079+ if ( in_array( $var, array( 'index', 'noindex' ) ) ) {
10801080 $arr['index'] = $var;
1081 - } elseif( in_array( $var, array('follow','nofollow') ) ){
 1081+ } elseif ( in_array( $var, array( 'follow', 'nofollow' ) ) ) {
10821082 $arr['follow'] = $var;
10831083 }
10841084 }
@@ -1094,10 +1094,10 @@
10951095
10961096 $rdfrom = $wgRequest->getVal( 'rdfrom' );
10971097 $sk = $wgUser->getSkin();
1098 - if( isset( $this->mRedirectedFrom ) ) {
 1098+ if ( isset( $this->mRedirectedFrom ) ) {
10991099 // This is an internally redirected page view.
11001100 // We'll need a backlink to the source page for navigation.
1101 - if( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
 1101+ if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
11021102 $redir = $sk->link(
11031103 $this->mRedirectedFrom,
11041104 null,
@@ -1109,7 +1109,7 @@
11101110 $wgOut->setSubtitle( $s );
11111111
11121112 // Set the fragment if one was specified in the redirect
1113 - if( strval( $this->mTitle->getFragment() ) != '' ) {
 1113+ if ( strval( $this->mTitle->getFragment() ) != '' ) {
11141114 $fragment = Xml::escapeJsString( $this->mTitle->getFragmentForURL() );
11151115 $wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" );
11161116 }
@@ -1120,10 +1120,10 @@
11211121 );
11221122 return true;
11231123 }
1124 - } elseif( $rdfrom ) {
 1124+ } elseif ( $rdfrom ) {
11251125 // This is an externally redirected view, from some other wiki.
11261126 // If it was reported from a trusted site, supply a backlink.
1127 - if( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
 1127+ if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
11281128 $redir = $sk->makeExternalLink( $rdfrom, $rdfrom );
11291129 $s = wfMsgExt( 'redirectedfrom', array( 'parseinline', 'replaceafter' ), $redir );
11301130 $wgOut->setSubtitle( $s );
@@ -1139,7 +1139,7 @@
11401140 */
11411141 public function showNamespaceHeader() {
11421142 global $wgOut;
1143 - if( $this->mTitle->isTalkPage() ) {
 1143+ if ( $this->mTitle->isTalkPage() ) {
11441144 $msg = wfMsgNoTrans( 'talkpageheader' );
11451145 if ( $msg !== '-' && !wfEmptyMsg( 'talkpageheader', $msg ) ) {
11461146 $wgOut->wrapWikiMsg( "<div class=\"mw-talkpageheader\">\n$1</div>", array( 'talkpageheader' ) );
@@ -1153,8 +1153,8 @@
11541154 public function showViewFooter() {
11551155 global $wgOut, $wgUseTrackbacks, $wgRequest;
11561156 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
1157 - if( $this->mTitle->getNamespace() == NS_USER_TALK && IP::isValid( $this->mTitle->getText() ) ) {
1158 - $wgOut->addWikiMsg('anontalkpagetext');
 1157+ if ( $this->mTitle->getNamespace() == NS_USER_TALK && IP::isValid( $this->mTitle->getText() ) ) {
 1158+ $wgOut->addWikiMsg( 'anontalkpagetext' );
11591159 }
11601160
11611161 # If we have been passed an &rcid= parameter, we want to give the user a
@@ -1162,7 +1162,7 @@
11631163 $this->showPatrolFooter();
11641164
11651165 # Trackbacks
1166 - if( $wgUseTrackbacks ) {
 1166+ if ( $wgUseTrackbacks ) {
11671167 $this->addTrackbacks();
11681168 }
11691169 }
@@ -1176,7 +1176,7 @@
11771177 global $wgOut, $wgRequest, $wgUser;
11781178 $rcid = $wgRequest->getVal( 'rcid' );
11791179
1180 - if( !$rcid || !$this->mTitle->exists() || !$this->mTitle->quickUserCan( 'patrol' ) ) {
 1180+ if ( !$rcid || !$this->mTitle->exists() || !$this->mTitle->quickUserCan( 'patrol' ) ) {
11811181 return;
11821182 }
11831183
@@ -1217,7 +1217,7 @@
12181218 if ( $id == 0 && !$ip ) { # User does not exist
12191219 $wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1</div>",
12201220 array( 'userpage-userdoesnotexist-view', $rootPart ) );
1221 - } else if (User::newFromId($id)->isBlocked()) { # Show log extract if the user is currently blocked
 1221+ } else if ( User::newFromId( $id )->isBlocked() ) { # Show log extract if the user is currently blocked
12221222 LogEventsList::showLogExtract(
12231223 $wgOut,
12241224 'block',
@@ -1245,7 +1245,7 @@
12461246
12471247 # Show error message
12481248 $oldid = $this->getOldID();
1249 - if( $oldid ) {
 1249+ if ( $oldid ) {
12501250 $text = wfMsgNoTrans( 'missing-article',
12511251 $this->mTitle->getPrefixedText(),
12521252 wfMsgNoTrans( 'missingarticle-rev', $oldid ) );
@@ -1257,13 +1257,13 @@
12581258 $editErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser );
12591259 $errors = array_merge( $createErrors, $editErrors );
12601260
1261 - if ( !count($errors) )
 1261+ if ( !count( $errors ) )
12621262 $text = wfMsgNoTrans( 'noarticletext' );
12631263 else
12641264 $text = wfMsgNoTrans( 'noarticletext-nopermission' );
12651265 }
12661266 $text = "<div class='noarticletext'>\n$text\n</div>";
1267 - if( !$this->hasViewableContent() ) {
 1267+ if ( !$this->hasViewableContent() ) {
12681268 // If there's no backing content, send a 404 Not Found
12691269 // for better machine handling of broken links.
12701270 $wgRequest->response()->header( "HTTP/1.x 404 Not Found" );
@@ -1278,24 +1278,24 @@
12791279 */
12801280 public function showDeletedRevisionHeader() {
12811281 global $wgOut, $wgRequest;
1282 - if( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
 1282+ if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
12831283 // Not deleted
12841284 return true;
12851285 }
12861286 // If the user is not allowed to see it...
1287 - if( !$this->mRevision->userCan(Revision::DELETED_TEXT) ) {
 1287+ if ( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) {
12881288 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n",
12891289 'rev-deleted-text-permission' );
12901290 return false;
12911291 // If the user needs to confirm that they want to see it...
1292 - } else if( $wgRequest->getInt('unhide') != 1 ) {
 1292+ } else if ( $wgRequest->getInt( 'unhide' ) != 1 ) {
12931293 # Give explanation and add a link to view the revision...
12941294 $oldid = intval( $this->getOldID() );
12951295 $link = $this->mTitle->getFullUrl( "oldid={$oldid}&unhide=1" );
12961296 $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
12971297 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
12981298 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n",
1299 - array($msg,$link) );
 1299+ array( $msg, $link ) );
13001300 return false;
13011301 // We are allowed to see...
13021302 } else {
@@ -1349,7 +1349,7 @@
13501350 $options->setIsPrintable( $wgOut->isPrintable() );
13511351 $output = $parserCache->getDirty( $this, $options );
13521352 if ( $output ) {
1353 - wfDebug( __METHOD__.": sending dirty output\n" );
 1353+ wfDebug( __METHOD__ . ": sending dirty output\n" );
13541354 wfDebugLog( 'dirty', "dirty output " . $parserCache->getKey( $this, $options ) . "\n" );
13551355 $wgOut->setSquidMaxage( 0 );
13561356 $this->mParserOutput = $output;
@@ -1358,7 +1358,7 @@
13591359 return true;
13601360 } else {
13611361 wfDebugLog( 'dirty', "dirty missing\n" );
1362 - wfDebug( __METHOD__.": no dirty cache\n" );
 1362+ wfDebug( __METHOD__ . ": no dirty cache\n" );
13631363 return false;
13641364 }
13651365 }
@@ -1388,7 +1388,7 @@
13891389 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
13901390 global $wgOut, $wgContLang, $wgStylePath, $wgUser;
13911391 # Display redirect
1392 - if( !is_array( $target ) ) {
 1392+ if ( !is_array( $target ) ) {
13931393 $target = array( $target );
13941394 }
13951395 $imageDir = $wgContLang->getDir();
@@ -1396,13 +1396,13 @@
13971397 $imageUrl2 = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
13981398 $alt2 = $wgContLang->isRTL() ? '&larr;' : '&rarr;'; // should -> and <- be used instead of entities?
13991399
1400 - if( $appendSubtitle ) {
 1400+ if ( $appendSubtitle ) {
14011401 $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) );
14021402 }
14031403 $sk = $wgUser->getSkin();
14041404 // the loop prepends the arrow image before the link, so the first case needs to be outside
14051405 $title = array_shift( $target );
1406 - if( $forceKnown ) {
 1406+ if ( $forceKnown ) {
14071407 $link = $sk->link(
14081408 $title,
14091409 htmlspecialchars( $title->getFullText() ),
@@ -1414,9 +1414,9 @@
14151415 $link = $sk->link( $title, htmlspecialchars( $title->getFullText() ) );
14161416 }
14171417 // automatically append redirect=no to each link, since most of them are redirect pages themselves
1418 - foreach( $target as $rt ) {
1419 - if( $forceKnown ) {
1420 - $link .= '<img src="'.$imageUrl2.'" alt="'.$alt2.' " />'
 1418+ foreach ( $target as $rt ) {
 1419+ if ( $forceKnown ) {
 1420+ $link .= '<img src="' . $imageUrl2 . '" alt="' . $alt2 . ' " />'
14211421 . $sk->link(
14221422 $rt,
14231423 htmlspecialchars( $rt->getFullText() ),
@@ -1425,12 +1425,12 @@
14261426 array( 'known', 'noclasses' )
14271427 );
14281428 } else {
1429 - $link .= '<img src="'.$imageUrl2.'" alt="'.$alt2.' " />'
 1429+ $link .= '<img src="' . $imageUrl2 . '" alt="' . $alt2 . ' " />'
14301430 . $sk->link( $rt, htmlspecialchars( $rt->getFullText() ) );
14311431 }
14321432 }
1433 - return '<img src="'.$imageUrl.'" alt="#REDIRECT " />' .
1434 - '<span class="redirectText">'.$link.'</span>';
 1433+ return '<img src="' . $imageUrl . '" alt="#REDIRECT " />' .
 1434+ '<span class="redirectText">' . $link . '</span>';
14351435
14361436 }
14371437
@@ -1438,26 +1438,26 @@
14391439 global $wgOut, $wgUser;
14401440 $dbr = wfGetDB( DB_SLAVE );
14411441 $tbs = $dbr->select( 'trackbacks',
1442 - array('tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name'),
1443 - array('tb_page' => $this->getID() )
 1442+ array( 'tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name' ),
 1443+ array( 'tb_page' => $this->getID() )
14441444 );
1445 - if( !$dbr->numRows($tbs) ) return;
 1445+ if ( !$dbr->numRows( $tbs ) ) return;
14461446
14471447 $tbtext = "";
1448 - while( $o = $dbr->fetchObject($tbs) ) {
 1448+ while ( $o = $dbr->fetchObject( $tbs ) ) {
14491449 $rmvtxt = "";
1450 - if( $wgUser->isAllowed( 'trackback' ) ) {
1451 - $delurl = $this->mTitle->getFullURL("action=deletetrackback&tbid=" .
 1450+ if ( $wgUser->isAllowed( 'trackback' ) ) {
 1451+ $delurl = $this->mTitle->getFullURL( "action=deletetrackback&tbid=" .
14521452 $o->tb_id . "&token=" . urlencode( $wgUser->editToken() ) );
14531453 $rmvtxt = wfMsg( 'trackbackremove', htmlspecialchars( $delurl ) );
14541454 }
14551455 $tbtext .= "\n";
1456 - $tbtext .= wfMsg(strlen($o->tb_ex) ? 'trackbackexcerpt' : 'trackback',
 1456+ $tbtext .= wfMsg( strlen( $o->tb_ex ) ? 'trackbackexcerpt' : 'trackback',
14571457 $o->tb_title,
14581458 $o->tb_url,
14591459 $o->tb_ex,
14601460 $o->tb_name,
1461 - $rmvtxt);
 1461+ $rmvtxt );
14621462 }
14631463 $wgOut->wrapWikiMsg( "<div id='mw_trackbacks'>$1</div>\n", array( 'trackbackbox', $tbtext ) );
14641464 $this->mTitle->invalidateCache();
@@ -1465,19 +1465,19 @@
14661466
14671467 public function deletetrackback() {
14681468 global $wgUser, $wgRequest, $wgOut;
1469 - if( !$wgUser->matchEditToken($wgRequest->getVal('token')) ) {
 1469+ if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
14701470 $wgOut->addWikiMsg( 'sessionfailure' );
14711471 return;
14721472 }
14731473
14741474 $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
1475 - if( count($permission_errors) ) {
 1475+ if ( count( $permission_errors ) ) {
14761476 $wgOut->showPermissionsErrorPage( $permission_errors );
14771477 return;
14781478 }
14791479
14801480 $db = wfGetDB( DB_MASTER );
1481 - $db->delete( 'trackbacks', array('tb_id' => $wgRequest->getInt('tbid')) );
 1481+ $db->delete( 'trackbacks', array( 'tb_id' => $wgRequest->getInt( 'tbid' ) ) );
14821482
14831483 $wgOut->addWikiMsg( 'trackbackdeleteok' );
14841484 $this->mTitle->invalidateCache();
@@ -1485,7 +1485,7 @@
14861486
14871487 public function render() {
14881488 global $wgOut;
1489 - $wgOut->setArticleBodyOnly(true);
 1489+ $wgOut->setArticleBodyOnly( true );
14901490 $this->view();
14911491 }
14921492
@@ -1494,19 +1494,19 @@
14951495 */
14961496 public function purge() {
14971497 global $wgUser, $wgRequest, $wgOut;
1498 - if( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) {
1499 - if( wfRunHooks( 'ArticlePurge', array( &$this ) ) ) {
 1498+ if ( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) {
 1499+ if ( wfRunHooks( 'ArticlePurge', array( &$this ) ) ) {
15001500 $this->doPurge();
15011501 $this->view();
15021502 }
15031503 } else {
15041504 $action = htmlspecialchars( $wgRequest->getRequestURL() );
1505 - $button = wfMsgExt( 'confirm_purge_button', array('escapenoentities') );
 1505+ $button = wfMsgExt( 'confirm_purge_button', array( 'escapenoentities' ) );
15061506 $form = "<form method=\"post\" action=\"$action\">\n" .
15071507 "<input type=\"submit\" name=\"submit\" value=\"$button\" />\n" .
15081508 "</form>\n";
1509 - $top = wfMsgExt( 'confirm-purge-top', array('parse') );
1510 - $bottom = wfMsgExt( 'confirm-purge-bottom', array('parse') );
 1509+ $top = wfMsgExt( 'confirm-purge-top', array( 'parse' ) );
 1510+ $bottom = wfMsgExt( 'confirm-purge-bottom', array( 'parse' ) );
15111511 $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
15121512 $wgOut->setRobotPolicy( 'noindex,nofollow' );
15131513 $wgOut->addHTML( $top . $form . $bottom );
@@ -1521,7 +1521,7 @@
15221522 // Invalidate the cache
15231523 $this->mTitle->invalidateCache();
15241524
1525 - if( $wgUseSquid ) {
 1525+ if ( $wgUseSquid ) {
15261526 // Commit the transaction before the purge is sent
15271527 $dbw = wfGetDB( DB_MASTER );
15281528 $dbw->commit();
@@ -1530,9 +1530,9 @@
15311531 $update = SquidUpdate::newSimplePurge( $this->mTitle );
15321532 $update->doUpdate();
15331533 }
1534 - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 1534+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
15351535 global $wgMessageCache;
1536 - if( $this->getID() == 0 ) {
 1536+ if ( $this->getID() == 0 ) {
15371537 $text = false;
15381538 } else {
15391539 $text = $this->getRawText();
@@ -1571,7 +1571,7 @@
15721572 ), __METHOD__, 'IGNORE' );
15731573
15741574 $affected = $dbw->affectedRows();
1575 - if( $affected ) {
 1575+ if ( $affected ) {
15761576 $newid = $dbw->insertId();
15771577 $this->mTitle->resetArticleId( $newid );
15781578 }
@@ -1601,7 +1601,7 @@
16021602 $rt = Title::newFromRedirect( $text );
16031603
16041604 $conditions = array( 'page_id' => $this->getId() );
1605 - if( !is_null( $lastRevision ) ) {
 1605+ if ( !is_null( $lastRevision ) ) {
16061606 # An extra check against threads stepping on each other
16071607 $conditions['page_latest'] = $lastRevision;
16081608 }
@@ -1610,7 +1610,7 @@
16111611 array( /* SET */
16121612 'page_latest' => $revision->getId(),
16131613 'page_touched' => $dbw->timestamp(),
1614 - 'page_is_new' => ($lastRevision === 0) ? 1 : 0,
 1614+ 'page_is_new' => ( $lastRevision === 0 ) ? 1 : 0,
16151615 'page_is_redirect' => $rt !== null ? 1 : 0,
16161616 'page_len' => strlen( $text ),
16171617 ),
@@ -1618,7 +1618,7 @@
16191619 __METHOD__ );
16201620
16211621 $result = $dbw->affectedRows() != 0;
1622 - if( $result ) {
 1622+ if ( $result ) {
16231623 $this->updateRedirectOn( $dbw, $rt, $lastRevIsRedirect );
16241624 }
16251625
@@ -1641,10 +1641,10 @@
16421642 // Always update redirects (target link might have changed)
16431643 // Update/Insert if we don't know if the last revision was a redirect or not
16441644 // Delete if changing from redirect to non-redirect
1645 - $isRedirect = !is_null($redirectTitle);
1646 - if($isRedirect || is_null($lastRevIsRedirect) || $lastRevIsRedirect !== $isRedirect) {
 1645+ $isRedirect = !is_null( $redirectTitle );
 1646+ if ( $isRedirect || is_null( $lastRevIsRedirect ) || $lastRevIsRedirect !== $isRedirect ) {
16471647 wfProfileIn( __METHOD__ );
1648 - if( $isRedirect ) {
 1648+ if ( $isRedirect ) {
16491649 // This title is a redirect, Add/Update row in the redirect table
16501650 $set = array( /* SET */
16511651 'rd_namespace' => $redirectTitle->getNamespace(),
@@ -1655,9 +1655,9 @@
16561656 } else {
16571657 // This is not a redirect, remove row from redirect table
16581658 $where = array( 'rd_from' => $this->getId() );
1659 - $dbw->delete( 'redirect', $where, __METHOD__);
 1659+ $dbw->delete( 'redirect', $where, __METHOD__ );
16601660 }
1661 - if( $this->getTitle()->getNamespace() == NS_FILE ) {
 1661+ if ( $this->getTitle()->getNamespace() == NS_FILE ) {
16621662 RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $this->getTitle() );
16631663 }
16641664 wfProfileOut( __METHOD__ );
@@ -1682,8 +1682,8 @@
16831683 'page_id' => $this->getId(),
16841684 'page_latest=rev_id' ),
16851685 __METHOD__ );
1686 - if( $row ) {
1687 - if( wfTimestamp(TS_MW, $row->rev_timestamp) >= $revision->getTimestamp() ) {
 1686+ if ( $row ) {
 1687+ if ( wfTimestamp( TS_MW, $row->rev_timestamp ) >= $revision->getTimestamp() ) {
16881688 wfProfileOut( __METHOD__ );
16891689 return false;
16901690 }
@@ -1705,25 +1705,25 @@
17061706 */
17071707 public function replaceSection( $section, $text, $summary = '', $edittime = null ) {
17081708 wfProfileIn( __METHOD__ );
1709 - if( strval( $section ) == '' ) {
 1709+ if ( strval( $section ) == '' ) {
17101710 // Whole-page edit; let the whole text through
17111711 } else {
1712 - if( is_null($edittime) ) {
 1712+ if ( is_null( $edittime ) ) {
17131713 $rev = Revision::newFromTitle( $this->mTitle );
17141714 } else {
17151715 $dbw = wfGetDB( DB_MASTER );
17161716 $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime );
17171717 }
1718 - if( !$rev ) {
 1718+ if ( !$rev ) {
17191719 wfDebug( "Article::replaceSection asked for bogus section (page: " .
17201720 $this->getId() . "; section: $section; edittime: $edittime)\n" );
17211721 return null;
17221722 }
17231723 $oldtext = $rev->getText();
17241724
1725 - if( $section == 'new' ) {
 1725+ if ( $section == 'new' ) {
17261726 # Inserting a new section
1727 - $subject = $summary ? wfMsgForContent('newsectionheaderdefaultlevel',$summary) . "\n\n" : '';
 1727+ $subject = $summary ? wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" : '';
17281728 $text = strlen( trim( $oldtext ) ) > 0
17291729 ? "{$oldtext}\n\n{$subject}{$text}"
17301730 : "{$subject}{$text}";
@@ -1741,28 +1741,28 @@
17421742 * This function is not deprecated until somebody fixes the core not to use
17431743 * it. Nevertheless, use Article::doEdit() instead.
17441744 */
1745 - function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false, $bot=false ) {
 1745+ function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC = false, $comment = false, $bot = false ) {
17461746 $flags = EDIT_NEW | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
17471747 ( $isminor ? EDIT_MINOR : 0 ) |
17481748 ( $suppressRC ? EDIT_SUPPRESS_RC : 0 ) |
17491749 ( $bot ? EDIT_FORCE_BOT : 0 );
17501750
17511751 # If this is a comment, add the summary as headline
1752 - if( $comment && $summary != "" ) {
1753 - $text = wfMsgForContent('newsectionheaderdefaultlevel',$summary) . "\n\n".$text;
 1752+ if ( $comment && $summary != "" ) {
 1753+ $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" . $text;
17541754 }
17551755
17561756 $this->doEdit( $text, $summary, $flags );
17571757
17581758 $dbw = wfGetDB( DB_MASTER );
1759 - if($watchthis) {
1760 - if(!$this->mTitle->userIsWatching()) {
 1759+ if ( $watchthis ) {
 1760+ if ( !$this->mTitle->userIsWatching() ) {
17611761 $dbw->begin();
17621762 $this->doWatch();
17631763 $dbw->commit();
17641764 }
17651765 } else {
1766 - if( $this->mTitle->userIsWatching() ) {
 1766+ if ( $this->mTitle->userIsWatching() ) {
17671767 $dbw->begin();
17681768 $this->doUnwatch();
17691769 $dbw->commit();
@@ -1780,19 +1780,19 @@
17811781 ( $forceBot ? EDIT_FORCE_BOT : 0 );
17821782
17831783 $status = $this->doEdit( $text, $summary, $flags );
1784 - if( !$status->isOK() ) {
 1784+ if ( !$status->isOK() ) {
17851785 return false;
17861786 }
17871787
17881788 $dbw = wfGetDB( DB_MASTER );
1789 - if( $watchthis ) {
1790 - if(!$this->mTitle->userIsWatching()) {
 1789+ if ( $watchthis ) {
 1790+ if ( !$this->mTitle->userIsWatching() ) {
17911791 $dbw->begin();
17921792 $this->doWatch();
17931793 $dbw->commit();
17941794 }
17951795 } else {
1796 - if( $this->mTitle->userIsWatching() ) {
 1796+ if ( $this->mTitle->userIsWatching() ) {
17971797 $dbw->begin();
17981798 $this->doUnwatch();
17991799 $dbw->commit();
@@ -1860,47 +1860,47 @@
18611861 global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries;
18621862
18631863 # Low-level sanity check
1864 - if( $this->mTitle->getText() == '' ) {
 1864+ if ( $this->mTitle->getText() == '' ) {
18651865 throw new MWException( 'Something is trying to edit an article with an empty title' );
18661866 }
18671867
18681868 wfProfileIn( __METHOD__ );
18691869
1870 - $user = is_null($user) ? $wgUser : $user;
 1870+ $user = is_null( $user ) ? $wgUser : $user;
18711871 $status = Status::newGood( array() );
18721872
18731873 # Load $this->mTitle->getArticleID() and $this->mLatest if it's not already
18741874 $this->loadPageData();
18751875
1876 - if( !($flags & EDIT_NEW) && !($flags & EDIT_UPDATE) ) {
 1876+ if ( !( $flags & EDIT_NEW ) && !( $flags & EDIT_UPDATE ) ) {
18771877 $aid = $this->mTitle->getArticleID();
1878 - if( $aid ) {
 1878+ if ( $aid ) {
18791879 $flags |= EDIT_UPDATE;
18801880 } else {
18811881 $flags |= EDIT_NEW;
18821882 }
18831883 }
18841884
1885 - if( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, &$summary,
 1885+ if ( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, &$summary,
18861886 $flags & EDIT_MINOR, null, null, &$flags, &$status ) ) )
18871887 {
18881888 wfDebug( __METHOD__ . ": ArticleSave hook aborted save!\n" );
18891889 wfProfileOut( __METHOD__ );
1890 - if( $status->isOK() ) {
1891 - $status->fatal( 'edit-hook-aborted');
 1890+ if ( $status->isOK() ) {
 1891+ $status->fatal( 'edit-hook-aborted' );
18921892 }
18931893 return $status;
18941894 }
18951895
18961896 # Silently ignore EDIT_MINOR if not allowed
1897 - $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed('minoredit');
 1897+ $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed( 'minoredit' );
18981898 $bot = $flags & EDIT_FORCE_BOT;
18991899
19001900 $oldtext = $this->getRawText(); // current revision
19011901 $oldsize = strlen( $oldtext );
19021902
19031903 # Provide autosummaries if one is not provided and autosummaries are enabled.
1904 - if( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) {
 1904+ if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) {
19051905 $summary = $this->getAutosummary( $oldtext, $text, $flags );
19061906 }
19071907
@@ -1910,13 +1910,13 @@
19111911
19121912 $dbw = wfGetDB( DB_MASTER );
19131913 $now = wfTimestampNow();
1914 - $this->mTimestamp=$now;
 1914+ $this->mTimestamp = $now;
19151915
1916 - if( $flags & EDIT_UPDATE ) {
 1916+ if ( $flags & EDIT_UPDATE ) {
19171917 # Update article, but only if changed.
19181918 $status->value['new'] = false;
19191919 # Make sure the revision is either completely inserted or not inserted at all
1920 - if( !$wgDBtransactions ) {
 1920+ if ( !$wgDBtransactions ) {
19211921 $userAbort = ignore_user_abort( true );
19221922 }
19231923
@@ -1924,14 +1924,14 @@
19251925
19261926 $changed = ( strcmp( $text, $oldtext ) != 0 );
19271927
1928 - if( $changed ) {
 1928+ if ( $changed ) {
19291929 $this->mGoodAdjustment = (int)$this->isCountable( $text )
19301930 - (int)$this->isCountable( $oldtext );
19311931 $this->mTotalAdjustment = 0;
19321932
1933 - if( !$this->mLatest ) {
 1933+ if ( !$this->mLatest ) {
19341934 # Article gone missing
1935 - wfDebug( __METHOD__.": EDIT_UPDATE specified but article doesn't exist\n" );
 1935+ wfDebug( __METHOD__ . ": EDIT_UPDATE specified but article doesn't exist\n" );
19361936 $status->fatal( 'edit-gone-missing' );
19371937 wfProfileOut( __METHOD__ );
19381938 return $status;
@@ -1959,29 +1959,29 @@
19601960 # creates a window where concurrent edits can cause an ignored edit conflict.
19611961 $ok = $this->updateRevisionOn( $dbw, $revision, $this->mLatest );
19621962
1963 - if( !$ok ) {
 1963+ if ( !$ok ) {
19641964 /* Belated edit conflict! Run away!! */
19651965 $status->fatal( 'edit-conflict' );
19661966 # Delete the invalid revision if the DB is not transactional
1967 - if( !$wgDBtransactions ) {
 1967+ if ( !$wgDBtransactions ) {
19681968 $dbw->delete( 'revision', array( 'rev_id' => $revisionId ), __METHOD__ );
19691969 }
19701970 $revisionId = 0;
19711971 $dbw->rollback();
19721972 } else {
19731973 global $wgUseRCPatrol;
1974 - wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, $baseRevId, $user) );
 1974+ wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, $baseRevId, $user ) );
19751975 # Update recentchanges
1976 - if( !( $flags & EDIT_SUPPRESS_RC ) ) {
 1976+ if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
19771977 # Mark as patrolled if the user can do so
1978 - $patrolled = $wgUseRCPatrol && $this->mTitle->userCan('autopatrol');
 1978+ $patrolled = $wgUseRCPatrol && $this->mTitle->userCan( 'autopatrol' );
19791979 # Add RC row to the DB
19801980 $rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary,
19811981 $this->mLatest, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
19821982 $revisionId, $patrolled
19831983 );
19841984 # Log auto-patrolled edits
1985 - if( $patrolled ) {
 1985+ if ( $patrolled ) {
19861986 PatrolLog::record( $rc, true );
19871987 }
19881988 }
@@ -1998,11 +1998,11 @@
19991999 $this->mTitle->invalidateCache();
20002000 }
20012001
2002 - if( !$wgDBtransactions ) {
 2002+ if ( !$wgDBtransactions ) {
20032003 ignore_user_abort( $userAbort );
20042004 }
20052005 // Now that ignore_user_abort is restored, we can respond to fatal errors
2006 - if( !$status->isOK() ) {
 2006+ if ( !$status->isOK() ) {
20072007 wfProfileOut( __METHOD__ );
20082008 return $status;
20092009 }
@@ -2028,7 +2028,7 @@
20292029 # This will return false if the article already exists
20302030 $newid = $this->insertOn( $dbw );
20312031
2032 - if( $newid === false ) {
 2032+ if ( $newid === false ) {
20332033 $dbw->rollback();
20342034 $status->fatal( 'edit-already-exists' );
20352035 wfProfileOut( __METHOD__ );
@@ -2051,17 +2051,17 @@
20522052 # Update the page record with revision data
20532053 $this->updateRevisionOn( $dbw, $revision, 0 );
20542054
2055 - wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false, $user) );
 2055+ wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, false, $user ) );
20562056 # Update recentchanges
2057 - if( !( $flags & EDIT_SUPPRESS_RC ) ) {
 2057+ if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
20582058 global $wgUseRCPatrol, $wgUseNPPatrol;
20592059 # Mark as patrolled if the user can do so
2060 - $patrolled = ($wgUseRCPatrol || $wgUseNPPatrol) && $this->mTitle->userCan('autopatrol');
 2060+ $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) && $this->mTitle->userCan( 'autopatrol' );
20612061 # Add RC row to the DB
20622062 $rc = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $user, $summary, $bot,
2063 - '', strlen($text), $revisionId, $patrolled );
 2063+ '', strlen( $text ), $revisionId, $patrolled );
20642064 # Log auto-patrolled edits
2065 - if( $patrolled ) {
 2065+ if ( $patrolled ) {
20662066 PatrolLog::record( $rc, true );
20672067 }
20682068 }
@@ -2079,7 +2079,7 @@
20802080 }
20812081
20822082 # Do updates right now unless deferral was requested
2083 - if( !( $flags & EDIT_DEFER_UPDATES ) ) {
 2083+ if ( !( $flags & EDIT_DEFER_UPDATES ) ) {
20842084 wfDoUpdates();
20852085 }
20862086
@@ -2111,9 +2111,9 @@
21122112 */
21132113 public function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) {
21142114 global $wgOut;
2115 - if( $noRedir ) {
 2115+ if ( $noRedir ) {
21162116 $query = 'redirect=no';
2117 - if( $extraQuery )
 2117+ if ( $extraQuery )
21182118 $query .= "&$query";
21192119 } else {
21202120 $query = $extraQuery;
@@ -2129,38 +2129,38 @@
21302130 $wgOut->setRobotPolicy( 'noindex,nofollow' );
21312131
21322132 # If we haven't been given an rc_id value, we can't do anything
2133 - $rcid = (int) $wgRequest->getVal('rcid');
2134 - $rc = RecentChange::newFromId($rcid);
2135 - if( is_null($rc) ) {
 2133+ $rcid = (int) $wgRequest->getVal( 'rcid' );
 2134+ $rc = RecentChange::newFromId( $rcid );
 2135+ if ( is_null( $rc ) ) {
21362136 $wgOut->showErrorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
21372137 return;
21382138 }
21392139
2140 - #It would be nice to see where the user had actually come from, but for now just guess
 2140+ # It would be nice to see where the user had actually come from, but for now just guess
21412141 $returnto = $rc->getAttribute( 'rc_type' ) == RC_NEW ? 'Newpages' : 'Recentchanges';
21422142 $return = SpecialPage::getTitleFor( $returnto );
21432143
21442144 $dbw = wfGetDB( DB_MASTER );
21452145 $errors = $rc->doMarkPatrolled();
21462146
2147 - if( in_array(array('rcpatroldisabled'), $errors) ) {
 2147+ if ( in_array( array( 'rcpatroldisabled' ), $errors ) ) {
21482148 $wgOut->showErrorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
21492149 return;
21502150 }
21512151
2152 - if( in_array(array('hookaborted'), $errors) ) {
 2152+ if ( in_array( array( 'hookaborted' ), $errors ) ) {
21532153 // The hook itself has handled any output
21542154 return;
21552155 }
21562156
2157 - if( in_array(array('markedaspatrollederror-noautopatrol'), $errors) ) {
 2157+ if ( in_array( array( 'markedaspatrollederror-noautopatrol' ), $errors ) ) {
21582158 $wgOut->setPageTitle( wfMsg( 'markedaspatrollederror' ) );
21592159 $wgOut->addWikiMsg( 'markedaspatrollederror-noautopatrol' );
21602160 $wgOut->returnToMain( false, $return );
21612161 return;
21622162 }
21632163
2164 - if( !empty($errors) ) {
 2164+ if ( !empty( $errors ) ) {
21652165 $wgOut->showPermissionsErrorPage( $errors );
21662166 return;
21672167 }
@@ -2176,15 +2176,15 @@
21772177 */
21782178 public function watch() {
21792179 global $wgUser, $wgOut;
2180 - if( $wgUser->isAnon() ) {
 2180+ if ( $wgUser->isAnon() ) {
21812181 $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
21822182 return;
21832183 }
2184 - if( wfReadOnly() ) {
 2184+ if ( wfReadOnly() ) {
21852185 $wgOut->readOnlyPage();
21862186 return;
21872187 }
2188 - if( $this->doWatch() ) {
 2188+ if ( $this->doWatch() ) {
21892189 $wgOut->setPagetitle( wfMsg( 'addedwatch' ) );
21902190 $wgOut->setRobotPolicy( 'noindex,nofollow' );
21912191 $wgOut->addWikiMsg( 'addedwatchtext', $this->mTitle->getPrefixedText() );
@@ -2198,12 +2198,12 @@
21992199 */
22002200 public function doWatch() {
22012201 global $wgUser;
2202 - if( $wgUser->isAnon() ) {
 2202+ if ( $wgUser->isAnon() ) {
22032203 return false;
22042204 }
2205 - if( wfRunHooks('WatchArticle', array(&$wgUser, &$this)) ) {
 2205+ if ( wfRunHooks( 'WatchArticle', array( &$wgUser, &$this ) ) ) {
22062206 $wgUser->addWatch( $this->mTitle );
2207 - return wfRunHooks('WatchArticleComplete', array(&$wgUser, &$this));
 2207+ return wfRunHooks( 'WatchArticleComplete', array( &$wgUser, &$this ) );
22082208 }
22092209 return false;
22102210 }
@@ -2213,15 +2213,15 @@
22142214 */
22152215 public function unwatch() {
22162216 global $wgUser, $wgOut;
2217 - if( $wgUser->isAnon() ) {
 2217+ if ( $wgUser->isAnon() ) {
22182218 $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
22192219 return;
22202220 }
2221 - if( wfReadOnly() ) {
 2221+ if ( wfReadOnly() ) {
22222222 $wgOut->readOnlyPage();
22232223 return;
22242224 }
2225 - if( $this->doUnwatch() ) {
 2225+ if ( $this->doUnwatch() ) {
22262226 $wgOut->setPagetitle( wfMsg( 'removedwatch' ) );
22272227 $wgOut->setRobotPolicy( 'noindex,nofollow' );
22282228 $wgOut->addWikiMsg( 'removedwatchtext', $this->mTitle->getPrefixedText() );
@@ -2235,12 +2235,12 @@
22362236 */
22372237 public function doUnwatch() {
22382238 global $wgUser;
2239 - if( $wgUser->isAnon() ) {
 2239+ if ( $wgUser->isAnon() ) {
22402240 return false;
22412241 }
2242 - if( wfRunHooks('UnwatchArticle', array(&$wgUser, &$this)) ) {
 2242+ if ( wfRunHooks( 'UnwatchArticle', array( &$wgUser, &$this ) ) ) {
22432243 $wgUser->removeWatch( $this->mTitle );
2244 - return wfRunHooks('UnwatchArticleComplete', array(&$wgUser, &$this));
 2244+ return wfRunHooks( 'UnwatchArticleComplete', array( &$wgUser, &$this ) );
22452245 }
22462246 return false;
22472247 }
@@ -2290,7 +2290,7 @@
22912291 return false;
22922292 }
22932293
2294 - if( !$cascade ) {
 2294+ if ( !$cascade ) {
22952295 $cascade = false;
22962296 }
22972297
@@ -2302,17 +2302,17 @@
23032303 $current = array();
23042304 $updated = Article::flattenRestrictions( $limit );
23052305 $changed = false;
2306 - foreach( $restrictionTypes as $action ) {
2307 - if( isset( $expiry[$action] ) ) {
 2306+ foreach ( $restrictionTypes as $action ) {
 2307+ if ( isset( $expiry[$action] ) ) {
23082308 # Get current restrictions on $action
23092309 $aLimits = $this->mTitle->getRestrictions( $action );
23102310 $current[$action] = implode( '', $aLimits );
23112311 # Are any actual restrictions being dealt with here?
2312 - $aRChanged = count($aLimits) || !empty($limit[$action]);
 2312+ $aRChanged = count( $aLimits ) || !empty( $limit[$action] );
23132313 # If something changed, we need to log it. Checking $aRChanged
23142314 # assures that "unprotecting" a page that is not protected does
23152315 # not log just because the expiry was "changed".
2316 - if( $aRChanged && $this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action] ) {
 2316+ if ( $aRChanged && $this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action] ) {
23172317 $changed = true;
23182318 }
23192319 }
@@ -2320,19 +2320,19 @@
23212321
23222322 $current = Article::flattenRestrictions( $current );
23232323
2324 - $changed = ($changed || $current != $updated );
2325 - $changed = $changed || ($updated && $this->mTitle->areRestrictionsCascading() != $cascade);
 2324+ $changed = ( $changed || $current != $updated );
 2325+ $changed = $changed || ( $updated && $this->mTitle->areRestrictionsCascading() != $cascade );
23262326 $protect = ( $updated != '' );
23272327
23282328 # If nothing's changed, do nothing
2329 - if( $changed ) {
2330 - if( wfRunHooks( 'ArticleProtect', array( &$this, &$wgUser, $limit, $reason ) ) ) {
 2329+ if ( $changed ) {
 2330+ if ( wfRunHooks( 'ArticleProtect', array( &$this, &$wgUser, $limit, $reason ) ) ) {
23312331
23322332 $dbw = wfGetDB( DB_MASTER );
23332333
23342334 # Prepare a null revision to be added to the history
23352335 $modified = $current != '' && $protect;
2336 - if( $protect ) {
 2336+ if ( $protect ) {
23372337 $comment_type = $modified ? 'modifiedarticleprotection' : 'protectedarticle';
23382338 } else {
23392339 $comment_type = 'unprotectedarticle';
@@ -2343,27 +2343,27 @@
23442344 # Otherwise, people who cannot normally protect can "protect" pages via transclusion
23452345 $editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' );
23462346 # The schema allows multiple restrictions
2347 - if(!in_array('protect', $editrestriction) && !in_array('sysop', $editrestriction))
 2347+ if ( !in_array( 'protect', $editrestriction ) && !in_array( 'sysop', $editrestriction ) )
23482348 $cascade = false;
23492349 $cascade_description = '';
2350 - if( $cascade ) {
2351 - $cascade_description = ' ['.wfMsgForContent('protect-summary-cascade').']';
 2350+ if ( $cascade ) {
 2351+ $cascade_description = ' [' . wfMsgForContent( 'protect-summary-cascade' ) . ']';
23522352 }
23532353
2354 - if( $reason )
 2354+ if ( $reason )
23552355 $comment .= ": $reason";
23562356
23572357 $editComment = $comment;
23582358 $encodedExpiry = array();
23592359 $protect_description = '';
2360 - foreach( $limit as $action => $restrictions ) {
2361 - if ( !isset($expiry[$action]) )
 2360+ foreach ( $limit as $action => $restrictions ) {
 2361+ if ( !isset( $expiry[$action] ) )
23622362 $expiry[$action] = 'infinite';
23632363
2364 - $encodedExpiry[$action] = Block::encodeExpiry($expiry[$action], $dbw );
2365 - if( $restrictions != '' ) {
 2364+ $encodedExpiry[$action] = Block::encodeExpiry( $expiry[$action], $dbw );
 2365+ if ( $restrictions != '' ) {
23662366 $protect_description .= "[$action=$restrictions] (";
2367 - if( $encodedExpiry[$action] != 'infinity' ) {
 2367+ if ( $encodedExpiry[$action] != 'infinity' ) {
23682368 $protect_description .= wfMsgForContent( 'protect-expiring',
23692369 $wgContLang->timeanddate( $expiry[$action], false, false ) ,
23702370 $wgContLang->date( $expiry[$action], false, false ) ,
@@ -2374,20 +2374,20 @@
23752375 $protect_description .= ') ';
23762376 }
23772377 }
2378 - $protect_description = trim($protect_description);
 2378+ $protect_description = trim( $protect_description );
23792379
2380 - if( $protect_description && $protect )
 2380+ if ( $protect_description && $protect )
23812381 $editComment .= " ($protect_description)";
2382 - if( $cascade )
 2382+ if ( $cascade )
23832383 $editComment .= "$cascade_description";
23842384 # Update restrictions table
2385 - foreach( $limit as $action => $restrictions ) {
2386 - if($restrictions != '' ) {
2387 - $dbw->replace( 'page_restrictions', array(array('pr_page', 'pr_type')),
 2385+ foreach ( $limit as $action => $restrictions ) {
 2386+ if ( $restrictions != '' ) {
 2387+ $dbw->replace( 'page_restrictions', array( array( 'pr_page', 'pr_type' ) ),
23882388 array( 'pr_page' => $id,
23892389 'pr_type' => $action,
23902390 'pr_level' => $restrictions,
2391 - 'pr_cascade' => ($cascade && $action == 'edit') ? 1 : 0,
 2391+ 'pr_cascade' => ( $cascade && $action == 'edit' ) ? 1 : 0,
23922392 'pr_expiry' => $encodedExpiry[$action] ), __METHOD__ );
23932393 } else {
23942394 $dbw->delete( 'page_restrictions', array( 'pr_page' => $id,
@@ -2411,14 +2411,14 @@
24122412 ), 'Article::protect'
24132413 );
24142414
2415 - wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, $latest, $wgUser) );
 2415+ wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $nullRevision, $latest, $wgUser ) );
24162416 wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) );
24172417
24182418 # Update the protection log
24192419 $log = new LogPage( 'protect' );
2420 - if( $protect ) {
2421 - $params = array($protect_description,$cascade ? 'cascade' : '');
2422 - $log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle, trim( $reason), $params );
 2420+ if ( $protect ) {
 2421+ $params = array( $protect_description, $cascade ? 'cascade' : '' );
 2422+ $log->addEntry( $modified ? 'modify' : 'protect', $this->mTitle, trim( $reason ), $params );
24232423 } else {
24242424 $log->addEntry( 'unprotect', $this->mTitle, $reason );
24252425 }
@@ -2436,13 +2436,13 @@
24372437 * @return String
24382438 */
24392439 protected static function flattenRestrictions( $limit ) {
2440 - if( !is_array( $limit ) ) {
 2440+ if ( !is_array( $limit ) ) {
24412441 throw new MWException( 'Article::flattenRestrictions given non-array restriction set' );
24422442 }
24432443 $bits = array();
24442444 ksort( $limit );
2445 - foreach( $limit as $action => $restrictions ) {
2446 - if( $restrictions != '' ) {
 2445+ foreach ( $limit as $action => $restrictions ) {
 2446+ if ( $restrictions != '' ) {
24472447 $bits[] = "$action=$restrictions";
24482448 }
24492449 }
@@ -2458,7 +2458,7 @@
24592459 $dbw = wfGetDB( DB_MASTER );
24602460 // Get the last revision
24612461 $rev = Revision::newFromTitle( $this->mTitle );
2462 - if( is_null( $rev ) )
 2462+ if ( is_null( $rev ) )
24632463 return false;
24642464
24652465 // Get the article's contents
@@ -2466,9 +2466,9 @@
24672467 $blank = false;
24682468 // If the page is blank, use the text from the previous revision,
24692469 // which can only be blank if there's a move/import/protect dummy revision involved
2470 - if( $contents == '' ) {
 2470+ if ( $contents == '' ) {
24712471 $prev = $rev->getPrevious();
2472 - if( $prev ) {
 2472+ if ( $prev ) {
24732473 $contents = $prev->getText();
24742474 $blank = true;
24752475 }
@@ -2477,11 +2477,11 @@
24782478 // Find out if there was only one contributor
24792479 // Only scan the last 20 revisions
24802480 $res = $dbw->select( 'revision', 'rev_user_text',
2481 - array( 'rev_page' => $this->getID(), $dbw->bitAnd('rev_deleted', Revision::DELETED_USER) . ' = 0' ),
 2481+ array( 'rev_page' => $this->getID(), $dbw->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' ),
24822482 __METHOD__,
24832483 array( 'LIMIT' => 20 )
24842484 );
2485 - if( $res === false )
 2485+ if ( $res === false )
24862486 // This page has no revisions, which is very weird
24872487 return false;
24882488
@@ -2489,8 +2489,8 @@
24902490 $row = $dbw->fetchObject( $res );
24912491 $onlyAuthor = $row->rev_user_text;
24922492 // Try to find a second contributor
2493 - foreach( $res as $row ) {
2494 - if( $row->rev_user_text != $onlyAuthor ) {
 2493+ foreach ( $res as $row ) {
 2494+ if ( $row->rev_user_text != $onlyAuthor ) {
24952495 $onlyAuthor = false;
24962496 break;
24972497 }
@@ -2498,18 +2498,18 @@
24992499 $dbw->freeResult( $res );
25002500
25012501 // Generate the summary with a '$1' placeholder
2502 - if( $blank ) {
 2502+ if ( $blank ) {
25032503 // The current revision is blank and the one before is also
25042504 // blank. It's just not our lucky day
25052505 $reason = wfMsgForContent( 'exbeforeblank', '$1' );
25062506 } else {
2507 - if( $onlyAuthor )
 2507+ if ( $onlyAuthor )
25082508 $reason = wfMsgForContent( 'excontentauthor', '$1', $onlyAuthor );
25092509 else
25102510 $reason = wfMsgForContent( 'excontent', '$1' );
25112511 }
25122512
2513 - if( $reason == '-' ) {
 2513+ if ( $reason == '-' ) {
25142514 // Allow these UI messages to be blanked out cleanly
25152515 return '';
25162516 }
@@ -2518,7 +2518,7 @@
25192519 $contents = preg_replace( "/[\n\r]/", ' ', $contents );
25202520 // Calculate the maximum amount of chars to get
25212521 // Max content length = max comment length - length of the comment (excl. $1) - '...'
2522 - $maxLength = 255 - (strlen( $reason ) - 2) - 3;
 2522+ $maxLength = 255 - ( strlen( $reason ) - 2 ) - 3;
25232523 $contents = $wgContLang->truncate( $contents, $maxLength );
25242524 // Remove possible unfinished links
25252525 $contents = preg_replace( '/\[\[([^\]]*)\]?$/', '$1', $contents );
@@ -2542,10 +2542,10 @@
25432543
25442544 $reason = $this->DeleteReasonList;
25452545
2546 - if( $reason != 'other' && $this->DeleteReason != '' ) {
 2546+ if ( $reason != 'other' && $this->DeleteReason != '' ) {
25472547 // Entry from drop down menu + additional comment
25482548 $reason .= wfMsgForContent( 'colon-separator' ) . $this->DeleteReason;
2549 - } elseif( $reason == 'other' ) {
 2549+ } elseif ( $reason == 'other' ) {
25502550 $reason = $this->DeleteReason;
25512551 }
25522552 # Flag to hide all contents of the archived revisions
@@ -2554,7 +2554,7 @@
25552555 # This code desperately needs to be totally rewritten
25562556
25572557 # Read-only check...
2558 - if( wfReadOnly() ) {
 2558+ if ( wfReadOnly() ) {
25592559 $wgOut->readOnlyPage();
25602560 return;
25612561 }
@@ -2562,7 +2562,7 @@
25632563 # Check permissions
25642564 $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
25652565
2566 - if( count( $permission_errors ) > 0 ) {
 2566+ if ( count( $permission_errors ) > 0 ) {
25672567 $wgOut->showPermissionsErrorPage( $permission_errors );
25682568 return;
25692569 }
@@ -2573,7 +2573,7 @@
25742574 $dbw = wfGetDB( DB_MASTER );
25752575 $conds = $this->mTitle->pageCond();
25762576 $latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ );
2577 - if( $latest === false ) {
 2577+ if ( $latest === false ) {
25782578 $wgOut->showFatalError(
25792579 Html::rawElement(
25802580 'div',
@@ -2592,18 +2592,18 @@
25932593
25942594 # Hack for big sites
25952595 $bigHistory = $this->isBigDeletion();
2596 - if( $bigHistory && !$this->mTitle->userCan( 'bigdelete' ) ) {
 2596+ if ( $bigHistory && !$this->mTitle->userCan( 'bigdelete' ) ) {
25972597 global $wgLang, $wgDeleteRevisionsLimit;
25982598 $wgOut->wrapWikiMsg( "<div class='error'>\n$1</div>\n",
25992599 array( 'delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
26002600 return;
26012601 }
26022602
2603 - if( $confirm ) {
 2603+ if ( $confirm ) {
26042604 $this->doDelete( $reason, $suppress );
2605 - if( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
 2605+ if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
26062606 $this->doWatch();
2607 - } elseif( $this->mTitle->userIsWatching() ) {
 2607+ } elseif ( $this->mTitle->userIsWatching() ) {
26082608 $this->doUnwatch();
26092609 }
26102610 return;
@@ -2611,10 +2611,10 @@
26122612
26132613 // Generate deletion reason
26142614 $hasHistory = false;
2615 - if( !$reason ) $reason = $this->generateReason($hasHistory);
 2615+ if ( !$reason ) $reason = $this->generateReason( $hasHistory );
26162616
26172617 // If the page has a history, insert a warning
2618 - if( $hasHistory && !$confirm ) {
 2618+ if ( $hasHistory && !$confirm ) {
26192619 global $wgLang;
26202620 $skin = $wgUser->getSkin();
26212621 $revisions = $this->estimateRevisionCount();
@@ -2623,7 +2623,7 @@
26242624 wfMsgHtml( 'word-separator' ) . $skin->historyLink() .
26252625 '</strong>'
26262626 );
2627 - if( $bigHistory ) {
 2627+ if ( $bigHistory ) {
26282628 global $wgDeleteRevisionsLimit;
26292629 $wgOut->wrapWikiMsg( "<div class='error'>\n$1</div>\n",
26302630 array( 'delete-warning-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
@@ -2638,7 +2638,7 @@
26392639 */
26402640 public function isBigDeletion() {
26412641 global $wgDeleteRevisionsLimit;
2642 - if( $wgDeleteRevisionsLimit ) {
 2642+ if ( $wgDeleteRevisionsLimit ) {
26432643 $revCount = $this->estimateRevisionCount();
26442644 return $revCount > $wgDeleteRevisionsLimit;
26452645 }
@@ -2651,7 +2651,7 @@
26522652 public function estimateRevisionCount() {
26532653 $dbr = wfGetDB( DB_SLAVE );
26542654 // For an exact count...
2655 - //return $dbr->selectField( 'revision', 'COUNT(*)',
 2655+ // return $dbr->selectField( 'revision', 'COUNT(*)',
26562656 // array( 'rev_page' => $this->getId() ), __METHOD__ );
26572657 return $dbr->estimateRowCount( 'revision', '*',
26582658 array( 'rev_page' => $this->getId() ), __METHOD__ );
@@ -2681,12 +2681,12 @@
26822682 'LIMIT' => $num
26832683 ) )
26842684 );
2685 - if( !$res ) {
 2685+ if ( !$res ) {
26862686 wfProfileOut( __METHOD__ );
26872687 return array();
26882688 }
26892689 $row = $db->fetchObject( $res );
2690 - if( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) {
 2690+ if ( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) {
26912691 $db = wfGetDB( DB_MASTER );
26922692 $continue--;
26932693 } else {
@@ -2724,7 +2724,7 @@
27252725
27262726 wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) );
27272727
2728 - if( $wgUser->isAllowed( 'suppressrevision' ) ) {
 2728+ if ( $wgUser->isAllowed( 'suppressrevision' ) ) {
27292729 $suppress = "<tr id=\"wpDeleteSuppressRow\" name=\"wpDeleteSuppressRow\">
27302730 <td></td>
27312731 <td class='mw-input'><strong>" .
@@ -2767,7 +2767,7 @@
27682768 "</td>
27692769 </tr>";
27702770 # Dissalow watching is user is not logged in
2771 - if( $wgUser->isLoggedIn() ) {
 2771+ if ( $wgUser->isLoggedIn() ) {
27722772 $form .= "
27732773 <tr>
27742774 <td></td>
@@ -2791,7 +2791,7 @@
27922792 Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
27932793 Xml::closeElement( 'form' );
27942794
2795 - if( $wgUser->isAllowed( 'editinterface' ) ) {
 2795+ if ( $wgUser->isAllowed( 'editinterface' ) ) {
27962796 $skin = $wgUser->getSkin();
27972797 $title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
27982798 $link = $skin->link(
@@ -2820,8 +2820,8 @@
28212821 $id = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
28222822
28232823 $error = '';
2824 - if( wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason, &$error)) ) {
2825 - if( $this->doDeleteArticle( $reason, $suppress, $id ) ) {
 2824+ if ( wfRunHooks( 'ArticleDelete', array( &$this, &$wgUser, &$reason, &$error ) ) ) {
 2825+ if ( $this->doDeleteArticle( $reason, $suppress, $id ) ) {
28262826 $deleted = $this->mTitle->getPrefixedText();
28272827
28282828 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
@@ -2831,10 +2831,10 @@
28322832
28332833 $wgOut->addWikiMsg( 'deletedtext', $deleted, $loglink );
28342834 $wgOut->returnToMain( false );
2835 - wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason, $id));
 2835+ wfRunHooks( 'ArticleDeleteComplete', array( &$this, &$wgUser, $reason, $id ) );
28362836 }
28372837 } else {
2838 - if( $error == '' ) {
 2838+ if ( $error == '' ) {
28392839 $wgOut->showFatalError(
28402840 Html::rawElement(
28412841 'div',
@@ -2863,22 +2863,22 @@
28642864 global $wgUseSquid, $wgDeferredUpdateList;
28652865 global $wgUseTrackbacks;
28662866
2867 - wfDebug( __METHOD__."\n" );
 2867+ wfDebug( __METHOD__ . "\n" );
28682868
28692869 $dbw = wfGetDB( DB_MASTER );
28702870 $ns = $this->mTitle->getNamespace();
28712871 $t = $this->mTitle->getDBkey();
28722872 $id = $id ? $id : $this->mTitle->getArticleID( GAID_FOR_UPDATE );
28732873
2874 - if( $t == '' || $id == 0 ) {
 2874+ if ( $t == '' || $id == 0 ) {
28752875 return false;
28762876 }
28772877
2878 - $u = new SiteStatsUpdate( 0, 1, -(int)$this->isCountable( $this->getRawText() ), -1 );
 2878+ $u = new SiteStatsUpdate( 0, 1, - (int)$this->isCountable( $this->getRawText() ), -1 );
28792879 array_push( $wgDeferredUpdateList, $u );
28802880
28812881 // Bitfields to further suppress the content
2882 - if( $suppress ) {
 2882+ if ( $suppress ) {
28832883 $bitfield = 0;
28842884 // This should be 15...
28852885 $bitfield |= Revision::DELETED_TEXT;
@@ -2926,9 +2926,9 @@
29272927 $dbw->delete( 'page_restrictions', array ( 'pr_page' => $id ), __METHOD__ );
29282928
29292929 # Now that it's safely backed up, delete it
2930 - $dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__);
 2930+ $dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__ );
29312931 $ok = ( $dbw->affectedRows() > 0 ); // getArticleId() uses slave, could be laggy
2932 - if( !$ok ) {
 2932+ if ( !$ok ) {
29332933 $dbw->rollback();
29342934 return false;
29352935 }
@@ -2936,16 +2936,16 @@
29372937 # Fix category table counts
29382938 $cats = array();
29392939 $res = $dbw->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__ );
2940 - foreach( $res as $row ) {
2941 - $cats []= $row->cl_to;
 2940+ foreach ( $res as $row ) {
 2941+ $cats [] = $row->cl_to;
29422942 }
29432943 $this->updateCategoryCounts( array(), $cats );
29442944
29452945 # If using cascading deletes, we can skip some explicit deletes
2946 - if( !$dbw->cascadingDeletes() ) {
 2946+ if ( !$dbw->cascadingDeletes() ) {
29472947 $dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ );
29482948
2949 - if($wgUseTrackbacks)
 2949+ if ( $wgUseTrackbacks )
29502950 $dbw->delete( 'trackbacks', array( 'tb_page' => $id ), __METHOD__ );
29512951
29522952 # Delete outgoing links
@@ -2959,15 +2959,15 @@
29602960 }
29612961
29622962 # If using cleanup triggers, we can skip some manual deletes
2963 - if( !$dbw->cleanupTriggers() ) {
 2963+ if ( !$dbw->cleanupTriggers() ) {
29642964 # Clean up recentchanges entries...
29652965 $dbw->delete( 'recentchanges',
2966 - array( 'rc_type != '.RC_LOG,
 2966+ array( 'rc_type != ' . RC_LOG,
29672967 'rc_namespace' => $this->mTitle->getNamespace(),
29682968 'rc_title' => $this->mTitle->getDBkey() ),
29692969 __METHOD__ );
29702970 $dbw->delete( 'recentchanges',
2971 - array( 'rc_type != '.RC_LOG, 'rc_cur_id' => $id ),
 2971+ array( 'rc_type != ' . RC_LOG, 'rc_cur_id' => $id ),
29722972 __METHOD__ );
29732973 }
29742974
@@ -3019,17 +3019,17 @@
30203020 $rollbackErrors = $this->mTitle->getUserPermissionsErrors( 'rollback', $wgUser );
30213021 $errors = array_merge( $editErrors, wfArrayDiff2( $rollbackErrors, $editErrors ) );
30223022
3023 - if( !$wgUser->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) )
 3023+ if ( !$wgUser->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) )
30243024 $errors[] = array( 'sessionfailure' );
30253025
3026 - if( $wgUser->pingLimiter( 'rollback' ) || $wgUser->pingLimiter() ) {
 3026+ if ( $wgUser->pingLimiter( 'rollback' ) || $wgUser->pingLimiter() ) {
30273027 $errors[] = array( 'actionthrottledtext' );
30283028 }
30293029 # If there were errors, bail out now
3030 - if( !empty( $errors ) )
 3030+ if ( !empty( $errors ) )
30313031 return $errors;
30323032
3033 - return $this->commitRollback($fromP, $summary, $bot, $resultDetails);
 3033+ return $this->commitRollback( $fromP, $summary, $bot, $resultDetails );
30343034 }
30353035
30363036 /**
@@ -3041,31 +3041,31 @@
30423042 * ly if you want to use custom permissions checks. If you don't, use
30433043 * doRollback() instead.
30443044 */
3045 - public function commitRollback($fromP, $summary, $bot, &$resultDetails) {
 3045+ public function commitRollback( $fromP, $summary, $bot, &$resultDetails ) {
30463046 global $wgUseRCPatrol, $wgUser, $wgLang;
30473047 $dbw = wfGetDB( DB_MASTER );
30483048
3049 - if( wfReadOnly() ) {
 3049+ if ( wfReadOnly() ) {
30503050 return array( array( 'readonlytext' ) );
30513051 }
30523052
30533053 # Get the last editor
30543054 $current = Revision::newFromTitle( $this->mTitle );
3055 - if( is_null( $current ) ) {
 3055+ if ( is_null( $current ) ) {
30563056 # Something wrong... no page?
3057 - return array(array('notanarticle'));
 3057+ return array( array( 'notanarticle' ) );
30583058 }
30593059
30603060 $from = str_replace( '_', ' ', $fromP );
30613061 # User name given should match up with the top revision.
30623062 # If the user was deleted then $from should be empty.
3063 - if( $from != $current->getUserText() ) {
 3063+ if ( $from != $current->getUserText() ) {
30643064 $resultDetails = array( 'current' => $current );
3065 - return array(array('alreadyrolled',
3066 - htmlspecialchars($this->mTitle->getPrefixedText()),
3067 - htmlspecialchars($fromP),
3068 - htmlspecialchars($current->getUserText())
3069 - ));
 3065+ return array( array( 'alreadyrolled',
 3066+ htmlspecialchars( $this->mTitle->getPrefixedText() ),
 3067+ htmlspecialchars( $fromP ),
 3068+ htmlspecialchars( $current->getUserText() )
 3069+ ) );
30703070 }
30713071
30723072 # Get the last edit not by this guy...
@@ -3080,25 +3080,25 @@
30813081 array( 'USE INDEX' => 'page_timestamp',
30823082 'ORDER BY' => 'rev_timestamp DESC' )
30833083 );
3084 - if( $s === false ) {
 3084+ if ( $s === false ) {
30853085 # No one else ever edited this page
3086 - return array(array('cantrollback'));
3087 - } else if( $s->rev_deleted & REVISION::DELETED_TEXT || $s->rev_deleted & REVISION::DELETED_USER ) {
 3086+ return array( array( 'cantrollback' ) );
 3087+ } else if ( $s->rev_deleted & REVISION::DELETED_TEXT || $s->rev_deleted & REVISION::DELETED_USER ) {
30883088 # Only admins can see this text
3089 - return array(array('notvisiblerev'));
 3089+ return array( array( 'notvisiblerev' ) );
30903090 }
30913091
30923092 $set = array();
3093 - if( $bot && $wgUser->isAllowed('markbotedits') ) {
 3093+ if ( $bot && $wgUser->isAllowed( 'markbotedits' ) ) {
30943094 # Mark all reverted edits as bot
30953095 $set['rc_bot'] = 1;
30963096 }
3097 - if( $wgUseRCPatrol ) {
 3097+ if ( $wgUseRCPatrol ) {
30983098 # Mark all reverted edits as patrolled
30993099 $set['rc_patrolled'] = 1;
31003100 }
31013101
3102 - if( count($set) ) {
 3102+ if ( count( $set ) ) {
31033103 $dbw->update( 'recentchanges', $set,
31043104 array( /* WHERE */
31053105 'rc_cur_id' => $current->getPage(),
@@ -3110,8 +3110,8 @@
31113111
31123112 # Generate the edit summary if necessary
31133113 $target = Revision::newFromId( $s->rev_id );
3114 - if( empty( $summary ) ) {
3115 - if( $from == '' ) { // no public user name
 3114+ if ( empty( $summary ) ) {
 3115+ if ( $from == '' ) { // no public user name
31163116 $summary = wfMsgForContent( 'revertpage-nouser' );
31173117 } else {
31183118 $summary = wfMsgForContent( 'revertpage' );
@@ -3121,22 +3121,22 @@
31223122 # Allow the custom summary to use the same args as the default message
31233123 $args = array(
31243124 $target->getUserText(), $from, $s->rev_id,
3125 - $wgLang->timeanddate(wfTimestamp(TS_MW, $s->rev_timestamp), true),
3126 - $current->getId(), $wgLang->timeanddate($current->getTimestamp())
 3125+ $wgLang->timeanddate( wfTimestamp( TS_MW, $s->rev_timestamp ), true ),
 3126+ $current->getId(), $wgLang->timeanddate( $current->getTimestamp() )
31273127 );
31283128 $summary = wfMsgReplaceArgs( $summary, $args );
31293129
31303130 # Save
31313131 $flags = EDIT_UPDATE;
31323132
3133 - if( $wgUser->isAllowed('minoredit') )
 3133+ if ( $wgUser->isAllowed( 'minoredit' ) )
31343134 $flags |= EDIT_MINOR;
31353135
3136 - if( $bot && ($wgUser->isAllowed('markbotedits') || $wgUser->isAllowed('bot')) )
 3136+ if ( $bot && ( $wgUser->isAllowed( 'markbotedits' ) || $wgUser->isAllowed( 'bot' ) ) )
31373137 $flags |= EDIT_FORCE_BOT;
31383138 # Actually store the edit
31393139 $status = $this->doEdit( $target->getText(), $summary, $flags, $target->getId() );
3140 - if( !empty( $status->value['revision'] ) ) {
 3140+ if ( !empty( $status->value['revision'] ) ) {
31413141 $revId = $status->value['revision']->getId();
31423142 } else {
31433143 $revId = false;
@@ -3168,18 +3168,18 @@
31693169 $details
31703170 );
31713171
3172 - if( in_array( array( 'actionthrottledtext' ), $result ) ) {
 3172+ if ( in_array( array( 'actionthrottledtext' ), $result ) ) {
31733173 $wgOut->rateLimited();
31743174 return;
31753175 }
3176 - if( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) {
 3176+ if ( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) {
31773177 $wgOut->setPageTitle( wfMsg( 'rollbackfailed' ) );
31783178 $errArray = $result[0];
31793179 $errMsg = array_shift( $errArray );
31803180 $wgOut->addWikiMsgArray( $errMsg, $errArray );
3181 - if( isset( $details['current'] ) ){
 3181+ if ( isset( $details['current'] ) ) {
31823182 $current = $details['current'];
3183 - if( $current->getComment() != '' ) {
 3183+ if ( $current->getComment() != '' ) {
31843184 $wgOut->addWikiMsgArray( 'editcomment', array(
31853185 $wgUser->getSkin()->formatComment( $current->getComment() ) ), array( 'replaceafter' ) );
31863186 }
@@ -3189,19 +3189,19 @@
31903190 # Display permissions errors before read-only message -- there's no
31913191 # point in misleading the user into thinking the inability to rollback
31923192 # is only temporary.
3193 - if( !empty( $result ) && $result !== array( array( 'readonlytext' ) ) ) {
 3193+ if ( !empty( $result ) && $result !== array( array( 'readonlytext' ) ) ) {
31943194 # array_diff is completely broken for arrays of arrays, sigh. Re-
31953195 # move any 'readonlytext' error manually.
31963196 $out = array();
3197 - foreach( $result as $error ) {
3198 - if( $error != array( 'readonlytext' ) ) {
3199 - $out []= $error;
 3197+ foreach ( $result as $error ) {
 3198+ if ( $error != array( 'readonlytext' ) ) {
 3199+ $out [] = $error;
32003200 }
32013201 }
32023202 $wgOut->showPermissionsErrorPage( $out );
32033203 return;
32043204 }
3205 - if( $result == array( array( 'readonlytext' ) ) ) {
 3205+ if ( $result == array( array( 'readonlytext' ) ) ) {
32063206 $wgOut->readOnlyPage();
32073207 return;
32083208 }
@@ -3222,7 +3222,7 @@
32233223 $wgOut->addHTML( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
32243224 $wgOut->returnToMain( false, $this->mTitle );
32253225
3226 - if( !$wgRequest->getBool( 'hidediff', false ) && !$wgUser->getBoolOption( 'norollbackdiff', false ) ) {
 3226+ if ( !$wgRequest->getBool( 'hidediff', false ) && !$wgUser->getBoolOption( 'norollbackdiff', false ) ) {
32273227 $de = new DifferenceEngine( $this->mTitle, $current->getId(), $newId, false, true );
32283228 $de->showDiff( '', '' );
32293229 }
@@ -3238,7 +3238,7 @@
32393239 return;
32403240 }
32413241 # Don't update page view counters on views from bot users (bug 14044)
3242 - if( !$wgDisableCounters && !$wgUser->isAllowed('bot') && $this->getID() ) {
 3242+ if ( !$wgDisableCounters && !$wgUser->isAllowed( 'bot' ) && $this->getID() ) {
32433243 Article::incViewCount( $this->getID() );
32443244 $u = new SiteStatsUpdate( 1, 0, 0 );
32453245 array_push( $wgDeferredUpdateList, $u );
@@ -3251,8 +3251,8 @@
32523252 * Prepare text which is about to be saved.
32533253 * Returns a stdclass with source, pst and output members
32543254 */
3255 - public function prepareTextForEdit( $text, $revid=null ) {
3256 - if( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid) {
 3255+ public function prepareTextForEdit( $text, $revid = null ) {
 3256+ if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid ) {
32573257 // Already prepared
32583258 return $this->mPreparedEdit;
32593259 }
@@ -3289,7 +3289,7 @@
32903290
32913291 # Parse the text
32923292 # Be careful not to double-PST: $text is usually already PST-ed once
3293 - if( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) {
 3293+ if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) {
32943294 wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" );
32953295 $editInfo = $this->prepareTextForEdit( $text, $newid );
32963296 } else {
@@ -3298,7 +3298,7 @@
32993299 }
33003300
33013301 # Save it to the parser cache
3302 - if( $wgEnableParserCache ) {
 3302+ if ( $wgEnableParserCache ) {
33033303 $popts = $this->getParserOptions();
33043304 $parserCache = ParserCache::singleton();
33053305 $parserCache->save( $editInfo->output, $this, $popts );
@@ -3310,8 +3310,8 @@
33113311
33123312 wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $changed ) );
33133313
3314 - if( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) {
3315 - if( 0 == mt_rand( 0, 99 ) ) {
 3314+ if ( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) {
 3315+ if ( 0 == mt_rand( 0, 99 ) ) {
33163316 // Flush old entries from the `recentchanges` table; we do this on
33173317 // random requests so as to avoid an increase in writes for no good reason
33183318 global $wgRCMaxAge;
@@ -3327,7 +3327,7 @@
33283328 $title = $this->mTitle->getPrefixedDBkey();
33293329 $shortTitle = $this->mTitle->getDBkey();
33303330
3331 - if( 0 == $id ) {
 3331+ if ( 0 == $id ) {
33323332 wfProfileOut( __METHOD__ );
33333333 return;
33343334 }
@@ -3341,24 +3341,24 @@
33423342 # Don't do this if $changed = false otherwise some idiot can null-edit a
33433343 # load of user talk pages and piss people off, nor if it's a minor edit
33443344 # by a properly-flagged bot.
3345 - if( $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getTitleKey() && $changed
 3345+ if ( $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getTitleKey() && $changed
33463346 && !( $minoredit && $wgUser->isAllowed( 'nominornewtalk' ) ) ) {
3347 - if( wfRunHooks('ArticleEditUpdateNewTalk', array( &$this ) ) ) {
 3347+ if ( wfRunHooks( 'ArticleEditUpdateNewTalk', array( &$this ) ) ) {
33483348 $other = User::newFromName( $shortTitle, false );
3349 - if( !$other ) {
3350 - wfDebug( __METHOD__.": invalid username\n" );
3351 - } elseif( User::isIP( $shortTitle ) ) {
 3349+ if ( !$other ) {
 3350+ wfDebug( __METHOD__ . ": invalid username\n" );
 3351+ } elseif ( User::isIP( $shortTitle ) ) {
33523352 // An anonymous user
33533353 $other->setNewtalk( true );
3354 - } elseif( $other->isLoggedIn() ) {
 3354+ } elseif ( $other->isLoggedIn() ) {
33553355 $other->setNewtalk( true );
33563356 } else {
3357 - wfDebug( __METHOD__. ": don't need to notify a nonexistent user\n" );
 3357+ wfDebug( __METHOD__ . ": don't need to notify a nonexistent user\n" );
33583358 }
33593359 }
33603360 }
33613361
3362 - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 3362+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
33633363 $wgMessageCache->replace( $shortTitle, $text );
33643364 }
33653365
@@ -3392,15 +3392,15 @@
33933393 public function setOldSubtitle( $oldid = 0 ) {
33943394 global $wgLang, $wgOut, $wgUser, $wgRequest;
33953395
3396 - if( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
 3396+ if ( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
33973397 return;
33983398 }
33993399
3400 - $unhide = $wgRequest->getInt('unhide') == 1 &&
3401 - $wgUser->matchEditToken( $wgRequest->getVal('token'), $oldid );
 3400+ $unhide = $wgRequest->getInt( 'unhide' ) == 1 &&
 3401+ $wgUser->matchEditToken( $wgRequest->getVal( 'token' ), $oldid );
34023402 # Cascade unhide param in links for easy deletion browsing
34033403 $extraParams = array();
3404 - if( $wgRequest->getVal('unhide') ) {
 3404+ if ( $wgRequest->getVal( 'unhide' ) ) {
34053405 $extraParams['unhide'] = 1;
34063406 }
34073407 $revision = Revision::newFromId( $oldid );
@@ -3484,8 +3484,8 @@
34853485 $cdel = '';
34863486 // User can delete revisions or view deleted revisions...
34873487 $canHide = $wgUser->isAllowed( 'deleterevision' );
3488 - if( $canHide || ($revision->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) {
3489 - if( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) {
 3488+ if ( $canHide || ( $revision->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) ) {
 3489+ if ( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) {
34903490 $cdel = $sk->revDeleteLinkDisabled( $canHide ); // rev was hidden from Sysops
34913491 } else {
34923492 $query = array(
@@ -3493,7 +3493,7 @@
34943494 'target' => $this->mTitle->getPrefixedDbkey(),
34953495 'ids' => $oldid
34963496 );
3497 - $cdel = $sk->revDeleteLink( $query, $revision->isDeleted(File::DELETED_RESTRICTED), $canHide );
 3497+ $cdel = $sk->revDeleteLink( $query, $revision->isDeleted( File::DELETED_RESTRICTED ), $canHide );
34983498 }
34993499 $cdel .= ' ';
35003500 }
@@ -3543,20 +3543,20 @@
35443544 */
35453545 protected function tryFileCache() {
35463546 static $called = false;
3547 - if( $called ) {
 3547+ if ( $called ) {
35483548 wfDebug( "Article::tryFileCache(): called twice!?\n" );
35493549 return false;
35503550 }
35513551 $called = true;
3552 - if( $this->isFileCacheable() ) {
 3552+ if ( $this->isFileCacheable() ) {
35533553 $cache = new HTMLFileCache( $this->mTitle );
3554 - if( $cache->isFileCacheGood( $this->mTouched ) ) {
 3554+ if ( $cache->isFileCacheGood( $this->mTouched ) ) {
35553555 wfDebug( "Article::tryFileCache(): about to load file\n" );
35563556 $cache->loadFromFileCache();
35573557 return true;
35583558 } else {
35593559 wfDebug( "Article::tryFileCache(): starting buffer\n" );
3560 - ob_start( array(&$cache, 'saveToFileCache' ) );
 3560+ ob_start( array( &$cache, 'saveToFileCache' ) );
35613561 }
35623562 } else {
35633563 wfDebug( "Article::tryFileCache(): not cacheable\n" );
@@ -3570,10 +3570,10 @@
35713571 */
35723572 public function isFileCacheable() {
35733573 $cacheable = false;
3574 - if( HTMLFileCache::useFileCache() ) {
 3574+ if ( HTMLFileCache::useFileCache() ) {
35753575 $cacheable = $this->getID() && !$this->mRedirectedFrom;
35763576 // Extension may have reason to disable file caching on some pages.
3577 - if( $cacheable ) {
 3577+ if ( $cacheable ) {
35783578 $cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) );
35793579 }
35803580 }
@@ -3585,7 +3585,7 @@
35863586 *
35873587 */
35883588 public function checkTouched() {
3589 - if( !$this->mDataLoaded ) {
 3589+ if ( !$this->mDataLoaded ) {
35903590 $this->loadPageData();
35913591 }
35923592 return !$this->mIsRedirect;
@@ -3596,7 +3596,7 @@
35973597 */
35983598 public function getTouched() {
35993599 # Ensure that page data has been loaded
3600 - if( !$this->mDataLoaded ) {
 3600+ if ( !$this->mDataLoaded ) {
36013601 $this->loadPageData();
36023602 }
36033603 return $this->mTouched;
@@ -3606,7 +3606,7 @@
36073607 * Get the page_latest field
36083608 */
36093609 public function getLatest() {
3610 - if( !$this->mDataLoaded ) {
 3610+ if ( !$this->mDataLoaded ) {
36113611 $this->loadPageData();
36123612 }
36133613 return (int)$this->mLatest;
@@ -3634,7 +3634,7 @@
36353635 $revision->insertOn( $dbw );
36363636 $this->updateRevisionOn( $dbw, $revision );
36373637
3638 - wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false, $wgUser) );
 3638+ wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, false, $wgUser ) );
36393639
36403640 wfProfileOut( __METHOD__ );
36413641 }
@@ -3653,7 +3653,7 @@
36543654 $hitcounterTable = $dbw->tableName( 'hitcounter' );
36553655 $acchitsTable = $dbw->tableName( 'acchits' );
36563656
3657 - if( $wgHitcounterUpdateFreq <= 1 ) {
 3657+ if ( $wgHitcounterUpdateFreq <= 1 ) {
36583658 $dbw->query( "UPDATE $pageTable SET page_counter = page_counter + 1 WHERE page_id = $id" );
36593659 return;
36603660 }
@@ -3663,34 +3663,34 @@
36643664
36653665 $dbw->query( "INSERT INTO $hitcounterTable (hc_id) VALUES ({$id})" );
36663666
3667 - $checkfreq = intval( $wgHitcounterUpdateFreq/25 + 1 );
3668 - if( (rand() % $checkfreq != 0) or ($dbw->lastErrno() != 0) ){
 3667+ $checkfreq = intval( $wgHitcounterUpdateFreq / 25 + 1 );
 3668+ if ( ( rand() % $checkfreq != 0 ) or ( $dbw->lastErrno() != 0 ) ) {
36693669 # Most of the time (or on SQL errors), skip row count check
36703670 $dbw->ignoreErrors( $oldignore );
36713671 return;
36723672 }
36733673
3674 - $res = $dbw->query("SELECT COUNT(*) as n FROM $hitcounterTable");
 3674+ $res = $dbw->query( "SELECT COUNT(*) as n FROM $hitcounterTable" );
36753675 $row = $dbw->fetchObject( $res );
36763676 $rown = intval( $row->n );
3677 - if( $rown >= $wgHitcounterUpdateFreq ){
 3677+ if ( $rown >= $wgHitcounterUpdateFreq ) {
36783678 wfProfileIn( 'Article::incViewCount-collect' );
36793679 $old_user_abort = ignore_user_abort( true );
36803680
36813681 $dbType = $dbw->getType();
36823682 $dbw->lockTables( array(), array( 'hitcounter' ), __METHOD__, false );
36833683 $tabletype = $dbType == 'mysql' ? "ENGINE=HEAP " : '';
3684 - $dbw->query( "CREATE TEMPORARY TABLE $acchitsTable $tabletype AS ".
3685 - "SELECT hc_id,COUNT(*) AS hc_n FROM $hitcounterTable ".
 3684+ $dbw->query( "CREATE TEMPORARY TABLE $acchitsTable $tabletype AS " .
 3685+ "SELECT hc_id,COUNT(*) AS hc_n FROM $hitcounterTable " .
36863686 'GROUP BY hc_id', __METHOD__ );
36873687 $dbw->delete( 'hitcounter', '*', __METHOD__ );
36883688 $dbw->unlockTables( __METHOD__ );
3689 - if( $dbType == 'mysql' ) {
3690 - $dbw->query( "UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n ".
 3689+ if ( $dbType == 'mysql' ) {
 3690+ $dbw->query( "UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n " .
36913691 'WHERE page_id = hc_id', __METHOD__ );
36923692 }
36933693 else {
3694 - $dbw->query( "UPDATE $pageTable SET page_counter=page_counter + hc_n ".
 3694+ $dbw->query( "UPDATE $pageTable SET page_counter=page_counter + hc_n " .
36953695 "FROM $acchitsTable WHERE page_id = hc_id", __METHOD__ );
36963696 }
36973697 $dbw->query( "DROP TABLE $acchitsTable", __METHOD__ );
@@ -3714,7 +3714,7 @@
37153715 */
37163716 public static function onArticleCreate( $title ) {
37173717 # Update existence markers on article/talk tabs...
3718 - if( $title->isTalkPage() ) {
 3718+ if ( $title->isTalkPage() ) {
37193719 $other = $title->getSubjectPage();
37203720 } else {
37213721 $other = $title->getTalkPage();
@@ -3730,7 +3730,7 @@
37313731 public static function onArticleDelete( $title ) {
37323732 global $wgMessageCache;
37333733 # Update existence markers on article/talk tabs...
3734 - if( $title->isTalkPage() ) {
 3734+ if ( $title->isTalkPage() ) {
37353735 $other = $title->getSubjectPage();
37363736 } else {
37373737 $other = $title->getTalkPage();
@@ -3745,16 +3745,16 @@
37463746 HTMLFileCache::clearFileCache( $title );
37473747
37483748 # Messages
3749 - if( $title->getNamespace() == NS_MEDIAWIKI ) {
 3749+ if ( $title->getNamespace() == NS_MEDIAWIKI ) {
37503750 $wgMessageCache->replace( $title->getDBkey(), false );
37513751 }
37523752 # Images
3753 - if( $title->getNamespace() == NS_FILE ) {
 3753+ if ( $title->getNamespace() == NS_FILE ) {
37543754 $update = new HTMLCacheUpdate( $title, 'imagelinks' );
37553755 $update->doUpdate();
37563756 }
37573757 # User talk pages
3758 - if( $title->getNamespace() == NS_USER_TALK ) {
 3758+ if ( $title->getNamespace() == NS_USER_TALK ) {
37593759 $user = User::newFromName( $title->getText(), false );
37603760 $user->setNewtalk( false );
37613761 }
@@ -3799,7 +3799,7 @@
38003800 public function info() {
38013801 global $wgLang, $wgOut, $wgAllowPageInfo, $wgUser;
38023802
3803 - if( !$wgAllowPageInfo ) {
 3803+ if ( !$wgAllowPageInfo ) {
38043804 $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
38053805 return;
38063806 }
@@ -3810,9 +3810,9 @@
38113811 $wgOut->setPageTitleActionText( wfMsg( 'info_short' ) );
38123812 $wgOut->setSubtitle( wfMsgHtml( 'infosubtitle' ) );
38133813
3814 - if( !$this->mTitle->exists() ) {
 3814+ if ( !$this->mTitle->exists() ) {
38153815 $wgOut->addHTML( '<div class="noarticletext">' );
3816 - if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 3816+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
38173817 // This doesn't quite make sense; the user is asking for
38183818 // information about the _page_, not the message... -- RC
38193819 $wgOut->addHTML( htmlspecialchars( wfMsgWeirdKey( $this->mTitle->getText() ) ) );
@@ -3838,14 +3838,14 @@
38393839 $pageInfo = $this->pageCountInfo( $page );
38403840 $talkInfo = $this->pageCountInfo( $page->getTalkPage() );
38413841
3842 - $wgOut->addHTML( "<ul><li>" . wfMsg("numwatchers", $wgLang->formatNum( $numwatchers ) ) . '</li>' );
3843 - $wgOut->addHTML( "<li>" . wfMsg('numedits', $wgLang->formatNum( $pageInfo['edits'] ) ) . '</li>');
3844 - if( $talkInfo ) {
3845 - $wgOut->addHTML( '<li>' . wfMsg("numtalkedits", $wgLang->formatNum( $talkInfo['edits'] ) ) . '</li>');
 3842+ $wgOut->addHTML( "<ul><li>" . wfMsg( "numwatchers", $wgLang->formatNum( $numwatchers ) ) . '</li>' );
 3843+ $wgOut->addHTML( "<li>" . wfMsg( 'numedits', $wgLang->formatNum( $pageInfo['edits'] ) ) . '</li>' );
 3844+ if ( $talkInfo ) {
 3845+ $wgOut->addHTML( '<li>' . wfMsg( "numtalkedits", $wgLang->formatNum( $talkInfo['edits'] ) ) . '</li>' );
38463846 }
3847 - $wgOut->addHTML( '<li>' . wfMsg("numauthors", $wgLang->formatNum( $pageInfo['authors'] ) ) . '</li>' );
3848 - if( $talkInfo ) {
3849 - $wgOut->addHTML( '<li>' . wfMsg('numtalkauthors', $wgLang->formatNum( $talkInfo['authors'] ) ) . '</li>' );
 3847+ $wgOut->addHTML( '<li>' . wfMsg( "numauthors", $wgLang->formatNum( $pageInfo['authors'] ) ) . '</li>' );
 3848+ if ( $talkInfo ) {
 3849+ $wgOut->addHTML( '<li>' . wfMsg( 'numtalkauthors', $wgLang->formatNum( $talkInfo['authors'] ) ) . '</li>' );
38503850 }
38513851 $wgOut->addHTML( '</ul>' );
38523852 }
@@ -3860,7 +3860,7 @@
38613861 */
38623862 public function pageCountInfo( $title ) {
38633863 $id = $title->getArticleId();
3864 - if( $id == 0 ) {
 3864+ if ( $id == 0 ) {
38653865 return false;
38663866 }
38673867 $dbr = wfGetDB( DB_SLAVE );
@@ -3891,7 +3891,7 @@
38923892 public function getUsedTemplates() {
38933893 $result = array();
38943894 $id = $this->mTitle->getArticleID();
3895 - if( $id == 0 ) {
 3895+ if ( $id == 0 ) {
38963896 return array();
38973897 }
38983898 $dbr = wfGetDB( DB_SLAVE );
@@ -3899,8 +3899,8 @@
39003900 array( 'tl_namespace', 'tl_title' ),
39013901 array( 'tl_from' => $id ),
39023902 __METHOD__ );
3903 - if( $res !== false ) {
3904 - foreach( $res as $row ) {
 3903+ if ( $res !== false ) {
 3904+ foreach ( $res as $row ) {
39053905 $result[] = Title::makeTitle( $row->tl_namespace, $row->tl_title );
39063906 }
39073907 }
@@ -3917,17 +3917,17 @@
39183918 public function getHiddenCategories() {
39193919 $result = array();
39203920 $id = $this->mTitle->getArticleID();
3921 - if( $id == 0 ) {
 3921+ if ( $id == 0 ) {
39223922 return array();
39233923 }
39243924 $dbr = wfGetDB( DB_SLAVE );
39253925 $res = $dbr->select( array( 'categorylinks', 'page_props', 'page' ),
39263926 array( 'cl_to' ),
39273927 array( 'cl_from' => $id, 'pp_page=page_id', 'pp_propname' => 'hiddencat',
3928 - 'page_namespace' => NS_CATEGORY, 'page_title=cl_to'),
 3928+ 'page_namespace' => NS_CATEGORY, 'page_title=cl_to' ),
39293929 __METHOD__ );
3930 - if( $res !== false ) {
3931 - foreach( $res as $row ) {
 3930+ if ( $res !== false ) {
 3931+ foreach ( $res as $row ) {
39323932 $result[] = Title::makeTitle( NS_CATEGORY, $row->cl_to );
39333933 }
39343934 }
@@ -3948,24 +3948,24 @@
39493949 # Redirect autosummaries
39503950 $ot = Title::newFromRedirect( $oldtext );
39513951 $rt = Title::newFromRedirect( $newtext );
3952 - if( is_object( $rt ) && ( !is_object( $ot ) || !$rt->equals( $ot ) || $ot->getFragment() != $rt->getFragment() ) ) {
 3952+ if ( is_object( $rt ) && ( !is_object( $ot ) || !$rt->equals( $ot ) || $ot->getFragment() != $rt->getFragment() ) ) {
39533953 return wfMsgForContent( 'autoredircomment', $rt->getFullText() );
39543954 }
39553955
39563956 # New page autosummaries
3957 - if( $flags & EDIT_NEW && strlen( $newtext ) ) {
 3957+ if ( $flags & EDIT_NEW && strlen( $newtext ) ) {
39583958 # If they're making a new article, give its text, truncated, in the summary.
39593959 global $wgContLang;
39603960 $truncatedtext = $wgContLang->truncate(
3961 - str_replace("\n", ' ', $newtext),
 3961+ str_replace( "\n", ' ', $newtext ),
39623962 max( 0, 200 - strlen( wfMsgForContent( 'autosumm-new' ) ) ) );
39633963 return wfMsgForContent( 'autosumm-new', $truncatedtext );
39643964 }
39653965
39663966 # Blanking autosummaries
3967 - if( $oldtext != '' && $newtext == '' ) {
 3967+ if ( $oldtext != '' && $newtext == '' ) {
39683968 return wfMsgForContent( 'autosumm-blank' );
3969 - } elseif( strlen( $oldtext ) > 10 * strlen( $newtext ) && strlen( $newtext ) < 500) {
 3969+ } elseif ( strlen( $oldtext ) > 10 * strlen( $newtext ) && strlen( $newtext ) < 500 ) {
39703970 # Removing more than 90% of the article
39713971 global $wgContLang;
39723972 $truncatedtext = $wgContLang->truncate(
@@ -4006,25 +4006,25 @@
40074007 $parserOptions = $this->getParserOptions();
40084008 }
40094009
4010 - $time = -wfTime();
 4010+ $time = - wfTime();
40114011 $this->mParserOutput = $wgParser->parse( $text, $this->mTitle,
40124012 $parserOptions, true, true, $this->getRevIdFetched() );
40134013 $time += wfTime();
40144014
40154015 # Timing hack
4016 - if( $time > 3 ) {
 4016+ if ( $time > 3 ) {
40174017 wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time,
4018 - $this->mTitle->getPrefixedDBkey()));
 4018+ $this->mTitle->getPrefixedDBkey() ) );
40194019 }
40204020
4021 - if( $wgEnableParserCache && $cache && $this && $this->mParserOutput->getCacheTime() != -1 ) {
 4021+ if ( $wgEnableParserCache && $cache && $this && $this->mParserOutput->getCacheTime() != -1 ) {
40224022 $parserCache = ParserCache::singleton();
40234023 $parserCache->save( $this->mParserOutput, $this, $parserOptions );
40244024 }
40254025 // Make sure file cache is not used on uncacheable content.
40264026 // Output that has magic words in it can still use the parser cache
40274027 // (if enabled), though it will generally expire sooner.
4028 - if( $this->mParserOutput->getCacheTime() == -1 || $this->mParserOutput->containsOldMagic() ) {
 4028+ if ( $this->mParserOutput->getCacheTime() == -1 || $this->mParserOutput->containsOldMagic() ) {
40294029 $wgUseFileCache = false;
40304030 }
40314031 $this->doCascadeProtectionUpdates( $this->mParserOutput );
@@ -4045,7 +4045,7 @@
40464046 }
40474047
40484048 protected function doCascadeProtectionUpdates( $parserOutput ) {
4049 - if( !$this->isCurrent() || wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
 4049+ if ( !$this->isCurrent() || wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
40504050 return;
40514051 }
40524052
@@ -4068,7 +4068,7 @@
40694069 __METHOD__ );
40704070
40714071 global $wgContLang;
4072 - foreach( $res as $row ) {
 4072+ foreach ( $res as $row ) {
40734073 $tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true;
40744074 }
40754075
@@ -4084,7 +4084,7 @@
40854085 # Note that we simulate array_diff_key in PHP <5.0.x
40864086 $templates_diff = array_diff_key( $poTemplates, $tlTemplates );
40874087
4088 - if( count( $templates_diff ) > 0 ) {
 4088+ if ( count( $templates_diff ) > 0 ) {
40894089 # Whee, link updates time.
40904090 $u = new LinksUpdate( $this->mTitle, $parserOutput, false );
40914091 $u->doUpdate();
@@ -4110,12 +4110,12 @@
41114111 #
41124112 # Sometimes I wish we had INSERT ... ON DUPLICATE KEY UPDATE.
41134113 $insertCats = array_merge( $added, $deleted );
4114 - if( !$insertCats ) {
 4114+ if ( !$insertCats ) {
41154115 # Okay, nothing to do
41164116 return;
41174117 }
41184118 $insertRows = array();
4119 - foreach( $insertCats as $cat ) {
 4119+ foreach ( $insertCats as $cat ) {
41204120 $insertRows[] = array(
41214121 'cat_id' => $dbw->nextSequenceValue( 'category_cat_id_seq' ),
41224122 'cat_title' => $cat
@@ -4125,15 +4125,15 @@
41264126
41274127 $addFields = array( 'cat_pages = cat_pages + 1' );
41284128 $removeFields = array( 'cat_pages = cat_pages - 1' );
4129 - if( $ns == NS_CATEGORY ) {
 4129+ if ( $ns == NS_CATEGORY ) {
41304130 $addFields[] = 'cat_subcats = cat_subcats + 1';
41314131 $removeFields[] = 'cat_subcats = cat_subcats - 1';
4132 - } elseif( $ns == NS_FILE ) {
 4132+ } elseif ( $ns == NS_FILE ) {
41334133 $addFields[] = 'cat_files = cat_files + 1';
41344134 $removeFields[] = 'cat_files = cat_files - 1';
41354135 }
41364136
4137 - if( $added ) {
 4137+ if ( $added ) {
41384138 $dbw->update(
41394139 'category',
41404140 $addFields,
@@ -4141,7 +4141,7 @@
41424142 __METHOD__
41434143 );
41444144 }
4145 - if( $deleted ) {
 4145+ if ( $deleted ) {
41464146 $dbw->update(
41474147 'category',
41484148 $removeFields,
@@ -4164,7 +4164,7 @@
41654165 $this->exists() &&
41664166 $oldid === null;
41674167
4168 - wfDebug( __METHOD__.': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
 4168+ wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
41694169 if ( $wgUser->getOption( 'stubthreshold' ) ) {
41704170 wfIncrStats( 'pcache_miss_stub' );
41714171 }
Index: trunk/phase3/includes/AjaxDispatcher.php
@@ -7,7 +7,7 @@
88 * Handle ajax requests and send them to the proper handler.
99 */
1010
11 -if( !(defined( 'MEDIAWIKI' ) && $wgUseAjax ) ) {
 11+if ( !( defined( 'MEDIAWIKI' ) && $wgUseAjax ) ) {
1212 die( 1 );
1313 }
1414
@@ -33,11 +33,11 @@
3434
3535 $this->mode = "";
3636
37 - if (! empty($_GET["rs"])) {
 37+ if ( ! empty( $_GET["rs"] ) ) {
3838 $this->mode = "get";
3939 }
4040
41 - if (!empty($_POST["rs"])) {
 41+ if ( !empty( $_POST["rs"] ) ) {
4242 $this->mode = "post";
4343 }
4444
@@ -45,7 +45,7 @@
4646
4747 case 'get':
4848 $this->func_name = isset( $_GET["rs"] ) ? $_GET["rs"] : '';
49 - if (! empty($_GET["rsargs"])) {
 49+ if ( ! empty( $_GET["rsargs"] ) ) {
5050 $this->args = $_GET["rsargs"];
5151 } else {
5252 $this->args = array();
@@ -54,7 +54,7 @@
5555
5656 case 'post':
5757 $this->func_name = isset( $_POST["rs"] ) ? $_POST["rs"] : '';
58 - if (! empty($_POST["rsargs"])) {
 58+ if ( ! empty( $_POST["rsargs"] ) ) {
5959 $this->args = $_POST["rsargs"];
6060 } else {
6161 $this->args = array();
@@ -65,7 +65,7 @@
6666 wfProfileOut( __METHOD__ );
6767 return;
6868 # Or we could throw an exception:
69 - #throw new MWException( __METHOD__ . ' called without any data (mode empty).' );
 69+ # throw new MWException( __METHOD__ . ' called without any data (mode empty).' );
7070
7171 }
7272
@@ -83,9 +83,10 @@
8484 if ( empty( $this->mode ) ) {
8585 return;
8686 }
 87+
8788 wfProfileIn( __METHOD__ );
8889
89 - if (! in_array( $this->func_name, $wgAjaxExportList ) ) {
 90+ if ( ! in_array( $this->func_name, $wgAjaxExportList ) ) {
9091 wfDebug( __METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n" );
9192
9293 wfHttpError( 400, 'Bad Request',
@@ -99,11 +100,11 @@
100101 $func = $this->func_name;
101102 }
102103 try {
103 - $result = call_user_func_array($func, $this->args);
 104+ $result = call_user_func_array( $func, $this->args );
104105
105106 if ( $result === false || $result === null ) {
106 - wfDebug( __METHOD__ . ' ERROR while dispatching '
107 - . $this->func_name . "(" . var_export( $this->args, true ) . "): "
 107+ wfDebug( __METHOD__ . ' ERROR while dispatching '
 108+ . $this->func_name . "(" . var_export( $this->args, true ) . "): "
108109 . "no data returned\n" );
109110
110111 wfHttpError( 500, 'Internal Error',
@@ -111,7 +112,7 @@
112113 }
113114 else {
114115 if ( is_string( $result ) ) {
115 - $result= new AjaxResponse( $result );
 116+ $result = new AjaxResponse( $result );
116117 }
117118
118119 $result->sendHeaders();
@@ -120,12 +121,12 @@
121122 wfDebug( __METHOD__ . ' dispatch complete for ' . $this->func_name . "\n" );
122123 }
123124
124 - } catch (Exception $e) {
125 - wfDebug( __METHOD__ . ' ERROR while dispatching '
126 - . $this->func_name . "(" . var_export( $this->args, true ) . "): "
127 - . get_class($e) . ": " . $e->getMessage() . "\n" );
 125+ } catch ( Exception $e ) {
 126+ wfDebug( __METHOD__ . ' ERROR while dispatching '
 127+ . $this->func_name . "(" . var_export( $this->args, true ) . "): "
 128+ . get_class( $e ) . ": " . $e->getMessage() . "\n" );
128129
129 - if (!headers_sent()) {
 130+ if ( !headers_sent() ) {
130131 wfHttpError( 500, 'Internal Error',
131132 $e->getMessage() );
132133 } else {
Index: trunk/phase3/includes/CacheDependency.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /**
54 * This class stores an arbitrary value along with its dependencies.
65 * Users should typically only use DependencyWrapper::getFromCache(), rather
@@ -108,7 +107,7 @@
109108 /**
110109 * Hook to perform any expensive pre-serialize loading of dependency values.
111110 */
112 - function loadDependencyValues() {}
 111+ function loadDependencyValues() { }
113112 }
114113
115114 /**
@@ -213,6 +212,7 @@
214213
215214 function isExpired() {
216215 $touched = $this->getTitle()->getTouched();
 216+
217217 if ( $this->touched === false ) {
218218 if ( $touched === false ) {
219219 # Still missing
@@ -251,6 +251,7 @@
252252 function calculateTimestamps() {
253253 # Initialise values to false
254254 $timestamps = array();
 255+
255256 foreach ( $this->getLinkBatch()->data as $ns => $dbks ) {
256257 if ( count( $dbks ) > 0 ) {
257258 $timestamps[$ns] = array();
@@ -264,9 +265,13 @@
265266 if ( count( $timestamps ) ) {
266267 $dbr = wfGetDB( DB_SLAVE );
267268 $where = $this->getLinkBatch()->constructSet( 'page', $dbr );
268 - $res = $dbr->select( 'page',
 269+ $res = $dbr->select(
 270+ 'page',
269271 array( 'page_namespace', 'page_title', 'page_touched' ),
270 - $where, __METHOD__ );
 272+ $where,
 273+ __METHOD__
 274+ );
 275+
271276 while ( $row = $dbr->fetchObject( $res ) ) {
272277 $timestamps[$row->page_namespace][$row->page_title] = $row->page_touched;
273278 }
@@ -283,7 +288,7 @@
284289 }
285290
286291 function getLinkBatch() {
287 - if ( !isset( $this->linkBatch ) ){
 292+ if ( !isset( $this->linkBatch ) ) {
288293 $this->linkBatch = new LinkBatch;
289294 $this->linkBatch->setArray( $this->timestamps );
290295 }
@@ -295,6 +300,7 @@
296301 foreach ( $this->timestamps as $ns => $dbks ) {
297302 foreach ( $dbks as $dbk => $oldTimestamp ) {
298303 $newTimestamp = $newTimestamps[$ns][$dbk];
 304+
299305 if ( $oldTimestamp === false ) {
300306 if ( $newTimestamp === false ) {
301307 # Still missing
Index: trunk/phase3/includes/AutoLoader.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /* This defines autoloading handler for whole MediaWiki framework */
54
65 # Locations of core classes
Index: trunk/phase3/includes/BacklinkCache.php
@@ -1,10 +1,9 @@
22 <?php
3 -
43 /**
54 * Class for fetching backlink lists, approximate backlink counts and partitions.
65 * Instances of this class should typically be fetched with $title->getBacklinkCache().
76 *
8 - * Ideally you should only get your backlinks from here when you think there is some
 7+ * Ideally you should only get your backlinks from here when you think there is some
98 * advantage in caching them. Otherwise it's just a waste of memory.
109 */
1110 class BacklinkCache {
@@ -56,9 +55,10 @@
5756 wfProfileIn( __METHOD__ );
5857
5958 $fromField = $this->getPrefix( $table ) . '_from';
 59+
6060 if ( $startId || $endId ) {
6161 // Partial range, not cached
62 - wfDebug( __METHOD__.": from DB (uncacheable range)\n" );
 62+ wfDebug( __METHOD__ . ": from DB (uncacheable range)\n" );
6363 $conds = $this->getConditions( $table );
6464 // Use the from field in the condition rather than the joined page_id,
6565 // because databases are stupid and don't necessarily propagate indexes.
@@ -68,9 +68,9 @@
6969 if ( $endId ) {
7070 $conds[] = "$fromField <= " . intval( $endId );
7171 }
72 - $res = $this->getDB()->select(
 72+ $res = $this->getDB()->select(
7373 array( $table, 'page' ),
74 - array( 'page_namespace', 'page_title', 'page_id'),
 74+ array( 'page_namespace', 'page_title', 'page_id' ),
7575 $conds,
7676 __METHOD__,
7777 array(
@@ -83,8 +83,8 @@
8484 }
8585
8686 if ( !isset( $this->fullResultCache[$table] ) ) {
87 - wfDebug( __METHOD__.": from DB\n" );
88 - $res = $this->getDB()->select(
 87+ wfDebug( __METHOD__ . ": from DB\n" );
 88+ $res = $this->getDB()->select(
8989 array( $table, 'page' ),
9090 array( 'page_namespace', 'page_title', 'page_id' ),
9191 $this->getConditions( $table ),
@@ -111,6 +111,7 @@
112112 'templatelinks' => 'tl',
113113 'redirect' => 'rd',
114114 );
 115+
115116 if ( isset( $prefixes[$table] ) ) {
116117 return $prefixes[$table];
117118 } else {
@@ -123,6 +124,7 @@
124125 */
125126 protected function getConditions( $table ) {
126127 $prefix = $this->getPrefix( $table );
 128+
127129 switch ( $table ) {
128130 case 'pagelinks':
129131 case 'templatelinks':
@@ -134,13 +136,13 @@
135137 );
136138 break;
137139 case 'imagelinks':
138 - $conds = array(
 140+ $conds = array(
139141 'il_to' => $this->title->getDBkey(),
140142 'page_id=il_from'
141143 );
142144 break;
143145 case 'categorylinks':
144 - $conds = array(
 146+ $conds = array(
145147 'cl_to' => $this->title->getDBkey(),
146148 'page_id=cl_from',
147149 );
@@ -158,10 +160,12 @@
159161 if ( isset( $this->fullResultCache[$table] ) ) {
160162 return $this->fullResultCache[$table]->numRows();
161163 }
 164+
162165 if ( isset( $this->partitionCache[$table] ) ) {
163166 $entry = reset( $this->partitionCache[$table] );
164167 return $entry['numRows'];
165168 }
 169+
166170 $titleArray = $this->getLinks( $table );
167171 return $titleArray->count();
168172 }
@@ -178,26 +182,33 @@
179183 public function partition( $table, $batchSize ) {
180184 // Try cache
181185 if ( isset( $this->partitionCache[$table][$batchSize] ) ) {
182 - wfDebug( __METHOD__.": got from partition cache\n" );
 186+ wfDebug( __METHOD__ . ": got from partition cache\n" );
183187 return $this->partitionCache[$table][$batchSize]['batches'];
184188 }
 189+
185190 $this->partitionCache[$table][$batchSize] = false;
186191 $cacheEntry =& $this->partitionCache[$table][$batchSize];
187192
188193 // Try full result cache
189194 if ( isset( $this->fullResultCache[$table] ) ) {
190195 $cacheEntry = $this->partitionResult( $this->fullResultCache[$table], $batchSize );
191 - wfDebug( __METHOD__.": got from full result cache\n" );
 196+ wfDebug( __METHOD__ . ": got from full result cache\n" );
192197 return $cacheEntry['batches'];
193198 }
 199+
194200 // Try memcached
195201 global $wgMemc;
196 - $memcKey = wfMemcKey( 'backlinks', md5( $this->title->getPrefixedDBkey() ),
197 - $table, $batchSize );
 202+ $memcKey = wfMemcKey(
 203+ 'backlinks',
 204+ md5( $this->title->getPrefixedDBkey() ),
 205+ $table,
 206+ $batchSize
 207+ );
198208 $memcValue = $wgMemc->get( $memcKey );
 209+
199210 if ( is_array( $memcValue ) ) {
200211 $cacheEntry = $memcValue;
201 - wfDebug( __METHOD__.": got from memcached $memcKey\n" );
 212+ wfDebug( __METHOD__ . ": got from memcached $memcKey\n" );
202213 return $cacheEntry['batches'];
203214 }
204215 // Fetch from database
@@ -205,17 +216,18 @@
206217 $cacheEntry = $this->partitionResult( $this->fullResultCache[$table], $batchSize );
207218 // Save to memcached
208219 $wgMemc->set( $memcKey, $cacheEntry, self::CACHE_EXPIRY );
209 - wfDebug( __METHOD__.": got from database\n" );
 220+ wfDebug( __METHOD__ . ": got from database\n" );
210221 return $cacheEntry['batches'];
211222 }
212223
213 - /**
 224+ /**
214225 * Partition a DB result with backlinks in it into batches
215226 */
216227 protected function partitionResult( $res, $batchSize ) {
217228 $batches = array();
218229 $numRows = $res->numRows();
219230 $numBatches = ceil( $numRows / $batchSize );
 231+
220232 for ( $i = 0; $i < $numBatches; $i++ ) {
221233 if ( $i == 0 ) {
222234 $start = false;
@@ -225,6 +237,7 @@
226238 $row = $res->fetchObject();
227239 $start = $row->page_id;
228240 }
 241+
229242 if ( $i == $numBatches - 1 ) {
230243 $end = false;
231244 } else {
@@ -236,7 +249,7 @@
237250
238251 # Sanity check order
239252 if ( $start && $end && $start > $end ) {
240 - throw new MWException( __METHOD__.': Internal error: query result out of order' );
 253+ throw new MWException( __METHOD__ . ': Internal error: query result out of order' );
241254 }
242255
243256 $batches[] = array( $start, $end );
Index: trunk/phase3/includes/AjaxFunctions.php
@@ -4,7 +4,7 @@
55 * @ingroup Ajax
66 */
77
8 -if( !defined( 'MEDIAWIKI' ) ) {
 8+if ( !defined( 'MEDIAWIKI' ) ) {
99 die( 1 );
1010 }
1111
@@ -14,31 +14,31 @@
1515 * Modified function from http://pure-essence.net/stuff/code/utf8RawUrlDecode.phps
1616 *
1717 * @param $source String escaped with Javascript's escape() function
18 - * @param $iconv_to String destination character set will be used as second parameter
 18+ * @param $iconv_to String destination character set will be used as second parameter
1919 * in the iconv function. Default is UTF-8.
2020 * @return string
2121 */
22 -function js_unescape($source, $iconv_to = 'UTF-8') {
 22+function js_unescape( $source, $iconv_to = 'UTF-8' ) {
2323 $decodedStr = '';
2424 $pos = 0;
25 - $len = strlen ($source);
 25+ $len = strlen ( $source );
2626
27 - while ($pos < $len) {
28 - $charAt = substr ($source, $pos, 1);
29 - if ($charAt == '%') {
 27+ while ( $pos < $len ) {
 28+ $charAt = substr ( $source, $pos, 1 );
 29+ if ( $charAt == '%' ) {
3030 $pos++;
31 - $charAt = substr ($source, $pos, 1);
32 - if ($charAt == 'u') {
 31+ $charAt = substr ( $source, $pos, 1 );
 32+ if ( $charAt == 'u' ) {
3333 // we got a unicode character
3434 $pos++;
35 - $unicodeHexVal = substr ($source, $pos, 4);
36 - $unicode = hexdec ($unicodeHexVal);
37 - $decodedStr .= code2utf($unicode);
 35+ $unicodeHexVal = substr ( $source, $pos, 4 );
 36+ $unicode = hexdec ( $unicodeHexVal );
 37+ $decodedStr .= code2utf( $unicode );
3838 $pos += 4;
3939 } else {
4040 // we have an escaped ascii character
41 - $hexVal = substr ($source, $pos, 2);
42 - $decodedStr .= chr (hexdec ($hexVal));
 41+ $hexVal = substr ( $source, $pos, 2 );
 42+ $decodedStr .= chr ( hexdec ( $hexVal ) );
4343 $pos += 2;
4444 }
4545 } else {
@@ -47,8 +47,8 @@
4848 }
4949 }
5050
51 - if ($iconv_to != "UTF-8") {
52 - $decodedStr = iconv("UTF-8", $iconv_to, $decodedStr);
 51+ if ( $iconv_to != "UTF-8" ) {
 52+ $decodedStr = iconv( "UTF-8", $iconv_to, $decodedStr );
5353 }
5454
5555 return $decodedStr;
@@ -61,16 +61,16 @@
6262 * @param $num Integer
6363 * @return utf8char
6464 */
65 -function code2utf($num){
66 - if ( $num<128 )
67 - return chr($num);
68 - if ( $num<2048 )
69 - return chr(($num>>6)+192).chr(($num&63)+128);
70 - if ( $num<65536 )
71 - return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
72 - if ( $num<2097152 )
73 - return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128) .chr(($num&63)+128);
74 - return '';
 65+function code2utf( $num ) {
 66+ if ( $num < 128 )
 67+ return chr( $num );
 68+ if ( $num < 2048 )
 69+ return chr( ( $num >> 6 ) + 192 ) . chr( ( $num&63 ) + 128 );
 70+ if ( $num < 65536 )
 71+ return chr( ( $num >> 12 ) + 224 ) . chr( ( ( $num >> 6 )&63 ) + 128 ) . chr( ( $num&63 ) + 128 );
 72+ if ( $num < 2097152 )
 73+ return chr( ( $num >> 18 ) + 240 ) . chr( ( ( $num >> 12 )&63 ) + 128 ) . chr( ( ( $num >> 6 )&63 ) + 128 ) . chr( ( $num&63 ) + 128 );
 74+ return '';
7575 }
7676
7777 /**
@@ -81,49 +81,49 @@
8282 * respectively, followed by an HTML message to display in the alert box; or
8383 * '<err#>' on error
8484 */
85 -function wfAjaxWatch($pagename = "", $watch = "") {
86 - if(wfReadOnly()) {
 85+function wfAjaxWatch( $pagename = "", $watch = "" ) {
 86+ if ( wfReadOnly() ) {
8787 // redirect to action=(un)watch, which will display the database lock
8888 // message
8989 return '<err#>';
9090 }
9191
92 - if('w' !== $watch && 'u' !== $watch) {
 92+ if ( 'w' !== $watch && 'u' !== $watch ) {
9393 return '<err#>';
9494 }
9595 $watch = 'w' === $watch;
9696
97 - $title = Title::newFromDBkey($pagename);
98 - if(!$title) {
 97+ $title = Title::newFromDBkey( $pagename );
 98+ if ( !$title ) {
9999 // Invalid title
100100 return '<err#>';
101101 }
102 - $article = new Article($title);
 102+ $article = new Article( $title );
103103 $watching = $title->userIsWatching();
104104
105 - if($watch) {
106 - if(!$watching) {
107 - $dbw = wfGetDB(DB_MASTER);
 105+ if ( $watch ) {
 106+ if ( !$watching ) {
 107+ $dbw = wfGetDB( DB_MASTER );
108108 $dbw->begin();
109109 $ok = $article->doWatch();
110110 $dbw->commit();
111111 }
112112 } else {
113 - if($watching) {
114 - $dbw = wfGetDB(DB_MASTER);
 113+ if ( $watching ) {
 114+ $dbw = wfGetDB( DB_MASTER );
115115 $dbw->begin();
116116 $ok = $article->doUnwatch();
117117 $dbw->commit();
118118 }
119119 }
120120 // Something stopped the change
121 - if( isset($ok) && !$ok ) {
 121+ if ( isset( $ok ) && !$ok ) {
122122 return '<err#>';
123123 }
124 - if( $watch ) {
125 - return '<w#>'.wfMsgExt( 'addedwatchtext', array( 'parse' ), $title->getPrefixedText() );
 124+ if ( $watch ) {
 125+ return '<w#>' . wfMsgExt( 'addedwatchtext', array( 'parse' ), $title->getPrefixedText() );
126126 } else {
127 - return '<u#>'.wfMsgExt( 'removedwatchtext', array( 'parse' ), $title->getPrefixedText() );
 127+ return '<u#>' . wfMsgExt( 'removedwatchtext', array( 'parse' ), $title->getPrefixedText() );
128128 }
129129 }
130130
@@ -133,12 +133,12 @@
134134 */
135135 function wfAjaxGetThumbnailUrl( $file, $width, $height ) {
136136 $file = wfFindFile( $file );
137 -
 137+
138138 if ( !$file || !$file->exists() )
139139 return null;
140 -
 140+
141141 $url = $file->getThumbnail( $width, $height )->url;
142 -
 142+
143143 return $url;
144144 }
145145
@@ -148,11 +148,11 @@
149149 */
150150 function wfAjaxGetFileUrl( $file ) {
151151 $file = wfFindFile( $file );
152 -
 152+
153153 if ( !$file || !$file->exists() )
154154 return null;
155 -
 155+
156156 $url = $file->getUrl();
157 -
 157+
158158 return $url;
159 -}
\ No newline at end of file
 159+}
Index: trunk/phase3/includes/Autopromote.php
@@ -1,5 +1,4 @@
22 <?php
3 -
43 /**
54 * This class checks if user can get extra rights
65 * because of conditions specified in $wgAutopromote
Index: trunk/phase3/includes/Block.php
@@ -34,7 +34,7 @@
3535 $this->mUser = $user;
3636 $this->mBy = $by;
3737 $this->mReason = $reason;
38 - $this->mTimestamp = wfTimestamp(TS_MW,$timestamp);
 38+ $this->mTimestamp = wfTimestamp( TS_MW, $timestamp );
3939 $this->mAuto = $auto;
4040 $this->mAnonOnly = $anonOnly;
4141 $this->mCreateAccount = $createAccount;
@@ -54,7 +54,7 @@
5555 * Load a block from the database, using either the IP address or
5656 * user ID. Tries the user ID first, and if that doesn't work, tries
5757 * the address.
58 - *
 58+ *
5959 * @param $address String: IP address of user/anon
6060 * @param $user Integer: user id of user
6161 * @param $killExpired Boolean: delete expired blocks on load
@@ -130,6 +130,7 @@
131131 */
132132 protected function &getDBOptions( &$options ) {
133133 global $wgAntiLockFlags;
 134+
134135 if ( $this->mForUpdate || $this->mFromMaster ) {
135136 $db = wfGetDB( DB_MASTER );
136137 if ( !$this->mForUpdate || ( $wgAntiLockFlags & ALF_NO_BLOCK_LOCK ) ) {
@@ -180,12 +181,13 @@
181182 if ( $address ) {
182183 $conds = array( 'ipb_address' => $address, 'ipb_auto' => 0 );
183184 $res = $db->resultObject( $db->select( 'ipblocks', '*', $conds, __METHOD__, $options ) );
 185+
184186 if ( $this->loadFromResult( $res, $killExpired ) ) {
185187 if ( $user && $this->mAnonOnly ) {
186188 # Block is marked anon-only
187189 # Whitelist this IP address against autoblocks and range blocks
188190 # (but not account creation blocks -- bug 13611)
189 - if( !$this->mCreateAccount ) {
 191+ if ( !$this->mCreateAccount ) {
190192 $this->clear();
191193 }
192194 return false;
@@ -199,7 +201,7 @@
200202 if ( $this->loadRange( $address, $killExpired, $user ) ) {
201203 if ( $user && $this->mAnonOnly ) {
202204 # Respect account creation blocks on logged-in users -- bug 13611
203 - if( !$this->mCreateAccount ) {
 205+ if ( !$this->mCreateAccount ) {
204206 $this->clear();
205207 }
206208 return false;
@@ -211,10 +213,13 @@
212214 # Try autoblock
213215 if ( $address ) {
214216 $conds = array( 'ipb_address' => $address, 'ipb_auto' => 1 );
 217+
215218 if ( $user ) {
216219 $conds['ipb_anon_only'] = 0;
217220 }
 221+
218222 $res = $db->resultObject( $db->select( 'ipblocks', '*', $conds, __METHOD__, $options ) );
 223+
219224 if ( $this->loadFromResult( $res, $killExpired ) ) {
220225 return true;
221226 }
@@ -234,6 +239,7 @@
235240 */
236241 protected function loadFromResult( ResultWrapper $res, $killExpired = true ) {
237242 $ret = false;
 243+
238244 if ( 0 != $res->numRows() ) {
239245 # Get first block
240246 $row = $res->fetchObject();
@@ -274,6 +280,7 @@
275281 */
276282 public function loadRange( $address, $killExpired = true, $user = 0 ) {
277283 $iaddr = IP::toHex( $address );
 284+
278285 if ( $iaddr === false ) {
279286 # Invalid address
280287 return false;
@@ -309,7 +316,7 @@
310317 public function initFromRow( $row ) {
311318 $this->mAddress = $row->ipb_address;
312319 $this->mReason = $row->ipb_reason;
313 - $this->mTimestamp = wfTimestamp(TS_MW,$row->ipb_timestamp);
 320+ $this->mTimestamp = wfTimestamp( TS_MW, $row->ipb_timestamp );
314321 $this->mUser = $row->ipb_user;
315322 $this->mBy = $row->ipb_by;
316323 $this->mAuto = $row->ipb_auto;
@@ -321,17 +328,19 @@
322329 $this->mHideName = $row->ipb_deleted;
323330 $this->mId = $row->ipb_id;
324331 $this->mExpiry = self::decodeExpiry( $row->ipb_expiry );
 332+
325333 if ( isset( $row->user_name ) ) {
326334 $this->mByName = $row->user_name;
327335 } else {
328336 $this->mByName = $row->ipb_by_text;
329337 }
 338+
330339 $this->mRangeStart = $row->ipb_range_start;
331340 $this->mRangeEnd = $row->ipb_range_end;
332341 }
333342
334343 /**
335 - * Once $mAddress has been set, get the range they came from.
 344+ * Once $mAddress has been set, get the range they came from.
336345 * Wrapper for IP::parseRange
337346 */
338347 protected function initialiseRange() {
@@ -352,6 +361,7 @@
353362 if ( wfReadOnly() ) {
354363 return false;
355364 }
 365+
356366 if ( !$this->mId ) {
357367 throw new MWException( "Block::delete() now requires that the mId member be filled\n" );
358368 }
@@ -377,8 +387,9 @@
378388 # Don't collide with expired blocks
379389 Block::purgeExpired();
380390
381 - $ipb_id = $dbw->nextSequenceValue('ipblocks_ipb_id_seq');
382 - $dbw->insert( 'ipblocks',
 391+ $ipb_id = $dbw->nextSequenceValue( 'ipblocks_ipb_id_seq' );
 392+ $dbw->insert(
 393+ 'ipblocks',
383394 array(
384395 'ipb_id' => $ipb_id,
385396 'ipb_address' => $this->mAddress,
@@ -386,7 +397,7 @@
387398 'ipb_by' => $this->mBy,
388399 'ipb_by_text' => $this->mByName,
389400 'ipb_reason' => $this->mReason,
390 - 'ipb_timestamp' => $dbw->timestamp($this->mTimestamp),
 401+ 'ipb_timestamp' => $dbw->timestamp( $this->mTimestamp ),
391402 'ipb_auto' => $this->mAuto,
392403 'ipb_anon_only' => $this->mAnonOnly,
393404 'ipb_create_account' => $this->mCreateAccount,
@@ -397,7 +408,9 @@
398409 'ipb_deleted' => $this->mHideName,
399410 'ipb_block_email' => $this->mBlockEmail,
400411 'ipb_allow_usertalk' => $this->mAllowUsertalk
401 - ), 'Block::insert', array( 'IGNORE' )
 412+ ),
 413+ 'Block::insert',
 414+ array( 'IGNORE' )
402415 );
403416 $affected = $dbw->affectedRows();
404417
@@ -417,13 +430,14 @@
418431
419432 $this->validateBlockParams();
420433
421 - $dbw->update( 'ipblocks',
 434+ $dbw->update(
 435+ 'ipblocks',
422436 array(
423437 'ipb_user' => $this->mUser,
424438 'ipb_by' => $this->mBy,
425439 'ipb_by_text' => $this->mByName,
426440 'ipb_reason' => $this->mReason,
427 - 'ipb_timestamp' => $dbw->timestamp($this->mTimestamp),
 441+ 'ipb_timestamp' => $dbw->timestamp( $this->mTimestamp ),
428442 'ipb_auto' => $this->mAuto,
429443 'ipb_anon_only' => $this->mAnonOnly,
430444 'ipb_create_account' => $this->mCreateAccount,
@@ -433,13 +447,15 @@
434448 'ipb_range_end' => $this->mRangeEnd,
435449 'ipb_deleted' => $this->mHideName,
436450 'ipb_block_email' => $this->mBlockEmail,
437 - 'ipb_allow_usertalk' => $this->mAllowUsertalk ),
 451+ 'ipb_allow_usertalk' => $this->mAllowUsertalk
 452+ ),
438453 array( 'ipb_id' => $this->mId ),
439 - 'Block::update' );
 454+ 'Block::update'
 455+ );
440456
441457 return $dbw->affectedRows();
442458 }
443 -
 459+
444460 /**
445461 * Make sure all the proper members are set to sane values
446462 * before adding/updating a block
@@ -459,8 +475,8 @@
460476 if ( !$this->mUser && $this->mAnonOnly ) {
461477 $this->mBlockEmail = 0;
462478 }
463 - if( !$this->mByName ) {
464 - if( $this->mBy ) {
 479+ if ( !$this->mByName ) {
 480+ if ( $this->mBy ) {
465481 $this->mByName = User::whoIs( $this->mBy );
466482 } else {
467483 global $wgUser;
@@ -481,7 +497,7 @@
482498 # - stolen shamelessly from CheckUser_body.php
483499
484500 if ( $this->mEnableAutoblock && $this->mUser ) {
485 - wfDebug("Doing retroactive autoblocks for " . $this->mAddress . "\n");
 501+ wfDebug( "Doing retroactive autoblocks for " . $this->mAddress . "\n" );
486502
487503 $options = array( 'ORDER BY' => 'rc_timestamp DESC' );
488504 $conds = array( 'rc_user_text' => $this->mAddress );
@@ -500,7 +516,7 @@
501517
502518 if ( !$dbr->numRows( $res ) ) {
503519 # No results, don't autoblock anything
504 - wfDebug("No IP found to retroactively autoblock\n");
 520+ wfDebug( "No IP found to retroactively autoblock\n" );
505521 } else {
506522 while ( $row = $dbr->fetchObject( $res ) ) {
507523 if ( $row->rc_ip )
@@ -528,9 +544,9 @@
529545 $wgMemc->set( $key, $lines, 3600 * 24 );
530546 }
531547
532 - wfDebug("Checking the autoblock whitelist..\n");
 548+ wfDebug( "Checking the autoblock whitelist..\n" );
533549
534 - foreach( $lines as $line ) {
 550+ foreach ( $lines as $line ) {
535551 # List items only
536552 if ( substr( $line, 0, 1 ) !== '*' ) {
537553 continue;
@@ -539,11 +555,11 @@
540556 $wlEntry = substr( $line, 1 );
541557 $wlEntry = trim( $wlEntry );
542558
543 - wfDebug("Checking $ip against $wlEntry...");
 559+ wfDebug( "Checking $ip against $wlEntry..." );
544560
545561 # Is the IP in this range?
546562 if ( IP::isInRange( $ip, $wlEntry ) ) {
547 - wfDebug(" IP $ip matches $wlEntry, not autoblocking\n");
 563+ wfDebug( " IP $ip matches $wlEntry, not autoblocking\n" );
548564 return true;
549565 } else {
550566 wfDebug( " No match\n" );
@@ -570,8 +586,8 @@
571587 if ( Block::isWhitelistedFromAutoblocks( $autoblockIP ) ) {
572588 return;
573589 }
574 -
575 - ## Allow hooks to cancel the autoblock.
 590+
 591+ # # Allow hooks to cancel the autoblock.
576592 if ( !wfRunHooks( 'AbortAutoblock', array( $autoblockIP, &$this ) ) ) {
577593 wfDebug( "Autoblock aborted by hook.\n" );
578594 return false;
@@ -612,7 +628,7 @@
613629 $ipblock->mAllowUsertalk = $this->mAllowUsertalk;
614630 # If the user is already blocked with an expiry date, we don't
615631 # want to pile on top of that!
616 - if( $this->mExpiry ) {
 632+ if ( $this->mExpiry ) {
617633 $ipblock->mExpiry = min( $this->mExpiry, Block::getAutoblockExpiry( $this->mTimestamp ) );
618634 } else {
619635 $ipblock->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp );
@@ -661,7 +677,7 @@
662678 }
663679
664680 /**
665 - * Update the timestamp on autoblocks.
 681+ * Update the timestamp on autoblocks.
666682 */
667683 public function updateTimestamp() {
668684 if ( $this->mAuto ) {
@@ -727,7 +743,7 @@
728744 /**
729745 * Encode expiry for DB
730746 *
731 - * @param $expiry String: timestamp for expiry, or
 747+ * @param $expiry String: timestamp for expiry, or
732748 * @param $db Database object
733749 * @return String
734750 */
@@ -809,7 +825,7 @@
810826
811827 /**
812828 * Get a value to insert into expiry field of the database when infinite expiry
813 - * is desired. In principle this could be DBMS-dependant, but currently all
 829+ * is desired. In principle this could be DBMS-dependant, but currently all
814830 * supported DBMS's support the string "infinity", so we just use that.
815831 *
816832 * @return String
@@ -829,10 +845,10 @@
830846 public static function formatExpiry( $encoded_expiry ) {
831847 static $msg = null;
832848
833 - if( is_null( $msg ) ) {
 849+ if ( is_null( $msg ) ) {
834850 $msg = array();
835851 $keys = array( 'infiniteblock', 'expiringblock' );
836 - foreach( $keys as $key ) {
 852+ foreach ( $keys as $key ) {
837853 $msg[$key] = wfMsgHtml( $key );
838854 }
839855 }
@@ -859,6 +875,7 @@
860876 $expiry = 'infinity';
861877 } else {
862878 $expiry = strtotime( $expiry_input );
 879+
863880 if ( $expiry < 0 || $expiry === false ) {
864881 return false;
865882 }
Index: trunk/phase3/includes/AjaxResponse.php
@@ -4,14 +4,14 @@
55 * @ingroup Ajax
66 */
77
8 -if( !defined( 'MEDIAWIKI' ) ) {
 8+if ( !defined( 'MEDIAWIKI' ) ) {
99 die( 1 );
1010 }
1111
1212 /**
1313 * Handle responses for Ajax requests (send headers, print
1414 * content, that sort of thing)
15 - *
 15+ *
1616 * @ingroup Ajax
1717 */
1818 class AjaxResponse {
@@ -45,7 +45,7 @@
4646 $this->mText = '';
4747 $this->mResponseCode = '200 OK';
4848 $this->mLastModified = false;
49 - $this->mContentType= 'application/x-wiki';
 49+ $this->mContentType = 'application/x-wiki';
5050
5151 if ( $text ) {
5252 $this->addText( $text );
@@ -95,13 +95,13 @@
9696 header( "Status: " . $this->mResponseCode, true, (int)$n );
9797 }
9898
99 - header ("Content-Type: " . $this->mContentType );
 99+ header ( "Content-Type: " . $this->mContentType );
100100
101101 if ( $this->mLastModified ) {
102 - header ("Last-Modified: " . $this->mLastModified );
 102+ header ( "Last-Modified: " . $this->mLastModified );
103103 }
104104 else {
105 - header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
 105+ header ( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
106106 }
107107
108108 if ( $this->mCacheDuration ) {
@@ -110,31 +110,31 @@
111111 # and tell the client to always check with the squid. Otherwise,
112112 # tell the client to use a cached copy, without a way to purge it.
113113
114 - if( $wgUseSquid ) {
 114+ if ( $wgUseSquid ) {
115115
116116 # Expect explicite purge of the proxy cache, but require end user agents
117117 # to revalidate against the proxy on each visit.
118118 # Surrogate-Control controls our Squid, Cache-Control downstream caches
119119
120120 if ( $wgUseESI ) {
121 - header( 'Surrogate-Control: max-age='.$this->mCacheDuration.', content="ESI/1.0"');
 121+ header( 'Surrogate-Control: max-age=' . $this->mCacheDuration . ', content="ESI/1.0"' );
122122 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
123123 } else {
124 - header( 'Cache-Control: s-maxage='.$this->mCacheDuration.', must-revalidate, max-age=0' );
 124+ header( 'Cache-Control: s-maxage=' . $this->mCacheDuration . ', must-revalidate, max-age=0' );
125125 }
126126
127127 } else {
128128
129129 # Let the client do the caching. Cache is not purged.
130 - header ("Expires: " . gmdate( "D, d M Y H:i:s", time() + $this->mCacheDuration ) . " GMT");
131 - header ("Cache-Control: s-max-age={$this->mCacheDuration},public,max-age={$this->mCacheDuration}");
 130+ header ( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $this->mCacheDuration ) . " GMT" );
 131+ header ( "Cache-Control: s-max-age={$this->mCacheDuration},public,max-age={$this->mCacheDuration}" );
132132 }
133133
134134 } else {
135135 # always expired, always modified
136 - header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
137 - header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
138 - header ("Pragma: no-cache"); // HTTP/1.0
 136+ header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); // Date in the past
 137+ header ( "Cache-Control: no-cache, must-revalidate" ); // HTTP/1.1
 138+ header ( "Pragma: no-cache" ); // HTTP/1.0
139139 }
140140
141141 if ( $this->mVary ) {
@@ -156,11 +156,11 @@
157157 wfDebug( "$fname: CACHE DISABLED, NO TIMESTAMP\n" );
158158 return;
159159 }
160 - if( !$wgCachePages ) {
 160+ if ( !$wgCachePages ) {
161161 wfDebug( "$fname: CACHE DISABLED\n", false );
162162 return;
163163 }
164 - if( $wgUser->getOption( 'nocache' ) ) {
 164+ if ( $wgUser->getOption( 'nocache' ) ) {
165165 wfDebug( "$fname: USER DISABLED CACHE\n", false );
166166 return;
167167 }
@@ -168,7 +168,7 @@
169169 $timestamp = wfTimestamp( TS_MW, $timestamp );
170170 $lastmod = wfTimestamp( TS_RFC2822, max( $timestamp, $wgUser->mTouched, $wgCacheEpoch ) );
171171
172 - if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
 172+ if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
173173 # IE sends sizes after the date like this:
174174 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
175175 # this breaks strtotime().
@@ -177,8 +177,8 @@
178178 $ismodsince = wfTimestamp( TS_MW, $modsinceTime ? $modsinceTime : 1 );
179179 wfDebug( "$fname: -- client send If-Modified-Since: " . $modsince . "\n", false );
180180 wfDebug( "$fname: -- we might send Last-Modified : $lastmod\n", false );
181 - if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && $ismodsince >= $wgCacheEpoch ) {
182 - ini_set('zlib.output_compression', 0);
 181+ if ( ( $ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && $ismodsince >= $wgCacheEpoch ) {
 182+ ini_set( 'zlib.output_compression', 0 );
183183 $this->setResponseCode( "304 Not Modified" );
184184 $this->disable();
185185 $this->mLastModified = $lastmod;
Index: trunk/phase3/includes/Category.php
@@ -1,6 +1,6 @@
22 <?php
33 /**
4 - * Category objects are immutable, strictly speaking. If you call methods that change the database,
 4+ * Category objects are immutable, strictly speaking. If you call methods that change the database,
55 * like to refresh link counts, the objects will be appropriately reinitialized.
66 * Member variables are lazy-initialized.
77 *
@@ -18,21 +18,21 @@
1919 /** Counts of membership (cat_pages, cat_subcats, cat_files) */
2020 private $mPages = null, $mSubcats = null, $mFiles = null;
2121
22 - private function __construct() {}
 22+ private function __construct() { }
2323
2424 /**
2525 * Set up all member variables using a database query.
2626 * @return bool True on success, false on failure.
2727 */
2828 protected function initialize() {
29 - if ( $this->mName === null && $this->mTitle )
 29+ if ( $this->mName === null && $this->mTitle )
3030 $this->mName = $title->getDBkey();
3131
32 - if( $this->mName === null && $this->mID === null ) {
33 - throw new MWException( __METHOD__.' has both names and IDs null' );
34 - } elseif( $this->mID === null ) {
 32+ if ( $this->mName === null && $this->mID === null ) {
 33+ throw new MWException( __METHOD__ . ' has both names and IDs null' );
 34+ } elseif ( $this->mID === null ) {
3535 $where = array( 'cat_title' => $this->mName );
36 - } elseif( $this->mName === null ) {
 36+ } elseif ( $this->mName === null ) {
3737 $where = array( 'cat_id' => $this->mID );
3838 } else {
3939 # Already initialized
@@ -45,7 +45,8 @@
4646 $where,
4747 __METHOD__
4848 );
49 - if( !$row ) {
 49+
 50+ if ( !$row ) {
5051 # Okay, there were no contents. Nothing to initialize.
5152 if ( $this->mTitle ) {
5253 # If there is a title object but no record in the category table, treat this as an empty category
@@ -60,6 +61,7 @@
6162 return false; # Fail
6263 }
6364 }
 65+
6466 $this->mID = $row->cat_id;
6567 $this->mName = $row->cat_title;
6668 $this->mPages = $row->cat_pages;
@@ -69,7 +71,7 @@
7072 # (bug 13683) If the count is negative, then 1) it's obviously wrong
7173 # and should not be kept, and 2) we *probably* don't have to scan many
7274 # rows to obtain the correct figure, so let's risk a one-time recount.
73 - if( $this->mPages < 0 || $this->mSubcats < 0 || $this->mFiles < 0 ) {
 75+ if ( $this->mPages < 0 || $this->mSubcats < 0 || $this->mFiles < 0 ) {
7476 $this->refreshCounts();
7577 }
7678
@@ -86,7 +88,8 @@
8789 public static function newFromName( $name ) {
8890 $cat = new self();
8991 $title = Title::makeTitleSafe( NS_CATEGORY, $name );
90 - if( !is_object( $title ) ) {
 92+
 93+ if ( !is_object( $title ) ) {
9194 return false;
9295 }
9396
@@ -126,7 +129,7 @@
127130 /**
128131 * Factory function, for constructing a Category object from a result set
129132 *
130 - * @param $row result set row, must contain the cat_xxx fields. If the fields are null,
 133+ * @param $row result set row, must contain the cat_xxx fields. If the fields are null,
131134 * the resulting Category object will represent an empty category if a title object
132135 * was given. If the fields are null and no title was given, this method fails and returns false.
133136 * @param $title optional title object for the category represented by the given row.
@@ -137,8 +140,7 @@
138141 $cat = new self();
139142 $cat->mTitle = $title;
140143
141 -
142 - # NOTE: the row often results from a LEFT JOIN on categorylinks. This may result in
 144+ # NOTE: the row often results from a LEFT JOIN on categorylinks. This may result in
143145 # all the cat_xxx fields being null, if the category page exists, but nothing
144146 # was ever added to the category. This case should be treated linke an empty
145147 # category, if possible.
@@ -169,12 +171,16 @@
170172
171173 /** @return mixed DB key name, or false on failure */
172174 public function getName() { return $this->getX( 'mName' ); }
 175+
173176 /** @return mixed Category ID, or false on failure */
174177 public function getID() { return $this->getX( 'mID' ); }
 178+
175179 /** @return mixed Total number of member pages, or false on failure */
176180 public function getPageCount() { return $this->getX( 'mPages' ); }
 181+
177182 /** @return mixed Number of subcategories, or false on failure */
178183 public function getSubcatCount() { return $this->getX( 'mSubcats' ); }
 184+
179185 /** @return mixed Number of member files, or false on failure */
180186 public function getFileCount() { return $this->getX( 'mFiles' ); }
181187
@@ -182,9 +188,9 @@
183189 * @return mixed The Title for this category, or false on failure.
184190 */
185191 public function getTitle() {
186 - if( $this->mTitle ) return $this->mTitle;
187 -
188 - if( !$this->initialize() ) {
 192+ if ( $this->mTitle ) return $this->mTitle;
 193+
 194+ if ( !$this->initialize() ) {
189195 return false;
190196 }
191197
@@ -204,13 +210,19 @@
205211
206212 $conds = array( 'cl_to' => $this->getName(), 'cl_from = page_id' );
207213 $options = array( 'ORDER BY' => 'cl_sortkey' );
208 - if( $limit ) $options[ 'LIMIT' ] = $limit;
209 - if( $offset !== '' ) $conds[] = 'cl_sortkey > ' . $dbr->addQuotes( $offset );
210214
 215+ if ( $limit ) {
 216+ $options[ 'LIMIT' ] = $limit;
 217+ }
 218+
 219+ if ( $offset !== '' ) {
 220+ $conds[] = 'cl_sortkey > ' . $dbr->addQuotes( $offset );
 221+ }
 222+
211223 return TitleArray::newFromResult(
212224 $dbr->select(
213225 array( 'page', 'categorylinks' ),
214 - array( 'page_id', 'page_namespace','page_title', 'page_len',
 226+ array( 'page_id', 'page_namespace', 'page_title', 'page_len',
215227 'page_is_redirect', 'page_latest' ),
216228 $conds,
217229 __METHOD__,
@@ -221,10 +233,10 @@
222234
223235 /** Generic accessor */
224236 private function getX( $key ) {
225 - if( !$this->initialize() ) {
 237+ if ( !$this->initialize() ) {
226238 return false;
227239 }
228 - return $this->{$key};
 240+ return $this-> { $key } ;
229241 }
230242
231243 /**
@@ -233,14 +245,14 @@
234246 * @return bool True on success, false on failure
235247 */
236248 public function refreshCounts() {
237 - if( wfReadOnly() ) {
 249+ if ( wfReadOnly() ) {
238250 return false;
239251 }
240252 $dbw = wfGetDB( DB_MASTER );
241253 $dbw->begin();
242254 # Note, we must use names for this, since categorylinks does.
243 - if( $this->mName === null ) {
244 - if( !$this->initialize() ) {
 255+ if ( $this->mName === null ) {
 256+ if ( !$this->initialize() ) {
245257 return false;
246258 }
247259 } else {
@@ -249,15 +261,17 @@
250262 $seqVal = $dbw->nextSequenceValue( 'category_cat_id_seq' );
251263 $dbw->insert(
252264 'category',
253 - array( 'cat_id' => $seqVal,
254 - 'cat_title' => $this->mName ),
 265+ array(
 266+ 'cat_id' => $seqVal,
 267+ 'cat_title' => $this->mName
 268+ ),
255269 __METHOD__,
256270 'IGNORE'
257271 );
258272 }
259273
260 - $cond1 = $dbw->conditional( 'page_namespace='.NS_CATEGORY, 1, 'NULL' );
261 - $cond2 = $dbw->conditional( 'page_namespace='.NS_FILE, 1, 'NULL' );
 274+ $cond1 = $dbw->conditional( 'page_namespace=' . NS_CATEGORY, 1, 'NULL' );
 275+ $cond2 = $dbw->conditional( 'page_namespace=' . NS_FILE, 1, 'NULL' );
262276 $result = $dbw->selectRow(
263277 array( 'categorylinks', 'page' ),
264278 array( 'COUNT(*) AS pages',

Follow-up revisions

RevisionCommit summaryAuthorDate
r81671Back out the changes which depend on the categorylinks schema change, so that...tstarling00:57, 8 February 2011

Status & tagging log