r67072 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67071‎ | r67072 | r67073 >
Date:14:28, 30 May 2010
Author:siebrand
Status:ok
Tags:
Comment:
Ran stylize.php, removed trailing whitespace, updated indentation and code formatting.
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/FormOptions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/FormOptions.php
@@ -7,11 +7,11 @@
88 */
99
1010 class FormOptions implements ArrayAccess {
11 - const AUTO = -1; //! Automatically detects simple data types
 11+ const AUTO = -1; // ! Automatically detects simple data types
1212 const STRING = 0;
1313 const INT = 1;
1414 const BOOL = 2;
15 - const INTNULL = 3; //! Useful for namespace selector
 15+ const INTNULL = 3; // ! Useful for namespace selector
1616
1717 protected $options = array();
1818
@@ -34,15 +34,15 @@
3535
3636 public function delete( $name ) {
3737 $this->validateName( $name, true );
38 - unset($this->options[$name]);
 38+ unset( $this->options[$name] );
3939 }
4040
4141 public static function guessType( $data ) {
42 - if ( is_bool($data) ) {
 42+ if ( is_bool( $data ) ) {
4343 return self::BOOL;
44 - } elseif( is_int($data) ) {
 44+ } elseif ( is_int( $data ) ) {
4545 return self::INT;
46 - } elseif( is_string($data) ) {
 46+ } elseif ( is_string( $data ) ) {
4747 return self::STRING;
4848 } else {
4949 throw new MWException( 'Unsupported datatype' );
@@ -52,7 +52,7 @@
5353 # Handling values
5454
5555 public function validateName( $name, $strict = false ) {
56 - if ( !isset($this->options[$name]) ) {
 56+ if ( !isset( $this->options[$name] ) ) {
5757 if ( $strict ) {
5858 throw new MWException( "Invalid option $name" );
5959 } else {
@@ -64,6 +64,7 @@
6565
6666 public function setValue( $name, $value, $force = false ) {
6767 $this->validateName( $name, true );
 68+
6869 if ( !$force && $value === $this->options[$name]['default'] ) {
6970 // null default values as unchanged
7071 $this->options[$name]['value'] = null;
@@ -74,6 +75,7 @@
7576
7677 public function getValue( $name ) {
7778 $this->validateName( $name, true );
 79+
7880 return $this->getValueReal( $this->options[$name] );
7981 }
8082
@@ -93,16 +95,19 @@
9496 public function consumeValue( $name ) {
9597 $this->validateName( $name, true );
9698 $this->options[$name]['consumed'] = true;
 99+
97100 return $this->getValueReal( $this->options[$name] );
98101 }
99102
100103 public function consumeValues( /*Array*/ $names ) {
101104 $out = array();
 105+
102106 foreach ( $names as $name ) {
103107 $this->validateName( $name, true );
104108 $this->options[$name]['consumed'] = true;
105109 $out[] = $this->getValueReal( $this->options[$name] );
106110 }
 111+
107112 return $out;
108113 }
109114
@@ -111,8 +116,9 @@
112117 public function validateIntBounds( $name, $min, $max ) {
113118 $this->validateName( $name, true );
114119
115 - if ( $this->options[$name]['type'] !== self::INT )
 120+ if ( $this->options[$name]['type'] !== self::INT ) {
116121 throw new MWException( "Option $name is not of type int" );
 122+ }
117123
118124 $value = $this->getValueReal( $this->options[$name] );
119125 $value = max( $min, min( $max, $value ) );
@@ -124,6 +130,7 @@
125131
126132 public function getUnconsumedValues( $all = false ) {
127133 $values = array();
 134+
128135 foreach ( $this->options as $name => $data ) {
129136 if ( !$data['consumed'] ) {
130137 if ( $all || $data['value'] !== null ) {
@@ -131,24 +138,29 @@
132139 }
133140 }
134141 }
 142+
135143 return $values;
136144 }
137145
138146 public function getChangedValues() {
139147 $values = array();
 148+
140149 foreach ( $this->options as $name => $data ) {
141150 if ( $data['value'] !== null ) {
142151 $values[$name] = $data['value'];
143152 }
144153 }
 154+
145155 return $values;
146156 }
147157
148158 public function getAllValues() {
149159 $values = array();
 160+
150161 foreach ( $this->options as $name => $data ) {
151162 $values[$name] = $this->getValueReal( $data );
152163 }
 164+
153165 return $values;
154166 }
155167
@@ -156,7 +168,7 @@
157169
158170 public function fetchValuesFromRequest( WebRequest $r, $values = false ) {
159171 if ( !$values ) {
160 - $values = array_keys($this->options);
 172+ $values = array_keys( $this->options );
161173 }
162174
163175 foreach ( $values as $name ) {
@@ -184,7 +196,7 @@
185197
186198 /* ArrayAccess methods */
187199 public function offsetExists( $name ) {
188 - return isset($this->options[$name]);
 200+ return isset( $this->options[$name] );
189201 }
190202
191203 public function offsetGet( $name ) {
@@ -198,5 +210,4 @@
199211 public function offsetUnset( $name ) {
200212 $this->delete( $name );
201213 }
202 -
203214 }
Index: trunk/phase3/includes/Article.php
@@ -83,10 +83,14 @@
8484 * @return mixed Title object, or null if this page is not a redirect
8585 */
8686 public function getRedirectTarget() {
87 - if ( !$this->mTitle || !$this->mTitle->isRedirect() )
 87+ if ( !$this->mTitle || !$this->mTitle->isRedirect() ) {
8888 return null;
89 - if ( !is_null( $this->mRedirectTarget ) )
 89+ }
 90+
 91+ if ( !is_null( $this->mRedirectTarget ) ) {
9092 return $this->mRedirectTarget;
 93+ }
 94+
9195 # Query the redirect table
9296 $dbr = wfGetDB( DB_SLAVE );
9397 $row = $dbr->selectRow( 'redirect',
@@ -94,9 +98,11 @@
9599 array( 'rd_from' => $this->getID() ),
96100 __METHOD__
97101 );
 102+
98103 if ( $row ) {
99104 return $this->mRedirectTarget = Title::makeTitle( $row->rd_namespace, $row->rd_title );
100105 }
 106+
101107 # This page doesn't have an entry in the redirect table
102108 return $this->mRedirectTarget = $this->insertRedirect();
103109 }
@@ -109,9 +115,11 @@
110116 */
111117 public function insertRedirect() {
112118 $retval = Title::newFromRedirect( $this->getContent() );
 119+
113120 if ( !$retval ) {
114121 return null;
115122 }
 123+
116124 $dbw = wfGetDB( DB_MASTER );
117125 $dbw->replace( 'redirect', array( 'rd_from' ),
118126 array(
@@ -121,6 +129,7 @@
122130 ),
123131 __METHOD__
124132 );
 133+
125134 return $retval;
126135 }
127136
@@ -131,6 +140,7 @@
132141 */
133142 public function followRedirect() {
134143 $text = $this->getContent();
 144+
135145 return $this->followRedirectText( $text );
136146 }
137147
@@ -143,6 +153,7 @@
144154 public function followRedirectText( $text ) {
145155 $rt = Title::newFromRedirectRecurse( $text ); // recurse through to only get the final target
146156 # process if title object is valid and not special:userlogout
 157+
147158 if ( $rt ) {
148159 if ( $rt->getInterwiki() != '' ) {
149160 if ( $rt->isLocal() ) {
@@ -166,9 +177,11 @@
167178 return $rt->getFullURL();
168179 }
169180 }
 181+
170182 return $rt;
171183 }
172184 }
 185+
173186 // No or invalid redirect
174187 return false;
175188 }
@@ -213,7 +226,9 @@
214227 */
215228 public function getContent() {
216229 global $wgUser, $wgContLang, $wgOut, $wgMessageCache;
 230+
217231 wfProfileIn( __METHOD__ );
 232+
218233 if ( $this->getID() === 0 ) {
219234 # If this is a MediaWiki:x message, then load the messages
220235 # and return the message value for x.
@@ -222,16 +237,19 @@
223238 list( $message, $lang ) = $wgMessageCache->figureMessage( $wgContLang->lcfirst( $this->mTitle->getText() ) );
224239 $wgMessageCache->loadAllMessages( $lang );
225240 $text = wfMsgGetKey( $message, false, $lang, false );
 241+
226242 if ( wfEmptyMsg( $message, $text ) )
227243 $text = '';
228244 } else {
229245 $text = wfMsgExt( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag' );
230246 }
231247 wfProfileOut( __METHOD__ );
 248+
232249 return $text;
233250 } else {
234251 $this->loadContent();
235252 wfProfileOut( __METHOD__ );
 253+
236254 return $this->mContent;
237255 }
238256 }
@@ -246,8 +264,10 @@
247265 if ( $this->mContentLoaded && $this->mOldId == 0 ) {
248266 return $this->mContent;
249267 }
 268+
250269 $rev = Revision::newFromTitle( $this->mTitle );
251270 $text = $rev ? $rev->getRawText() : false;
 271+
252272 return $text;
253273 }
254274
@@ -265,6 +285,7 @@
266286 */
267287 public function getSection( $text, $section ) {
268288 global $wgParser;
 289+
269290 return $wgParser->getSection( $text, $section );
270291 }
271292
@@ -280,13 +301,18 @@
281302 $undo_text = $undo->getText();
282303 $undoafter_text = $undoafter->getText();
283304 $cur_text = $this->getContent();
 305+
284306 if ( $cur_text == $undo_text ) {
285307 # No use doing a merge if it's just a straight revert.
286308 return $undoafter_text;
287309 }
 310+
288311 $undone_text = '';
289 - if ( !wfMerge( $undo_text, $undoafter_text, $cur_text, $undone_text ) )
 312+
 313+ if ( !wfMerge( $undo_text, $undoafter_text, $cur_text, $undone_text ) ) {
290314 return false;
 315+ }
 316+
291317 return $undone_text;
292318 }
293319
@@ -298,6 +324,7 @@
299325 if ( is_null( $this->mOldId ) ) {
300326 $this->mOldId = $this->getOldIDFromRequest();
301327 }
 328+
302329 return $this->mOldId;
303330 }
304331
@@ -308,13 +335,16 @@
309336 */
310337 public function getOldIDFromRequest() {
311338 global $wgRequest;
 339+
312340 $this->mRedirectUrl = false;
 341+
313342 $oldid = $wgRequest->getVal( 'oldid' );
 343+
314344 if ( isset( $oldid ) ) {
315345 $oldid = intval( $oldid );
316346 if ( $wgRequest->getVal( 'direction' ) == 'next' ) {
317347 $nextid = $this->mTitle->getNextRevisionID( $oldid );
318 - if ( $nextid ) {
 348+ if ( $nextid ) {
319349 $oldid = $nextid;
320350 } else {
321351 $this->mRedirectUrl = $this->mTitle->getFullURL( 'redirect=no' );
@@ -326,9 +356,11 @@
327357 }
328358 }
329359 }
 360+
330361 if ( !$oldid ) {
331362 $oldid = 0;
332363 }
 364+
333365 return $oldid;
334366 }
335367
@@ -336,18 +368,22 @@
337369 * Load the revision (including text) into this object
338370 */
339371 function loadContent() {
340 - if ( $this->mContentLoaded ) return;
 372+ if ( $this->mContentLoaded ) {
 373+ return;
 374+ }
 375+
341376 wfProfileIn( __METHOD__ );
 377+
342378 # Query variables :P
343379 $oldid = $this->getOldID();
344380 # Pre-fill content with error message so that if something
345381 # fails we'll have something telling us what we intended.
346382 $this->mOldId = $oldid;
347383 $this->fetchContent( $oldid );
 384+
348385 wfProfileOut( __METHOD__ );
349386 }
350387
351 -
352388 /**
353389 * Fetch a page record with the given conditions
354390 * @param $dbr Database object
@@ -368,21 +404,25 @@
369405 'page_latest',
370406 'page_len',
371407 );
 408+
372409 wfRunHooks( 'ArticlePageDataBefore', array( &$this, &$fields ) );
 410+
373411 $row = $dbr->selectRow(
374412 'page',
375413 $fields,
376414 $conditions,
377415 __METHOD__
378416 );
 417+
379418 wfRunHooks( 'ArticlePageDataAfter', array( &$this, &$row ) );
 419+
380420 return $row ;
381421 }
382422
383423 /**
384424 * Fetch a page record matching the Title object's namespace and title
385425 * using a sanitized title string
386 - *
 426+ *
387427 * @param $dbr Database object
388428 * @param $title Title object
389429 * @return mixed Database result resource, or false on failure
@@ -416,6 +456,7 @@
417457 }
418458
419459 $lc = LinkCache::singleton();
 460+
420461 if ( $data ) {
421462 $lc->addGoodLinkObj( $data->page_id, $this->mTitle, $data->page_len, $data->page_is_redirect );
422463
@@ -435,13 +476,13 @@
436477 $this->mTitle->mArticleID = 0;
437478 }
438479
439 - $this->mDataLoaded = true;
 480+ $this->mDataLoaded = true;
440481 }
441482
442483 /**
443484 * Get text of an article from database
444485 * Does *NOT* follow redirects.
445 - *
 486+ *
446487 * @param $oldid Int: 0 for whatever the latest revision is
447488 * @return mixed string containing article contents, or false if null
448489 */
@@ -464,20 +505,25 @@
465506 wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" );
466507 return false;
467508 }
 509+
468510 $data = $this->pageDataFromId( $dbr, $revision->getPage() );
 511+
469512 if ( !$data ) {
470513 wfDebug( __METHOD__ . " failed to get page data linked to revision id $oldid\n" );
471514 return false;
472515 }
 516+
473517 $this->mTitle = Title::makeTitle( $data->page_namespace, $data->page_title );
474518 $this->loadPageData( $data );
475519 } else {
476520 if ( !$this->mDataLoaded ) {
477521 $data = $this->pageDataFromTitle( $dbr, $this->mTitle );
 522+
478523 if ( !$data ) {
479524 wfDebug( __METHOD__ . " failed to find page data for title " . $this->mTitle->getPrefixedText() . "\n" );
480525 return false;
481526 }
 527+
482528 $this->loadPageData( $data );
483529 }
484530 $revision = Revision::newFromId( $this->mLatest );
@@ -541,6 +587,7 @@
542588 $options = 'FOR UPDATE';
543589 }
544590 }
 591+
545592 return $options;
546593 }
547594
@@ -580,6 +627,7 @@
581628 public function getCount() {
582629 if ( -1 == $this->mCounter ) {
583630 $id = $this->getID();
 631+
584632 if ( $id == 0 ) {
585633 $this->mCounter = 0;
586634 } else {
@@ -592,11 +640,12 @@
593641 );
594642 }
595643 }
 644+
596645 return $this->mCounter;
597646 }
598647
599648 /**
600 - * Determine whether a page would be suitable for being counted as an
 649+ * Determine whether a page would be suitable for being counted as an
601650 * article in the site_stats table based on the title & its content
602651 *
603652 * @param $text String: text to analyze
@@ -606,6 +655,7 @@
607656 global $wgUseCommaCount;
608657
609658 $token = $wgUseCommaCount ? ',' : '[[';
 659+
610660 return $this->mTitle->isContentPage() && !$this->isRedirect( $text ) && in_string( $token, $text );
611661 }
612662
@@ -620,12 +670,14 @@
621671 if ( $this->mDataLoaded ) {
622672 return $this->mIsRedirect;
623673 }
 674+
624675 // Apparently loadPageData was never called
625676 $this->loadContent();
626677 $titleObj = Title::newFromRedirectRecurse( $this->fetchContent() );
627678 } else {
628679 $titleObj = Title::newFromRedirect( $text );
629680 }
 681+
630682 return $titleObj !== null;
631683 }
632684
@@ -639,6 +691,7 @@
640692 if ( $this->getOldID() == 0 ) {
641693 return true;
642694 }
 695+
643696 return $this->exists() && isset( $this->mRevision ) && $this->mRevision->isCurrent();
644697 }
645698
@@ -647,12 +700,15 @@
648701 * This isn't necessary for all uses, so it's only done if needed.
649702 */
650703 protected function loadLastEdit() {
651 - if ( -1 != $this->mUser )
 704+ if ( -1 != $this->mUser ) {
652705 return;
 706+ }
653707
654708 # New or non-existent articles have no user information
655709 $id = $this->getID();
656 - if ( 0 == $id ) return;
 710+ if ( 0 == $id ) {
 711+ return;
 712+ }
657713
658714 $this->mLastRevision = Revision::loadFromPageId( wfGetDB( DB_MASTER ), $id );
659715 if ( !is_null( $this->mLastRevision ) ) {
@@ -664,7 +720,7 @@
665721 $this->mRevIdFetched = $this->mLastRevision->getId();
666722 }
667723 }
668 -
 724+
669725 /**
670726 * @return string GMT timestamp of last article revision
671727 **/
@@ -674,6 +730,7 @@
675731 if ( !$this->mTimestamp ) {
676732 $this->loadLastEdit();
677733 }
 734+
678735 return wfTimestamp( TS_MW, $this->mTimestamp );
679736 }
680737
@@ -682,6 +739,7 @@
683740 */
684741 public function getUser() {
685742 $this->loadLastEdit();
 743+
686744 return $this->mUser;
687745 }
688746
@@ -690,6 +748,7 @@
691749 */
692750 public function getUserText() {
693751 $this->loadLastEdit();
 752+
694753 return $this->mUserText;
695754 }
696755
@@ -698,16 +757,18 @@
699758 */
700759 public function getComment() {
701760 $this->loadLastEdit();
 761+
702762 return $this->mComment;
703763 }
704764
705765 /**
706766 * Returns true if last revision was marked as "minor edit"
707 - *
 767+ *
708768 * @return boolean Minor edit indicator for the last article revision.
709769 */
710770 public function getMinorEdit() {
711771 $this->loadLastEdit();
 772+
712773 return $this->mMinorEdit;
713774 }
714775
@@ -718,6 +779,7 @@
719780 */
720781 public function getRevIdFetched() {
721782 $this->loadLastEdit();
 783+
722784 return $this->mRevIdFetched;
723785 }
724786
@@ -727,7 +789,7 @@
728790 * @return UserArrayFromResult object with User objects of article contributors for requested range
729791 */
730792 public function getContributors( $limit = 0, $offset = 0 ) {
731 - # XXX: this is expensive; cache this info somewhere.
 793+ # FIXME: this is expensive; cache this info somewhere.
732794
733795 $dbr = wfGetDB( DB_SLAVE );
734796 $revTable = $dbr->tableName( 'revision' );
@@ -736,6 +798,7 @@
737799 $pageId = $this->getId();
738800
739801 $user = $this->getUser();
 802+
740803 if ( $user ) {
741804 $excludeCond = "AND rev_user != $user";
742805 } else {
@@ -753,8 +816,9 @@
754817 GROUP BY rev_user, rev_user_text
755818 ORDER BY timestamp DESC";
756819
757 - if ( $limit > 0 )
 820+ if ( $limit > 0 ) {
758821 $sql = $dbr->limitResult( $sql, $limit, $offset );
 822+ }
759823
760824 $sql .= ' ' . $this->getSelectOptions();
761825 $res = $dbr->query( $sql, __METHOD__ );
@@ -786,13 +850,16 @@
787851 # Try client and file cache
788852 if ( $oldid === 0 && $this->checkTouched() ) {
789853 global $wgUseETag;
 854+
790855 if ( $wgUseETag ) {
791856 $wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) );
792857 }
 858+
793859 # Is is client cached?
794860 if ( $wgOut->checkLastModified( $this->getTouched() ) ) {
795861 wfDebug( __METHOD__ . ": done 304\n" );
796862 wfProfileOut( __METHOD__ );
 863+
797864 return;
798865 # Try file cache
799866 } else if ( $wgUseFileCache && $this->tryFileCache() ) {
@@ -801,6 +868,7 @@
802869 $wgOut->disable();
803870 $this->viewUpdates();
804871 wfProfileOut( __METHOD__ );
 872+
805873 return;
806874 }
807875 }
@@ -810,6 +878,7 @@
811879 $wgOut->redirect( $this->mRedirectUrl );
812880 wfDebug( __METHOD__ . ": redirecting due to oldid\n" );
813881 wfProfileOut( __METHOD__ );
 882+
814883 return;
815884 }
816885
@@ -822,6 +891,7 @@
823892 wfDebug( __METHOD__ . ": showing diff page\n" );
824893 $this->showDiffPage();
825894 wfProfileOut( __METHOD__ );
 895+
826896 return;
827897 }
828898
@@ -840,16 +910,17 @@
841911 $pass = 0;
842912 $outputDone = false;
843913 $this->mParserOutput = false;
 914+
844915 while ( !$outputDone && ++$pass ) {
845916 switch( $pass ) {
846917 case 1:
847918 wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) );
848919 break;
849 -
850920 case 2:
851921 # Try the parser cache
852922 if ( $useParserCache ) {
853923 $this->mParserOutput = $parserCache->get( $this, $parserOptions );
 924+
854925 if ( $this->mParserOutput !== false ) {
855926 wfDebug( __METHOD__ . ": showing parser cache contents\n" );
856927 $wgOut->addParserOutput( $this->mParserOutput );
@@ -860,7 +931,6 @@
861932 }
862933 }
863934 break;
864 -
865935 case 3:
866936 $text = $this->getContent();
867937 if ( $text === false || $this->getID() == 0 ) {
@@ -883,11 +953,13 @@
884954 # Are we looking at an old revision
885955 if ( $oldid && !is_null( $this->mRevision ) ) {
886956 $this->setOldSubtitle( $oldid );
 957+
887958 if ( !$this->showDeletedRevisionHeader() ) {
888959 wfDebug( __METHOD__ . ": cannot view deleted revision\n" );
889960 wfProfileOut( __METHOD__ );
890961 return;
891962 }
 963+
892964 # If this "old" version is the current, then try the parser cache...
893965 if ( $oldid === $this->getLatest() && $this->useParserCache( false ) ) {
894966 $this->mParserOutput = $parserCache->get( $this, $parserOptions );
@@ -923,7 +995,6 @@
924996 $outputDone = true;
925997 }
926998 break;
927 -
928999 case 4:
9291000 # Run the parse, protected by a pool counter
9301001 wfDebug( __METHOD__ . ": doing uncached parse\n" );
@@ -941,7 +1012,6 @@
9421013 $outputDone = true;
9431014 }
9441015 break;
945 -
9461016 # Should be unreachable, but just in case...
9471017 default:
9481018 break 2;
@@ -951,6 +1021,7 @@
9521022 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
9531023 if ( $this->mParserOutput ) {
9541024 $titleText = $this->mParserOutput->getTitleText();
 1025+
9551026 if ( strval( $titleText ) !== '' ) {
9561027 $wgOut->setPageTitle( $titleText );
9571028 }
@@ -1012,7 +1083,9 @@
10131084 */
10141085 public function showCssOrJsPage() {
10151086 global $wgOut;
 1087+
10161088 $wgOut->addHTML( wfMsgExt( 'clearyourcache', 'parse' ) );
 1089+
10171090 // Give hooks a chance to customise the output
10181091 if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->mTitle, $wgOut ) ) ) {
10191092 // Wrap the whole lot in a <pre> and don't parse
@@ -1033,6 +1106,7 @@
10341107 public function getRobotPolicyForView() {
10351108 wfDeprecated( __METHOD__ );
10361109 $policy = $this->getRobotPolicy( 'view' );
 1110+
10371111 return $policy['index'] . ',' . $policy['follow'];
10381112 }
10391113
@@ -1043,34 +1117,42 @@
10441118 * TODO: actions other than 'view'
10451119 */
10461120 public function getRobotPolicy( $action ) {
1047 -
10481121 global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies;
10491122 global $wgDefaultRobotPolicy, $wgRequest;
10501123
10511124 $ns = $this->mTitle->getNamespace();
 1125+
10521126 if ( $ns == NS_USER || $ns == NS_USER_TALK ) {
10531127 # Don't index user and user talk pages for blocked users (bug 11443)
10541128 if ( !$this->mTitle->isSubpage() ) {
10551129 $block = new Block();
10561130 if ( $block->load( $this->mTitle->getText() ) ) {
1057 - return array( 'index' => 'noindex',
1058 - 'follow' => 'nofollow' );
 1131+ return array(
 1132+ 'index' => 'noindex',
 1133+ 'follow' => 'nofollow'
 1134+ );
10591135 }
10601136 }
10611137 }
10621138
10631139 if ( $this->getID() === 0 || $this->getOldID() ) {
10641140 # Non-articles (special pages etc), and old revisions
1065 - return array( 'index' => 'noindex',
1066 - 'follow' => 'nofollow' );
 1141+ return array(
 1142+ 'index' => 'noindex',
 1143+ 'follow' => 'nofollow'
 1144+ );
10671145 } elseif ( $wgOut->isPrintable() ) {
10681146 # Discourage indexing of printable versions, but encourage following
1069 - return array( 'index' => 'noindex',
1070 - 'follow' => 'follow' );
 1147+ return array(
 1148+ 'index' => 'noindex',
 1149+ 'follow' => 'follow'
 1150+ );
10711151 } elseif ( $wgRequest->getInt( 'curid' ) ) {
10721152 # For ?curid=x urls, disallow indexing
1073 - return array( 'index' => 'noindex',
1074 - 'follow' => 'follow' );
 1153+ return array(
 1154+ 'index' => 'noindex',
 1155+ 'follow' => 'follow'
 1156+ );
10751157 }
10761158
10771159 # Otherwise, construct the policy based on the various config variables.
@@ -1078,24 +1160,29 @@
10791161
10801162 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
10811163 # Honour customised robot policies for this namespace
1082 - $policy = array_merge( $policy,
1083 - self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] ) );
 1164+ $policy = array_merge(
 1165+ $policy,
 1166+ self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
 1167+ );
10841168 }
10851169 if ( $this->mTitle->canUseNoindex() && is_object( $this->mParserOutput ) && $this->mParserOutput->getIndexPolicy() ) {
10861170 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
10871171 # a final sanity check that we have really got the parser output.
1088 - $policy = array_merge( $policy,
1089 - array( 'index' => $this->mParserOutput->getIndexPolicy() ) );
 1172+ $policy = array_merge(
 1173+ $policy,
 1174+ array( 'index' => $this->mParserOutput->getIndexPolicy() )
 1175+ );
10901176 }
10911177
10921178 if ( isset( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) ) {
10931179 # (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
1094 - $policy = array_merge( $policy,
1095 - self::formatRobotPolicy( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) );
 1180+ $policy = array_merge(
 1181+ $policy,
 1182+ self::formatRobotPolicy( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] )
 1183+ );
10961184 }
10971185
10981186 return $policy;
1099 -
11001187 }
11011188
11021189 /**
@@ -1123,6 +1210,7 @@
11241211 $arr['follow'] = $var;
11251212 }
11261213 }
 1214+
11271215 return $arr;
11281216 }
11291217
@@ -1138,6 +1226,7 @@
11391227
11401228 $rdfrom = $wgRequest->getVal( 'rdfrom' );
11411229 $sk = $wgUser->getSkin();
 1230+
11421231 if ( isset( $this->mRedirectedFrom ) ) {
11431232 // This is an internally redirected page view.
11441233 // We'll need a backlink to the source page for navigation.
@@ -1149,6 +1238,7 @@
11501239 array( 'redirect' => 'no' ),
11511240 array( 'known', 'noclasses' )
11521241 );
 1242+
11531243 $s = wfMsgExt( 'redirectedfrom', array( 'parseinline', 'replaceafter' ), $redir );
11541244 $wgOut->setSubtitle( $s );
11551245
@@ -1162,6 +1252,7 @@
11631253 $wgOut->addLink( array( 'rel' => 'canonical',
11641254 'href' => $this->mTitle->getLocalURL() )
11651255 );
 1256+
11661257 return true;
11671258 }
11681259 } elseif ( $rdfrom ) {
@@ -1171,9 +1262,11 @@
11721263 $redir = $sk->makeExternalLink( $rdfrom, $rdfrom );
11731264 $s = wfMsgExt( 'redirectedfrom', array( 'parseinline', 'replaceafter' ), $redir );
11741265 $wgOut->setSubtitle( $s );
 1266+
11751267 return true;
11761268 }
11771269 }
 1270+
11781271 return false;
11791272 }
11801273
@@ -1183,6 +1276,7 @@
11841277 */
11851278 public function showNamespaceHeader() {
11861279 global $wgOut;
 1280+
11871281 if ( $this->mTitle->isTalkPage() ) {
11881282 $msg = wfMsgNoTrans( 'talkpageheader' );
11891283 if ( $msg !== '-' && !wfEmptyMsg( 'talkpageheader', $msg ) ) {
@@ -1196,6 +1290,7 @@
11971291 */
11981292 public function showViewFooter() {
11991293 global $wgOut, $wgUseTrackbacks, $wgRequest;
 1294+
12001295 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
12011296 if ( $this->mTitle->getNamespace() == NS_USER_TALK && IP::isValid( $this->mTitle->getText() ) ) {
12021297 $wgOut->addWikiMsg( 'anontalkpagetext' );
@@ -1218,6 +1313,7 @@
12191314 */
12201315 public function showPatrolFooter() {
12211316 global $wgOut, $wgRequest, $wgUser;
 1317+
12221318 $rcid = $wgRequest->getVal( 'rcid' );
12231319
12241320 if ( !$rcid || !$this->mTitle->exists() || !$this->mTitle->quickUserCan( 'patrol' ) ) {
@@ -1258,6 +1354,7 @@
12591355 $rootPart = $parts[0];
12601356 $user = User::newFromName( $rootPart, false /* allow IP users*/ );
12611357 $ip = User::isIP( $rootPart );
 1358+
12621359 if ( !$user->isLoggedIn() && !$ip ) { # User does not exist
12631360 $wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
12641361 array( 'userpage-userdoesnotexist-view', $rootPart ) );
@@ -1278,7 +1375,9 @@
12791376 );
12801377 }
12811378 }
 1379+
12821380 wfRunHooks( 'ShowMissingArticle', array( $this ) );
 1381+
12831382 # Show delete and move logs
12841383 LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->mTitle->getPrefixedText(), '',
12851384 array( 'lim' => 10,
@@ -1301,36 +1400,42 @@
13021401 $editErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $wgUser );
13031402 $errors = array_merge( $createErrors, $editErrors );
13041403
1305 - if ( !count( $errors ) )
 1404+ if ( !count( $errors ) ) {
13061405 $text = wfMsgNoTrans( 'noarticletext' );
1307 - else
 1406+ } else {
13081407 $text = wfMsgNoTrans( 'noarticletext-nopermission' );
 1408+ }
13091409 }
13101410 $text = "<div class='noarticletext'>\n$text\n</div>";
 1411+
13111412 if ( !$this->hasViewableContent() ) {
13121413 // If there's no backing content, send a 404 Not Found
13131414 // for better machine handling of broken links.
13141415 $wgRequest->response()->header( "HTTP/1.x 404 Not Found" );
13151416 }
 1417+
13161418 $wgOut->addWikiText( $text );
13171419 }
13181420
13191421 /**
13201422 * If the revision requested for view is deleted, check permissions.
13211423 * Send either an error message or a warning header to $wgOut.
1322 - *
 1424+ *
13231425 * @return boolean true if the view is allowed, false if not.
13241426 */
13251427 public function showDeletedRevisionHeader() {
13261428 global $wgOut, $wgRequest;
 1429+
13271430 if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
13281431 // Not deleted
13291432 return true;
13301433 }
 1434+
13311435 // If the user is not allowed to see it...
13321436 if ( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) {
13331437 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
13341438 'rev-deleted-text-permission' );
 1439+
13351440 return false;
13361441 // If the user needs to confirm that they want to see it...
13371442 } else if ( $wgRequest->getInt( 'unhide' ) != 1 ) {
@@ -1341,12 +1446,14 @@
13421447 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
13431448 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
13441449 array( $msg, $link ) );
 1450+
13451451 return false;
13461452 // We are allowed to see...
13471453 } else {
13481454 $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
13491455 'rev-suppressed-text-view' : 'rev-deleted-text-view';
13501456 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
 1457+
13511458 return true;
13521459 }
13531460 }
@@ -1372,11 +1479,14 @@
13731480 */
13741481 public function doViewParse() {
13751482 global $wgOut;
 1483+
13761484 $oldid = $this->getOldID();
13771485 $useParserCache = $this->useParserCache( $oldid );
13781486 $parserOptions = clone $this->getParserOptions();
 1487+
13791488 # Render printable version, use printable version cache
13801489 $parserOptions->setIsPrintable( $wgOut->isPrintable() );
 1490+
13811491 # Don't show section-edit links on old revisions... this way lies madness.
13821492 $parserOptions->setEditSection( $this->isCurrent() );
13831493 $useParserCache = $this->useParserCache( $oldid );
@@ -1392,11 +1502,13 @@
13931503 * @return boolean
13941504 */
13951505 public function tryDirtyCache() {
 1506+
13961507 global $wgOut;
13971508 $parserCache = ParserCache::singleton();
13981509 $options = $this->getParserOptions();
13991510 $options->setIsPrintable( $wgOut->isPrintable() );
14001511 $output = $parserCache->getDirty( $this, $options );
 1512+
14011513 if ( $output ) {
14021514 wfDebug( __METHOD__ . ": sending dirty output\n" );
14031515 wfDebugLog( 'dirty', "dirty output " . $parserCache->getKey( $this, $options ) . "\n" );
@@ -1404,10 +1516,12 @@
14051517 $this->mParserOutput = $output;
14061518 $wgOut->addParserOutput( $output );
14071519 $wgOut->addHTML( "<!-- parser cache is expired, sending anyway due to pool overload-->\n" );
 1520+
14081521 return true;
14091522 } else {
14101523 wfDebugLog( 'dirty', "dirty missing\n" );
14111524 wfDebug( __METHOD__ . ": no dirty cache\n" );
 1525+
14121526 return false;
14131527 }
14141528 }
@@ -1418,6 +1532,7 @@
14191533 */
14201534 public function showPoolError( $status ) {
14211535 global $wgOut;
 1536+
14221537 $wgOut->clearHTML(); // for release() errors
14231538 $wgOut->enableClientCache( false );
14241539 $wgOut->setRobotPolicy( 'noindex,nofollow' );
@@ -1430,7 +1545,7 @@
14311546
14321547 /**
14331548 * View redirect
1434 - *
 1549+ *
14351550 * @param $target Title object or Array of destination(s) to redirect
14361551 * @param $appendSubtitle Boolean [optional]
14371552 * @param $forceKnown Boolean: should the image be shown as a bluelink regardless of existence?
@@ -1438,10 +1553,12 @@
14391554 */
14401555 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
14411556 global $wgOut, $wgContLang, $wgStylePath, $wgUser;
 1557+
14421558 # Display redirect
14431559 if ( !is_array( $target ) ) {
14441560 $target = array( $target );
14451561 }
 1562+
14461563 $imageDir = $wgContLang->getDir();
14471564 $imageUrl = $wgStylePath . '/common/images/redirect' . $imageDir . '.png';
14481565 $imageUrl2 = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
@@ -1450,9 +1567,11 @@
14511568 if ( $appendSubtitle ) {
14521569 $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) );
14531570 }
 1571+
14541572 $sk = $wgUser->getSkin();
14551573 // the loop prepends the arrow image before the link, so the first case needs to be outside
14561574 $title = array_shift( $target );
 1575+
14571576 if ( $forceKnown ) {
14581577 $link = $sk->link(
14591578 $title,
@@ -1464,7 +1583,8 @@
14651584 } else {
14661585 $link = $sk->link( $title, htmlspecialchars( $title->getFullText() ) );
14671586 }
1468 - // automatically append redirect=no to each link, since most of them are redirect pages themselves
 1587+
 1588+ // Automatically append redirect=no to each link, since most of them are redirect pages themselves.
14691589 foreach ( $target as $rt ) {
14701590 if ( $forceKnown ) {
14711591 $link .= '<img src="' . $imageUrl2 . '" alt="' . $alt2 . ' " />'
@@ -1480,9 +1600,9 @@
14811601 . $sk->link( $rt, htmlspecialchars( $rt->getFullText() ) );
14821602 }
14831603 }
 1604+
14841605 return '<img src="' . $imageUrl . '" alt="#REDIRECT " />' .
14851606 '<span class="redirectText">' . $link . '</span>';
1486 -
14871607 }
14881608
14891609 /**
@@ -1490,21 +1610,27 @@
14911611 */
14921612 public function addTrackbacks() {
14931613 global $wgOut, $wgUser;
 1614+
14941615 $dbr = wfGetDB( DB_SLAVE );
14951616 $tbs = $dbr->select( 'trackbacks',
14961617 array( 'tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name' ),
14971618 array( 'tb_page' => $this->getID() )
14981619 );
1499 - if ( !$dbr->numRows( $tbs ) ) return;
15001620
 1621+ if ( !$dbr->numRows( $tbs ) ) {
 1622+ return;
 1623+ }
 1624+
15011625 $tbtext = "";
15021626 while ( $o = $dbr->fetchObject( $tbs ) ) {
15031627 $rmvtxt = "";
 1628+
15041629 if ( $wgUser->isAllowed( 'trackback' ) ) {
15051630 $delurl = $this->mTitle->getFullURL( "action=deletetrackback&tbid=" .
15061631 $o->tb_id . "&token=" . urlencode( $wgUser->editToken() ) );
15071632 $rmvtxt = wfMsg( 'trackbackremove', htmlspecialchars( $delurl ) );
15081633 }
 1634+
15091635 $tbtext .= "\n";
15101636 $tbtext .= wfMsg( strlen( $o->tb_ex ) ? 'trackbackexcerpt' : 'trackback',
15111637 $o->tb_title,
@@ -1513,6 +1639,7 @@
15141640 $o->tb_name,
15151641 $rmvtxt );
15161642 }
 1643+
15171644 $wgOut->wrapWikiMsg( "<div id='mw_trackbacks'>\n$1\n</div>\n", array( 'trackbackbox', $tbtext ) );
15181645 }
15191646
@@ -1521,14 +1648,18 @@
15221649 */
15231650 public function deletetrackback() {
15241651 global $wgUser, $wgRequest, $wgOut;
 1652+
15251653 if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
15261654 $wgOut->addWikiMsg( 'sessionfailure' );
 1655+
15271656 return;
15281657 }
15291658
15301659 $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
 1660+
15311661 if ( count( $permission_errors ) ) {
15321662 $wgOut->showPermissionsErrorPage( $permission_errors );
 1663+
15331664 return;
15341665 }
15351666
@@ -1538,13 +1669,14 @@
15391670 $wgOut->addWikiMsg( 'trackbackdeleteok' );
15401671 $this->mTitle->invalidateCache();
15411672 }
1542 -
 1673+
15431674 /**
15441675 * Handle action=render
15451676 */
15461677
15471678 public function render() {
15481679 global $wgOut;
 1680+
15491681 $wgOut->setArticleBodyOnly( true );
15501682 $this->view();
15511683 }
@@ -1554,6 +1686,7 @@
15551687 */
15561688 public function purge() {
15571689 global $wgUser, $wgRequest, $wgOut;
 1690+
15581691 if ( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) {
15591692 if ( wfRunHooks( 'ArticlePurge', array( &$this ) ) ) {
15601693 $this->doPurge();
@@ -1578,6 +1711,7 @@
15791712 */
15801713 public function doPurge() {
15811714 global $wgUseSquid;
 1715+
15821716 // Invalidate the cache
15831717 $this->mTitle->invalidateCache();
15841718
@@ -1590,13 +1724,16 @@
15911725 $update = SquidUpdate::newSimplePurge( $this->mTitle );
15921726 $update->doUpdate();
15931727 }
 1728+
15941729 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
15951730 global $wgMessageCache;
 1731+
15961732 if ( $this->getID() == 0 ) {
15971733 $text = false;
15981734 } else {
15991735 $text = $this->getRawText();
16001736 }
 1737+
16011738 $wgMessageCache->replace( $this->mTitle->getDBkey(), $text );
16021739 }
16031740 }
@@ -1631,11 +1768,13 @@
16321769 ), __METHOD__, 'IGNORE' );
16331770
16341771 $affected = $dbw->affectedRows();
 1772+
16351773 if ( $affected ) {
16361774 $newid = $dbw->insertId();
16371775 $this->mTitle->resetArticleId( $newid );
16381776 }
16391777 wfProfileOut( __METHOD__ );
 1778+
16401779 return $affected ? $newid : false;
16411780 }
16421781
@@ -1661,6 +1800,7 @@
16621801 $rt = Title::newFromRedirect( $text );
16631802
16641803 $conditions = array( 'page_id' => $this->getId() );
 1804+
16651805 if ( !is_null( $lastRevision ) ) {
16661806 # An extra check against threads stepping on each other
16671807 $conditions['page_latest'] = $lastRevision;
@@ -1702,6 +1842,7 @@
17031843 // Update/Insert if we don't know if the last revision was a redirect or not
17041844 // Delete if changing from redirect to non-redirect
17051845 $isRedirect = !is_null( $redirectTitle );
 1846+
17061847 if ( $isRedirect || is_null( $lastRevIsRedirect ) || $lastRevIsRedirect !== $isRedirect ) {
17071848 wfProfileIn( __METHOD__ );
17081849 if ( $isRedirect ) {
@@ -1717,12 +1858,15 @@
17181859 $where = array( 'rd_from' => $this->getId() );
17191860 $dbw->delete( 'redirect', $where, __METHOD__ );
17201861 }
 1862+
17211863 if ( $this->getTitle()->getNamespace() == NS_FILE ) {
17221864 RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $this->getTitle() );
17231865 }
17241866 wfProfileOut( __METHOD__ );
 1867+
17251868 return ( $dbw->affectedRows() != 0 );
17261869 }
 1870+
17271871 return true;
17281872 }
17291873
@@ -1732,10 +1876,11 @@
17331877 *
17341878 * @param $dbw Database object
17351879 * @param $revision Revision object
1736 - * @return mixed
 1880+ * @return mixed
17371881 */
17381882 public function updateIfNewerOn( &$dbw, $revision ) {
17391883 wfProfileIn( __METHOD__ );
 1884+
17401885 $row = $dbw->selectRow(
17411886 array( 'revision', 'page' ),
17421887 array( 'rev_id', 'rev_timestamp', 'page_is_redirect' ),
@@ -1743,6 +1888,7 @@
17441889 'page_id' => $this->getId(),
17451890 'page_latest=rev_id' ),
17461891 __METHOD__ );
 1892+
17471893 if ( $row ) {
17481894 if ( wfTimestamp( TS_MW, $row->rev_timestamp ) >= $revision->getTimestamp() ) {
17491895 wfProfileOut( __METHOD__ );
@@ -1755,7 +1901,9 @@
17561902 $prev = 0;
17571903 $lastRevIsRedirect = null;
17581904 }
 1905+
17591906 $ret = $this->updateRevisionOn( $dbw, $revision, $prev, $lastRevIsRedirect );
 1907+
17601908 wfProfileOut( __METHOD__ );
17611909 return $ret;
17621910 }
@@ -1769,6 +1917,7 @@
17701918 */
17711919 public function replaceSection( $section, $text, $summary = '', $edittime = null ) {
17721920 wfProfileIn( __METHOD__ );
 1921+
17731922 if ( strval( $section ) == '' ) {
17741923 // Whole-page edit; let the whole text through
17751924 } else {
@@ -1778,11 +1927,13 @@
17791928 $dbw = wfGetDB( DB_MASTER );
17801929 $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime );
17811930 }
 1931+
17821932 if ( !$rev ) {
17831933 wfDebug( "Article::replaceSection asked for bogus section (page: " .
17841934 $this->getId() . "; section: $section; edittime: $edittime)\n" );
17851935 return null;
17861936 }
 1937+
17871938 $oldtext = $rev->getText();
17881939
17891940 if ( $section == 'new' ) {
@@ -1794,9 +1945,11 @@
17951946 } else {
17961947 # Replacing an existing section; roll out the big guns
17971948 global $wgParser;
 1949+
17981950 $text = $wgParser->replaceSection( $oldtext, $section, $text );
17991951 }
18001952 }
 1953+
18011954 wfProfileOut( __METHOD__ );
18021955 return $text;
18031956 }
@@ -1812,7 +1965,6 @@
18131966 ( $bot ? EDIT_FORCE_BOT : 0 );
18141967
18151968 $this->doEdit( $text, $summary, $flags, false, null, $watchthis, $comment, '', true );
1816 -
18171969 }
18181970
18191971 /**
@@ -1824,6 +1976,7 @@
18251977 ( $forceBot ? EDIT_FORCE_BOT : 0 );
18261978
18271979 $status = $this->doEdit( $text, $summary, $flags, false, null, $watchthis, false, $sectionanchor, true );
 1980+
18281981 if ( !$status->isOK() ) {
18291982 return false;
18301983 }
@@ -1847,6 +2000,7 @@
18482001
18492002 return $flags;
18502003 }
 2004+
18512005 /**
18522006 * Article::doEdit()
18532007 *
@@ -1919,7 +2073,7 @@
19202074 $this->loadPageData();
19212075
19222076 $flags = $this->checkFlags( $flags );
1923 -
 2077+
19242078 # If this is a comment, add the summary as headline
19252079 if ( $comment && $summary != "" ) {
19262080 $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" . $text;
@@ -1930,9 +2084,11 @@
19312085 {
19322086 wfDebug( __METHOD__ . ": ArticleSave hook aborted save!\n" );
19332087 wfProfileOut( __METHOD__ );
 2088+
19342089 if ( $status->isOK() ) {
19352090 $status->fatal( 'edit-hook-aborted' );
19362091 }
 2092+
19372093 return $status;
19382094 }
19392095
@@ -1959,6 +2115,7 @@
19602116 if ( $flags & EDIT_UPDATE ) {
19612117 # Update article, but only if changed.
19622118 $status->value['new'] = false;
 2119+
19632120 # Make sure the revision is either completely inserted or not inserted at all
19642121 if ( !$wgDBtransactions ) {
19652122 $userAbort = ignore_user_abort( true );
@@ -1977,6 +2134,7 @@
19782135 # Article gone missing
19792136 wfDebug( __METHOD__ . ": EDIT_UPDATE specified but article doesn't exist\n" );
19802137 $status->fatal( 'edit-gone-missing' );
 2138+
19812139 wfProfileOut( __METHOD__ );
19822140 return $status;
19832141 }
@@ -1989,7 +2147,7 @@
19902148 'parent_id' => $this->mLatest,
19912149 'user' => $user->getId(),
19922150 'user_text' => $user->getName(),
1993 - ) );
 2151+ ) );
19942152
19952153 $dbw->begin();
19962154 $revisionId = $revision->insertOn( $dbw );
@@ -2006,10 +2164,12 @@
20072165 if ( !$ok ) {
20082166 /* Belated edit conflict! Run away!! */
20092167 $status->fatal( 'edit-conflict' );
 2168+
20102169 # Delete the invalid revision if the DB is not transactional
20112170 if ( !$wgDBtransactions ) {
20122171 $dbw->delete( 'revision', array( 'rev_id' => $revisionId ), __METHOD__ );
20132172 }
 2173+
20142174 $revisionId = 0;
20152175 $dbw->rollback();
20162176 } else {
@@ -2024,6 +2184,7 @@
20252185 $this->mLatest, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
20262186 $revisionId, $patrolled
20272187 );
 2188+
20282189 # Log auto-patrolled edits
20292190 if ( $patrolled ) {
20302191 PatrolLog::record( $rc, true );
@@ -2045,6 +2206,7 @@
20462207 if ( !$wgDBtransactions ) {
20472208 ignore_user_abort( $userAbort );
20482209 }
 2210+
20492211 // Now that ignore_user_abort is restored, we can respond to fatal errors
20502212 if ( !$status->isOK() ) {
20512213 wfProfileOut( __METHOD__ );
@@ -2075,6 +2237,7 @@
20762238 if ( $newid === false ) {
20772239 $dbw->rollback();
20782240 $status->fatal( 'edit-already-exists' );
 2241+
20792242 wfProfileOut( __METHOD__ );
20802243 return $status;
20812244 }
@@ -2096,14 +2259,17 @@
20972260 $this->updateRevisionOn( $dbw, $revision, 0 );
20982261
20992262 wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, false, $user ) );
 2263+
21002264 # Update recentchanges
21012265 if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
21022266 global $wgUseRCPatrol, $wgUseNPPatrol;
 2267+
21032268 # Mark as patrolled if the user can do so
21042269 $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) && $this->mTitle->userCan( 'autopatrol' );
21052270 # Add RC row to the DB
21062271 $rc = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $user, $summary, $bot,
21072272 '', strlen( $text ), $revisionId, $patrolled );
 2273+
21082274 # Log auto-patrolled edits
21092275 if ( $patrolled ) {
21102276 PatrolLog::record( $rc, true );
@@ -2133,7 +2299,7 @@
21342300 wfRunHooks( 'ArticleSaveComplete', array( &$this, &$user, $text, $summary,
21352301 $flags & EDIT_MINOR, &$watchthis, null, &$flags, $revision, &$status, $baseRevId,
21362302 &$redirect) );
2137 -
 2303+
21382304 # Watch or unwatch the page
21392305 if ( $watchthis === true ) {
21402306 if ( !$this->mTitle->userIsWatching() ) {
@@ -2148,10 +2314,12 @@
21492315 $dbw->commit();
21502316 }
21512317 }
2152 -
 2318+
21532319 # Give extensions a chance to modify URL query on update
2154 - $extraQuery = '';
 2320+ $extraQuery = '';
 2321+
21552322 wfRunHooks( 'ArticleUpdateBeforeRedirect', array( $this, &$sectionanchor, &$extraQuery ) );
 2323+
21562324 if ( $redirect ) {
21572325 if ( $sectionanchor || $extraQuery ) {
21582326 $this->doRedirect( $this->isRedirect( $text ), $sectionanchor, $extraQuery );
@@ -2159,9 +2327,9 @@
21602328 $this->doRedirect( $this->isRedirect( $text ) );
21612329 }
21622330 }
2163 -
 2331+
21642332 wfProfileOut( __METHOD__ );
2165 -
 2333+
21662334 return $status;
21672335 }
21682336
@@ -2183,6 +2351,7 @@
21842352 */
21852353 public function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) {
21862354 global $wgOut;
 2355+
21872356 if ( $noRedir ) {
21882357 $query = 'redirect=no';
21892358 if ( $extraQuery )
@@ -2190,6 +2359,7 @@
21912360 } else {
21922361 $query = $extraQuery;
21932362 }
 2363+
21942364 $wgOut->redirect( $this->mTitle->getFullURL( $query ) . $sectionAnchor );
21952365 }
21962366
@@ -2198,11 +2368,13 @@
21992369 */
22002370 public function markpatrolled() {
22012371 global $wgOut, $wgRequest, $wgUseRCPatrol, $wgUseNPPatrol, $wgUser;
 2372+
22022373 $wgOut->setRobotPolicy( 'noindex,nofollow' );
22032374
22042375 # If we haven't been given an rc_id value, we can't do anything
22052376 $rcid = (int) $wgRequest->getVal( 'rcid' );
22062377 $rc = RecentChange::newFromId( $rcid );
 2378+
22072379 if ( is_null( $rc ) ) {
22082380 $wgOut->showErrorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
22092381 return;
@@ -2217,6 +2389,7 @@
22182390
22192391 if ( in_array( array( 'rcpatroldisabled' ), $errors ) ) {
22202392 $wgOut->showErrorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
 2393+
22212394 return;
22222395 }
22232396
@@ -2229,11 +2402,13 @@
22302403 $wgOut->setPageTitle( wfMsg( 'markedaspatrollederror' ) );
22312404 $wgOut->addWikiMsg( 'markedaspatrollederror-noautopatrol' );
22322405 $wgOut->returnToMain( false, $return );
 2406+
22332407 return;
22342408 }
22352409
22362410 if ( !empty( $errors ) ) {
22372411 $wgOut->showPermissionsErrorPage( $errors );
 2412+
22382413 return;
22392414 }
22402415
@@ -2248,19 +2423,23 @@
22492424 */
22502425 public function watch() {
22512426 global $wgUser, $wgOut;
 2427+
22522428 if ( $wgUser->isAnon() ) {
22532429 $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
22542430 return;
22552431 }
 2432+
22562433 if ( wfReadOnly() ) {
22572434 $wgOut->readOnlyPage();
22582435 return;
22592436 }
 2437+
22602438 if ( $this->doWatch() ) {
22612439 $wgOut->setPagetitle( wfMsg( 'addedwatch' ) );
22622440 $wgOut->setRobotPolicy( 'noindex,nofollow' );
22632441 $wgOut->addWikiMsg( 'addedwatchtext', $this->mTitle->getPrefixedText() );
22642442 }
 2443+
22652444 $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );
22662445 }
22672446
@@ -2270,13 +2449,16 @@
22712450 */
22722451 public function doWatch() {
22732452 global $wgUser;
 2453+
22742454 if ( $wgUser->isAnon() ) {
22752455 return false;
22762456 }
 2457+
22772458 if ( wfRunHooks( 'WatchArticle', array( &$wgUser, &$this ) ) ) {
22782459 $wgUser->addWatch( $this->mTitle );
22792460 return wfRunHooks( 'WatchArticleComplete', array( &$wgUser, &$this ) );
22802461 }
 2462+
22812463 return false;
22822464 }
22832465
@@ -2285,19 +2467,23 @@
22862468 */
22872469 public function unwatch() {
22882470 global $wgUser, $wgOut;
 2471+
22892472 if ( $wgUser->isAnon() ) {
22902473 $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
22912474 return;
22922475 }
 2476+
22932477 if ( wfReadOnly() ) {
22942478 $wgOut->readOnlyPage();
22952479 return;
22962480 }
 2481+
22972482 if ( $this->doUnwatch() ) {
22982483 $wgOut->setPagetitle( wfMsg( 'removedwatch' ) );
22992484 $wgOut->setRobotPolicy( 'noindex,nofollow' );
23002485 $wgOut->addWikiMsg( 'removedwatchtext', $this->mTitle->getPrefixedText() );
23012486 }
 2487+
23022488 $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );
23032489 }
23042490
@@ -2307,13 +2493,16 @@
23082494 */
23092495 public function doUnwatch() {
23102496 global $wgUser;
 2497+
23112498 if ( $wgUser->isAnon() ) {
23122499 return false;
23132500 }
 2501+
23142502 if ( wfRunHooks( 'UnwatchArticle', array( &$wgUser, &$this ) ) ) {
23152503 $wgUser->removeWatch( $this->mTitle );
23162504 return wfRunHooks( 'UnwatchArticleComplete', array( &$wgUser, &$this ) );
23172505 }
 2506+
23182507 return false;
23192508 }
23202509
@@ -2347,6 +2536,7 @@
23482537 $restrictionTypes = $this->mTitle->getRestrictionTypes();
23492538
23502539 $id = $this->mTitle->getArticleID();
 2540+
23512541 if ( $id <= 0 ) {
23522542 wfDebug( "updateRestrictions failed: $id <= 0\n" );
23532543 return false;
@@ -2374,6 +2564,7 @@
23752565 $current = array();
23762566 $updated = Article::flattenRestrictions( $limit );
23772567 $changed = false;
 2568+
23782569 foreach ( $restrictionTypes as $action ) {
23792570 if ( isset( $expiry[$action] ) ) {
23802571 # Get current restrictions on $action
@@ -2381,6 +2572,7 @@
23822573 $current[$action] = implode( '', $aLimits );
23832574 # Are any actual restrictions being dealt with here?
23842575 $aRChanged = count( $aLimits ) || !empty( $limit[$action] );
 2576+
23852577 # If something changed, we need to log it. Checking $aRChanged
23862578 # assures that "unprotecting" a page that is not protected does
23872579 # not log just because the expiry was "changed".
@@ -2399,36 +2591,42 @@
24002592 # If nothing's changed, do nothing
24012593 if ( $changed ) {
24022594 if ( wfRunHooks( 'ArticleProtect', array( &$this, &$wgUser, $limit, $reason ) ) ) {
2403 -
24042595 $dbw = wfGetDB( DB_MASTER );
24052596
24062597 # Prepare a null revision to be added to the history
24072598 $modified = $current != '' && $protect;
 2599+
24082600 if ( $protect ) {
24092601 $comment_type = $modified ? 'modifiedarticleprotection' : 'protectedarticle';
24102602 } else {
24112603 $comment_type = 'unprotectedarticle';
24122604 }
 2605+
24132606 $comment = $wgContLang->ucfirst( wfMsgForContent( $comment_type, $this->mTitle->getPrefixedText() ) );
24142607
24152608 # Only restrictions with the 'protect' right can cascade...
24162609 # Otherwise, people who cannot normally protect can "protect" pages via transclusion
24172610 $editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' );
 2611+
24182612 # The schema allows multiple restrictions
2419 - if ( !in_array( 'protect', $editrestriction ) && !in_array( 'sysop', $editrestriction ) )
 2613+ if ( !in_array( 'protect', $editrestriction ) && !in_array( 'sysop', $editrestriction ) ) {
24202614 $cascade = false;
 2615+ }
 2616+
24212617 $cascade_description = '';
 2618+
24222619 if ( $cascade ) {
24232620 $cascade_description = ' [' . wfMsgForContent( 'protect-summary-cascade' ) . ']';
24242621 }
24252622
2426 - if ( $reason )
 2623+ if ( $reason ) {
24272624 $comment .= ": $reason";
 2625+ }
24282626
24292627 $editComment = $comment;
24302628 $encodedExpiry = array();
24312629 $protect_description = '';
2432 - foreach ( $limit as $action => $restrictions ) {
 2630+ foreach ( $limit as $action => $restrictions ) {
24332631 if ( !isset( $expiry[$action] ) )
24342632 $expiry[$action] = 'infinite';
24352633
@@ -2443,15 +2641,20 @@
24442642 } else {
24452643 $protect_description .= wfMsgForContent( 'protect-expiry-indefinite' );
24462644 }
 2645+
24472646 $protect_description .= ') ';
24482647 }
24492648 }
24502649 $protect_description = trim( $protect_description );
24512650
2452 - if ( $protect_description && $protect )
 2651+ if ( $protect_description && $protect ) {
24532652 $editComment .= " ($protect_description)";
2454 - if ( $cascade )
 2653+ }
 2654+
 2655+ if ( $cascade ) {
24552656 $editComment .= "$cascade_description";
 2657+ }
 2658+
24562659 # Update restrictions table
24572660 foreach ( $limit as $action => $restrictions ) {
24582661 if ( $restrictions != '' ) {
@@ -2460,7 +2663,10 @@
24612664 'pr_type' => $action,
24622665 'pr_level' => $restrictions,
24632666 'pr_cascade' => ( $cascade && $action == 'edit' ) ? 1 : 0,
2464 - 'pr_expiry' => $encodedExpiry[$action] ), __METHOD__ );
 2667+ 'pr_expiry' => $encodedExpiry[$action]
 2668+ ),
 2669+ __METHOD__
 2670+ );
24652671 } else {
24662672 $dbw->delete( 'page_restrictions', array( 'pr_page' => $id,
24672673 'pr_type' => $action ), __METHOD__ );
@@ -2494,7 +2700,6 @@
24952701 } else {
24962702 $log->addEntry( 'unprotect', $this->mTitle, $reason );
24972703 }
2498 -
24992704 } # End hook
25002705 } # End "changed" check
25012706
@@ -2511,38 +2716,46 @@
25122717 if ( !is_array( $limit ) ) {
25132718 throw new MWException( 'Article::flattenRestrictions given non-array restriction set' );
25142719 }
 2720+
25152721 $bits = array();
25162722 ksort( $limit );
 2723+
25172724 foreach ( $limit as $action => $restrictions ) {
25182725 if ( $restrictions != '' ) {
25192726 $bits[] = "$action=$restrictions";
25202727 }
25212728 }
 2729+
25222730 return implode( ':', $bits );
25232731 }
25242732
25252733 /**
25262734 * Auto-generates a deletion reason
2527 - *
 2735+ *
25282736 * @param &$hasHistory Boolean: whether the page has a history
25292737 * @return mixed String containing deletion reason or empty string, or boolean false
25302738 * if no revision occurred
25312739 */
25322740 public function generateReason( &$hasHistory ) {
25332741 global $wgContLang;
 2742+
25342743 $dbw = wfGetDB( DB_MASTER );
25352744 // Get the last revision
25362745 $rev = Revision::newFromTitle( $this->mTitle );
2537 - if ( is_null( $rev ) )
 2746+
 2747+ if ( is_null( $rev ) ) {
25382748 return false;
 2749+ }
25392750
25402751 // Get the article's contents
25412752 $contents = $rev->getText();
25422753 $blank = false;
 2754+
25432755 // If the page is blank, use the text from the previous revision,
25442756 // which can only be blank if there's a move/import/protect dummy revision involved
25452757 if ( $contents == '' ) {
25462758 $prev = $rev->getPrevious();
 2759+
25472760 if ( $prev ) {
25482761 $contents = $prev->getText();
25492762 $blank = true;
@@ -2556,12 +2769,15 @@
25572770 __METHOD__,
25582771 array( 'LIMIT' => 20 )
25592772 );
2560 - if ( $res === false )
 2773+
 2774+ if ( $res === false ) {
25612775 // This page has no revisions, which is very weird
25622776 return false;
 2777+ }
25632778
25642779 $hasHistory = ( $res->numRows() > 1 );
25652780 $row = $dbw->fetchObject( $res );
 2781+
25662782 if ( $row ) { // $row is false if the only contributor is hidden
25672783 $onlyAuthor = $row->rev_user_text;
25682784 // Try to find a second contributor
@@ -2574,6 +2790,7 @@
25752791 } else {
25762792 $onlyAuthor = false;
25772793 }
 2794+
25782795 $dbw->freeResult( $res );
25792796
25802797 // Generate the summary with a '$1' placeholder
@@ -2582,10 +2799,11 @@
25832800 // blank. It's just not our lucky day
25842801 $reason = wfMsgForContent( 'exbeforeblank', '$1' );
25852802 } else {
2586 - if ( $onlyAuthor )
 2803+ if ( $onlyAuthor ) {
25872804 $reason = wfMsgForContent( 'excontentauthor', '$1', $onlyAuthor );
2588 - else
 2805+ } else {
25892806 $reason = wfMsgForContent( 'excontent', '$1' );
 2807+ }
25902808 }
25912809
25922810 if ( $reason == '-' ) {
@@ -2603,6 +2821,7 @@
26042822 $contents = preg_replace( '/\[\[([^\]]*)\]?$/', '$1', $contents );
26052823 // Now replace the '$1' placeholder
26062824 $reason = str_replace( '$1', $contents, $reason );
 2825+
26072826 return $reason;
26082827 }
26092828
@@ -2627,6 +2846,7 @@
26282847 } elseif ( $reason == 'other' ) {
26292848 $reason = $this->DeleteReason;
26302849 }
 2850+
26312851 # Flag to hide all contents of the archived revisions
26322852 $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgUser->isAllowed( 'suppressrevision' );
26332853
@@ -2635,6 +2855,7 @@
26362856 # Read-only check...
26372857 if ( wfReadOnly() ) {
26382858 $wgOut->readOnlyPage();
 2859+
26392860 return;
26402861 }
26412862
@@ -2643,6 +2864,7 @@
26442865
26452866 if ( count( $permission_errors ) > 0 ) {
26462867 $wgOut->showPermissionsErrorPage( $permission_errors );
 2868+
26472869 return;
26482870 }
26492871
@@ -2666,6 +2888,7 @@
26672889 'delete',
26682890 $this->mTitle->getPrefixedText()
26692891 );
 2892+
26702893 return;
26712894 }
26722895
@@ -2673,28 +2896,35 @@
26742897 $bigHistory = $this->isBigDeletion();
26752898 if ( $bigHistory && !$this->mTitle->userCan( 'bigdelete' ) ) {
26762899 global $wgLang, $wgDeleteRevisionsLimit;
 2900+
26772901 $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
26782902 array( 'delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
 2903+
26792904 return;
26802905 }
26812906
26822907 if ( $confirm ) {
26832908 $this->doDelete( $reason, $suppress );
 2909+
26842910 if ( $wgRequest->getCheck( 'wpWatch' ) && $wgUser->isLoggedIn() ) {
26852911 $this->doWatch();
26862912 } elseif ( $this->mTitle->userIsWatching() ) {
26872913 $this->doUnwatch();
26882914 }
 2915+
26892916 return;
26902917 }
26912918
26922919 // Generate deletion reason
26932920 $hasHistory = false;
2694 - if ( !$reason ) $reason = $this->generateReason( $hasHistory );
 2921+ if ( !$reason ) {
 2922+ $reason = $this->generateReason( $hasHistory );
 2923+ }
26952924
26962925 // If the page has a history, insert a warning
26972926 if ( $hasHistory && !$confirm ) {
26982927 global $wgLang;
 2928+
26992929 $skin = $wgUser->getSkin();
27002930 $revisions = $this->estimateRevisionCount();
27012931 $wgOut->addHTML( '<strong class="mw-delete-warning-revisions">' .
@@ -2702,8 +2932,10 @@
27032933 wfMsgHtml( 'word-separator' ) . $skin->historyLink() .
27042934 '</strong>'
27052935 );
 2936+
27062937 if ( $bigHistory ) {
27072938 global $wgDeleteRevisionsLimit;
 2939+
27082940 $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
27092941 array( 'delete-warning-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
27102942 }
@@ -2717,10 +2949,13 @@
27182950 */
27192951 public function isBigDeletion() {
27202952 global $wgDeleteRevisionsLimit;
 2953+
27212954 if ( $wgDeleteRevisionsLimit ) {
27222955 $revCount = $this->estimateRevisionCount();
 2956+
27232957 return $revCount > $wgDeleteRevisionsLimit;
27242958 }
 2959+
27252960 return false;
27262961 }
27272962
@@ -2729,6 +2964,7 @@
27302965 */
27312966 public function estimateRevisionCount() {
27322967 $dbr = wfGetDB( DB_SLAVE );
 2968+
27332969 // For an exact count...
27342970 // return $dbr->selectField( 'revision', 'COUNT(*)',
27352971 // array( 'rev_page' => $this->getId() ), __METHOD__ );
@@ -2748,6 +2984,7 @@
27492985 // If that doesn't have the latest revision, try the master
27502986 $continue = 2;
27512987 $db = wfGetDB( DB_SLAVE );
 2988+
27522989 do {
27532990 $res = $db->select( array( 'page', 'revision' ),
27542991 array( 'rev_id', 'rev_user_text' ),
@@ -2760,11 +2997,14 @@
27612998 'LIMIT' => $num
27622999 ) )
27633000 );
 3001+
27643002 if ( !$res ) {
27653003 wfProfileOut( __METHOD__ );
27663004 return array();
27673005 }
 3006+
27683007 $row = $db->fetchObject( $res );
 3008+
27693009 if ( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) {
27703010 $db = wfGetDB( DB_MASTER );
27713011 $continue--;
@@ -2774,9 +3014,11 @@
27753015 } while ( $continue );
27763016
27773017 $authors = array( $row->rev_user_text );
 3018+
27783019 while ( $row = $db->fetchObject( $res ) ) {
27793020 $authors[] = $row->rev_user_text;
27803021 }
 3022+
27813023 wfProfileOut( __METHOD__ );
27823024 return $authors;
27833025 }
@@ -2845,6 +3087,7 @@
28463088 ) ) .
28473089 "</td>
28483090 </tr>";
 3091+
28493092 # Disallow watching if user is not logged in
28503093 if ( $wgUser->isLoggedIn() ) {
28513094 $form .= "
@@ -2856,6 +3099,7 @@
28573100 "</td>
28583101 </tr>";
28593102 }
 3103+
28603104 $form .= "
28613105 $suppress
28623106 <tr>
@@ -2896,6 +3140,7 @@
28973141 */
28983142 public function doDelete( $reason, $suppress = false ) {
28993143 global $wgOut, $wgUser;
 3144+
29003145 $id = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
29013146
29023147 $error = '';
@@ -2921,7 +3166,9 @@
29223167 wfMsgExt( 'cannotdelete', array( 'parse' ), $this->mTitle->getPrefixedText() )
29233168 )
29243169 );
 3170+
29253171 $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
 3172+
29263173 LogEventsList::showLogExtract(
29273174 $wgOut,
29283175 'delete',
@@ -3016,6 +3263,7 @@
30173264 # Now that it's safely backed up, delete it
30183265 $dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__ );
30193266 $ok = ( $dbw->affectedRows() > 0 ); // getArticleId() uses slave, could be laggy
 3267+
30203268 if ( !$ok ) {
30213269 $dbw->rollback();
30223270 return false;
@@ -3024,9 +3272,11 @@
30253273 # Fix category table counts
30263274 $cats = array();
30273275 $res = $dbw->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__ );
 3276+
30283277 foreach ( $res as $row ) {
30293278 $cats [] = $row->cl_to;
30303279 }
 3280+
30313281 $this->updateCategoryCounts( array(), $cats );
30323282
30333283 # If using cascading deletes, we can skip some explicit deletes
@@ -3102,6 +3352,7 @@
31033353 */
31043354 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails ) {
31053355 global $wgUser;
 3356+
31063357 $resultDetails = null;
31073358
31083359 # Check permissions
@@ -3109,15 +3360,18 @@
31103361 $rollbackErrors = $this->mTitle->getUserPermissionsErrors( 'rollback', $wgUser );
31113362 $errors = array_merge( $editErrors, wfArrayDiff2( $rollbackErrors, $editErrors ) );
31123363
3113 - if ( !$wgUser->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) )
 3364+ if ( !$wgUser->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) ) {
31143365 $errors[] = array( 'sessionfailure' );
 3366+ }
31153367
31163368 if ( $wgUser->pingLimiter( 'rollback' ) || $wgUser->pingLimiter() ) {
31173369 $errors[] = array( 'actionthrottledtext' );
31183370 }
 3371+
31193372 # If there were errors, bail out now
3120 - if ( !empty( $errors ) )
 3373+ if ( !empty( $errors ) ) {
31213374 return $errors;
 3375+ }
31223376
31233377 return $this->commitRollback( $fromP, $summary, $bot, $resultDetails );
31243378 }
@@ -3133,6 +3387,7 @@
31343388 */
31353389 public function commitRollback( $fromP, $summary, $bot, &$resultDetails ) {
31363390 global $wgUseRCPatrol, $wgUser, $wgLang;
 3391+
31373392 $dbw = wfGetDB( DB_MASTER );
31383393
31393394 if ( wfReadOnly() ) {
@@ -3168,7 +3423,7 @@
31693424 "rev_user != {$user} OR rev_user_text != {$user_text}"
31703425 ), __METHOD__,
31713426 array( 'USE INDEX' => 'page_timestamp',
3172 - 'ORDER BY' => 'rev_timestamp DESC' )
 3427+ 'ORDER BY' => 'rev_timestamp DESC' )
31733428 );
31743429 if ( $s === false ) {
31753430 # No one else ever edited this page
@@ -3183,6 +3438,7 @@
31843439 # Mark all reverted edits as bot
31853440 $set['rc_bot'] = 1;
31863441 }
 3442+
31873443 if ( $wgUseRCPatrol ) {
31883444 # Mark all reverted edits as patrolled
31893445 $set['rc_patrolled'] = 1;
@@ -3219,11 +3475,14 @@
32203476 # Save
32213477 $flags = EDIT_UPDATE;
32223478
3223 - if ( $wgUser->isAllowed( 'minoredit' ) )
 3479+ if ( $wgUser->isAllowed( 'minoredit' ) ) {
32243480 $flags |= EDIT_MINOR;
 3481+ }
32253482
3226 - if ( $bot && ( $wgUser->isAllowed( 'markbotedits' ) || $wgUser->isAllowed( 'bot' ) ) )
 3483+ if ( $bot && ( $wgUser->isAllowed( 'markbotedits' ) || $wgUser->isAllowed( 'bot' ) ) ) {
32273484 $flags |= EDIT_FORCE_BOT;
 3485+ }
 3486+
32283487 # Actually store the edit
32293488 $status = $this->doEdit( $target->getText(), $summary, $flags, $target->getId() );
32303489 if ( !empty( $status->value['revision'] ) ) {
@@ -3240,6 +3499,7 @@
32413500 'target' => $target,
32423501 'newid' => $revId
32433502 );
 3503+
32443504 return array();
32453505 }
32463506
@@ -3248,6 +3508,7 @@
32493509 */
32503510 public function rollback() {
32513511 global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol;
 3512+
32523513 $details = null;
32533514
32543515 $result = $this->doRollback(
@@ -3262,26 +3523,31 @@
32633524 $wgOut->rateLimited();
32643525 return;
32653526 }
 3527+
32663528 if ( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) {
32673529 $wgOut->setPageTitle( wfMsg( 'rollbackfailed' ) );
32683530 $errArray = $result[0];
32693531 $errMsg = array_shift( $errArray );
32703532 $wgOut->addWikiMsgArray( $errMsg, $errArray );
 3533+
32713534 if ( isset( $details['current'] ) ) {
32723535 $current = $details['current'];
 3536+
32733537 if ( $current->getComment() != '' ) {
32743538 $wgOut->addWikiMsgArray( 'editcomment', array(
32753539 $wgUser->getSkin()->formatComment( $current->getComment() ) ), array( 'replaceafter' ) );
32763540 }
32773541 }
 3542+
32783543 return;
32793544 }
 3545+
32803546 # Display permissions errors before read-only message -- there's no
32813547 # point in misleading the user into thinking the inability to rollback
32823548 # is only temporary.
32833549 if ( !empty( $result ) && $result !== array( array( 'readonlytext' ) ) ) {
3284 - # array_diff is completely broken for arrays of arrays, sigh. Re-
3285 - # move any 'readonlytext' error manually.
 3550+ # array_diff is completely broken for arrays of arrays, sigh.
 3551+ # Remove any 'readonlytext' error manually.
32863552 $out = array();
32873553 foreach ( $result as $error ) {
32883554 if ( $error != array( 'readonlytext' ) ) {
@@ -3289,10 +3555,13 @@
32903556 }
32913557 }
32923558 $wgOut->showPermissionsErrorPage( $out );
 3559+
32933560 return;
32943561 }
 3562+
32953563 if ( $result == array( array( 'readonlytext' ) ) ) {
32963564 $wgOut->readOnlyPage();
 3565+
32973566 return;
32983567 }
32993568
@@ -3301,12 +3570,14 @@
33023571 $newId = $details['newid'];
33033572 $wgOut->setPageTitle( wfMsg( 'actioncomplete' ) );
33043573 $wgOut->setRobotPolicy( 'noindex,nofollow' );
 3574+
33053575 if ( $current->getUserText() === '' ) {
33063576 $old = wfMsg( 'rev-deleted-user' );
33073577 } else {
33083578 $old = $wgUser->getSkin()->userLink( $current->getUser(), $current->getUserText() )
33093579 . $wgUser->getSkin()->userToolLinks( $current->getUser(), $current->getUserText() );
33103580 }
 3581+
33113582 $new = $wgUser->getSkin()->userLink( $target->getUser(), $target->getUserText() )
33123583 . $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() );
33133584 $wgOut->addHTML( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
@@ -3318,7 +3589,6 @@
33193590 }
33203591 }
33213592
3322 -
33233593 /**
33243594 * Do standard deferred updates after page view
33253595 */
@@ -3327,12 +3597,14 @@
33283598 if ( wfReadOnly() ) {
33293599 return;
33303600 }
 3601+
33313602 # Don't update page view counters on views from bot users (bug 14044)
33323603 if ( !$wgDisableCounters && !$wgUser->isAllowed( 'bot' ) && $this->getID() ) {
33333604 Article::incViewCount( $this->getID() );
33343605 $u = new SiteStatsUpdate( 1, 0, 0 );
33353606 array_push( $wgDeferredUpdateList, $u );
33363607 }
 3608+
33373609 # Update newtalk / watchlist notification status
33383610 $wgUser->clearNotification( $this->mTitle );
33393611 }
@@ -3346,7 +3618,9 @@
33473619 // Already prepared
33483620 return $this->mPreparedEdit;
33493621 }
 3622+
33503623 global $wgParser;
 3624+
33513625 $edit = (object)array();
33523626 $edit->revid = $revid;
33533627 $edit->newText = $text;
@@ -3354,7 +3628,9 @@
33553629 $options = $this->getParserOptions();
33563630 $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $options, true, true, $revid );
33573631 $edit->oldText = $this->getContent();
 3632+
33583633 $this->mPreparedEdit = $edit;
 3634+
33593635 return $edit;
33603636 }
33613637
@@ -3405,10 +3681,12 @@
34063682 // Flush old entries from the `recentchanges` table; we do this on
34073683 // random requests so as to avoid an increase in writes for no good reason
34083684 global $wgRCMaxAge;
 3685+
34093686 $dbw = wfGetDB( DB_MASTER );
34103687 $cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
34113688 $recentchanges = $dbw->tableName( 'recentchanges' );
34123689 $sql = "DELETE FROM $recentchanges WHERE rc_timestamp < '{$cutoff}'";
 3690+
34133691 $dbw->query( $sql );
34143692 }
34153693 }
@@ -3432,7 +3710,8 @@
34333711 # load of user talk pages and piss people off, nor if it's a minor edit
34343712 # by a properly-flagged bot.
34353713 if ( $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getTitleKey() && $changed
3436 - && !( $minoredit && $wgUser->isAllowed( 'nominornewtalk' ) ) ) {
 3714+ && !( $minoredit && $wgUser->isAllowed( 'nominornewtalk' ) )
 3715+ ) {
34373716 if ( wfRunHooks( 'ArticleEditUpdateNewTalk', array( &$this ) ) ) {
34383717 $other = User::newFromName( $shortTitle, false );
34393718 if ( !$other ) {
@@ -3487,11 +3766,13 @@
34883767 }
34893768
34903769 $unhide = $wgRequest->getInt( 'unhide' ) == 1;
 3770+
34913771 # Cascade unhide param in links for easy deletion browsing
34923772 $extraParams = array();
34933773 if ( $wgRequest->getVal( 'unhide' ) ) {
34943774 $extraParams['unhide'] = 1;
34953775 }
 3776+
34963777 $revision = Revision::newFromId( $oldid );
34973778
34983779 $current = ( $oldid == $this->mLatest );
@@ -3571,6 +3852,7 @@
35723853 );
35733854
35743855 $cdel = '';
 3856+
35753857 // User can delete revisions or view deleted revisions...
35763858 $canHide = $wgUser->isAllowed( 'deleterevision' );
35773859 if ( $canHide || ( $revision->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) ) {
@@ -3609,6 +3891,7 @@
36103892 "</div>\n" .
36113893 "\n\t\t\t\t<div id=\"mw-revision-nav\">" . $cdel . wfMsgExt( 'revision-nav', array( 'escapenoentities', 'parsemag', 'replaceafter' ),
36123894 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>\n\t\t\t";
 3895+
36133896 $wgOut->setSubtitle( $r );
36143897 }
36153898
@@ -3622,6 +3905,7 @@
36233906 */
36243907 public function preSaveTransform( $text ) {
36253908 global $wgParser, $wgUser;
 3909+
36263910 return $wgParser->preSaveTransform( $text, $this->mTitle, $wgUser, ParserOptions::newFromUser( $wgUser ) );
36273911 }
36283912
@@ -3636,10 +3920,12 @@
36373921 */
36383922 protected function tryFileCache() {
36393923 static $called = false;
 3924+
36403925 if ( $called ) {
36413926 wfDebug( "Article::tryFileCache(): called twice!?\n" );
36423927 return false;
36433928 }
 3929+
36443930 $called = true;
36453931 if ( $this->isFileCacheable() ) {
36463932 $cache = new HTMLFileCache( $this->mTitle );
@@ -3654,6 +3940,7 @@
36553941 } else {
36563942 wfDebug( "Article::tryFileCache(): not cacheable\n" );
36573943 }
 3944+
36583945 return false;
36593946 }
36603947
@@ -3663,6 +3950,7 @@
36643951 */
36653952 public function isFileCacheable() {
36663953 $cacheable = false;
 3954+
36673955 if ( HTMLFileCache::useFileCache() ) {
36683956 $cacheable = $this->getID() && !$this->mRedirectedFrom;
36693957 // Extension may have reason to disable file caching on some pages.
@@ -3670,6 +3958,7 @@
36713959 $cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) );
36723960 }
36733961 }
 3962+
36743963 return $cacheable;
36753964 }
36763965
@@ -3681,6 +3970,7 @@
36823971 if ( !$this->mDataLoaded ) {
36833972 $this->loadPageData();
36843973 }
 3974+
36853975 return !$this->mIsRedirect;
36863976 }
36873977
@@ -3693,6 +3983,7 @@
36943984 if ( !$this->mDataLoaded ) {
36953985 $this->loadPageData();
36963986 }
 3987+
36973988 return $this->mTouched;
36983989 }
36993990
@@ -3704,6 +3995,7 @@
37053996 if ( !$this->mDataLoaded ) {
37063997 $this->loadPageData();
37073998 }
 3999+
37084000 return (int)$this->mLatest;
37094001 }
37104002
@@ -3741,6 +4033,7 @@
37424034 */
37434035 public static function incViewCount( $id ) {
37444036 $id = intval( $id );
 4037+
37454038 global $wgHitcounterUpdateFreq;
37464039
37474040 $dbw = wfGetDB( DB_MASTER );
@@ -3750,6 +4043,7 @@
37514044
37524045 if ( $wgHitcounterUpdateFreq <= 1 ) {
37534046 $dbw->query( "UPDATE $pageTable SET page_counter = page_counter + 1 WHERE page_id = $id" );
 4047+
37544048 return;
37554049 }
37564050
@@ -3762,12 +4056,14 @@
37634057 if ( ( rand() % $checkfreq != 0 ) or ( $dbw->lastErrno() != 0 ) ) {
37644058 # Most of the time (or on SQL errors), skip row count check
37654059 $dbw->ignoreErrors( $oldignore );
 4060+
37664061 return;
37674062 }
37684063
37694064 $res = $dbw->query( "SELECT COUNT(*) as n FROM $hitcounterTable" );
37704065 $row = $dbw->fetchObject( $res );
37714066 $rown = intval( $row->n );
 4067+
37724068 if ( $rown >= $wgHitcounterUpdateFreq ) {
37734069 wfProfileIn( 'Article::incViewCount-collect' );
37744070 $old_user_abort = ignore_user_abort( true );
@@ -3780,11 +4076,11 @@
37814077 'GROUP BY hc_id', __METHOD__ );
37824078 $dbw->delete( 'hitcounter', '*', __METHOD__ );
37834079 $dbw->unlockTables( __METHOD__ );
 4080+
37844081 if ( $dbType == 'mysql' ) {
37854082 $dbw->query( "UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n " .
37864083 'WHERE page_id = hc_id', __METHOD__ );
3787 - }
3788 - else {
 4084+ } else {
37894085 $dbw->query( "UPDATE $pageTable SET page_counter=page_counter + hc_n " .
37904086 "FROM $acchitsTable WHERE page_id = hc_id", __METHOD__ );
37914087 }
@@ -3793,6 +4089,7 @@
37944090 ignore_user_abort( $old_user_abort );
37954091 wfProfileOut( 'Article::incViewCount-collect' );
37964092 }
 4093+
37974094 $dbw->ignoreErrors( $oldignore );
37984095 }
37994096
@@ -3814,6 +4111,7 @@
38154112 } else {
38164113 $other = $title->getTalkPage();
38174114 }
 4115+
38184116 $other->invalidateCache();
38194117 $other->purgeSquid();
38204118
@@ -3821,18 +4119,20 @@
38224120 $title->purgeSquid();
38234121 $title->deleteTitleProtection();
38244122 }
3825 -
 4123+
38264124 /**
38274125 * Clears caches when article is deleted
38284126 */
38294127 public static function onArticleDelete( $title ) {
38304128 global $wgMessageCache;
 4129+
38314130 # Update existence markers on article/talk tabs...
38324131 if ( $title->isTalkPage() ) {
38334132 $other = $title->getSubjectPage();
38344133 } else {
38354134 $other = $title->getTalkPage();
38364135 }
 4136+
38374137 $other->invalidateCache();
38384138 $other->purgeSquid();
38394139
@@ -3846,16 +4146,19 @@
38474147 if ( $title->getNamespace() == NS_MEDIAWIKI ) {
38484148 $wgMessageCache->replace( $title->getDBkey(), false );
38494149 }
 4150+
38504151 # Images
38514152 if ( $title->getNamespace() == NS_FILE ) {
38524153 $update = new HTMLCacheUpdate( $title, 'imagelinks' );
38534154 $update->doUpdate();
38544155 }
 4156+
38554157 # User talk pages
38564158 if ( $title->getNamespace() == NS_USER_TALK ) {
38574159 $user = User::newFromName( $title->getText(), false );
38584160 $user->setNewtalk( false );
38594161 }
 4162+
38604163 # Image redirects
38614164 RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $title );
38624165 }
@@ -3890,6 +4193,7 @@
38914194 */
38924195 public function revert() {
38934196 global $wgOut;
 4197+
38944198 $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
38954199 }
38964200
@@ -3923,6 +4227,7 @@
39244228 : 'noarticletextanon';
39254229 $wgOut->addHTML( wfMsgExt( $msg, 'parse' ) );
39264230 }
 4231+
39274232 $wgOut->addHTML( '</div>' );
39284233 } else {
39294234 $dbr = wfGetDB( DB_SLAVE );
@@ -3941,13 +4246,17 @@
39424247
39434248 $wgOut->addHTML( "<ul><li>" . wfMsg( "numwatchers", $wgLang->formatNum( $numwatchers ) ) . '</li>' );
39444249 $wgOut->addHTML( "<li>" . wfMsg( 'numedits', $wgLang->formatNum( $pageInfo['edits'] ) ) . '</li>' );
 4250+
39454251 if ( $talkInfo ) {
39464252 $wgOut->addHTML( '<li>' . wfMsg( "numtalkedits", $wgLang->formatNum( $talkInfo['edits'] ) ) . '</li>' );
39474253 }
 4254+
39484255 $wgOut->addHTML( '<li>' . wfMsg( "numauthors", $wgLang->formatNum( $pageInfo['authors'] ) ) . '</li>' );
 4256+
39494257 if ( $talkInfo ) {
39504258 $wgOut->addHTML( '<li>' . wfMsg( 'numtalkauthors', $wgLang->formatNum( $talkInfo['authors'] ) ) . '</li>' );
39514259 }
 4260+
39524261 $wgOut->addHTML( '</ul>' );
39534262 }
39544263 }
@@ -3961,9 +4270,11 @@
39624271 */
39634272 public function pageCountInfo( $title ) {
39644273 $id = $title->getArticleId();
 4274+
39654275 if ( $id == 0 ) {
39664276 return false;
39674277 }
 4278+
39684279 $dbr = wfGetDB( DB_SLAVE );
39694280 $rev_clause = array( 'rev_page' => $id );
39704281 $edits = $dbr->selectField(
@@ -3980,6 +4291,7 @@
39814292 __METHOD__,
39824293 $this->getSelectOptions()
39834294 );
 4295+
39844296 return array( 'edits' => $edits, 'authors' => $authors );
39854297 }
39864298
@@ -3992,20 +4304,25 @@
39934305 public function getUsedTemplates() {
39944306 $result = array();
39954307 $id = $this->mTitle->getArticleID();
 4308+
39964309 if ( $id == 0 ) {
39974310 return array();
39984311 }
 4312+
39994313 $dbr = wfGetDB( DB_SLAVE );
40004314 $res = $dbr->select( array( 'templatelinks' ),
40014315 array( 'tl_namespace', 'tl_title' ),
40024316 array( 'tl_from' => $id ),
40034317 __METHOD__ );
 4318+
40044319 if ( $res !== false ) {
40054320 foreach ( $res as $row ) {
40064321 $result[] = Title::makeTitle( $row->tl_namespace, $row->tl_title );
40074322 }
40084323 }
 4324+
40094325 $dbr->freeResult( $res );
 4326+
40104327 return $result;
40114328 }
40124329
@@ -4018,21 +4335,26 @@
40194336 public function getHiddenCategories() {
40204337 $result = array();
40214338 $id = $this->mTitle->getArticleID();
 4339+
40224340 if ( $id == 0 ) {
40234341 return array();
40244342 }
 4343+
40254344 $dbr = wfGetDB( DB_SLAVE );
40264345 $res = $dbr->select( array( 'categorylinks', 'page_props', 'page' ),
40274346 array( 'cl_to' ),
40284347 array( 'cl_from' => $id, 'pp_page=page_id', 'pp_propname' => 'hiddencat',
40294348 'page_namespace' => NS_CATEGORY, 'page_title=cl_to' ),
40304349 __METHOD__ );
 4350+
40314351 if ( $res !== false ) {
40324352 foreach ( $res as $row ) {
40334353 $result[] = Title::makeTitle( NS_CATEGORY, $row->cl_to );
40344354 }
40354355 }
 4356+
40364357 $dbr->freeResult( $res );
 4358+
40374359 return $result;
40384360 }
40394361
@@ -4049,6 +4371,7 @@
40504372 # Redirect autosummaries
40514373 $ot = Title::newFromRedirect( $oldtext );
40524374 $rt = Title::newFromRedirect( $newtext );
 4375+
40534376 if ( is_object( $rt ) && ( !is_object( $ot ) || !$rt->equals( $ot ) || $ot->getFragment() != $rt->getFragment() ) ) {
40544377 return wfMsgForContent( 'autoredircomment', $rt->getFullText() );
40554378 }
@@ -4057,9 +4380,11 @@
40584381 if ( $flags & EDIT_NEW && strlen( $newtext ) ) {
40594382 # If they're making a new article, give its text, truncated, in the summary.
40604383 global $wgContLang;
 4384+
40614385 $truncatedtext = $wgContLang->truncate(
40624386 str_replace( "\n", ' ', $newtext ),
40634387 max( 0, 200 - strlen( wfMsgForContent( 'autosumm-new' ) ) ) );
 4388+
40644389 return wfMsgForContent( 'autosumm-new', $truncatedtext );
40654390 }
40664391
@@ -4069,9 +4394,11 @@
40704395 } elseif ( strlen( $oldtext ) > 10 * strlen( $newtext ) && strlen( $newtext ) < 500 ) {
40714396 # Removing more than 90% of the article
40724397 global $wgContLang;
 4398+
40734399 $truncatedtext = $wgContLang->truncate(
40744400 $newtext,
40754401 max( 0, 200 - strlen( wfMsgForContent( 'autosumm-replace' ) ) ) );
 4402+
40764403 return wfMsgForContent( 'autosumm-replace', $truncatedtext );
40774404 }
40784405
@@ -4128,13 +4455,16 @@
41294456 $parserCache = ParserCache::singleton();
41304457 $parserCache->save( $this->mParserOutput, $this, $parserOptions );
41314458 }
 4459+
41324460 // Make sure file cache is not used on uncacheable content.
41334461 // Output that has magic words in it can still use the parser cache
41344462 // (if enabled), though it will generally expire sooner.
41354463 if ( $this->mParserOutput->getCacheTime() == -1 || $this->mParserOutput->containsOldMagic() ) {
41364464 $wgUseFileCache = false;
41374465 }
 4466+
41384467 $this->doCascadeProtectionUpdates( $this->mParserOutput );
 4468+
41394469 return $this->mParserOutput;
41404470 }
41414471
@@ -4144,14 +4474,16 @@
41454475 */
41464476 public function getParserOptions() {
41474477 global $wgUser;
 4478+
41484479 if ( !$this->mParserOptions ) {
41494480 $this->mParserOptions = new ParserOptions( $wgUser );
41504481 $this->mParserOptions->setTidy( true );
41514482 $this->mParserOptions->enableLimitReport();
41524483 }
 4484+
41534485 return $this->mParserOptions;
41544486 }
4155 -
 4487+
41564488 /**
41574489 * Updates cascading protections
41584490 *
@@ -4179,9 +4511,11 @@
41804512 $res = $dbr->select( array( 'templatelinks' ),
41814513 array( 'tl_namespace', 'tl_title' ),
41824514 array( 'tl_from' => $id ),
4183 - __METHOD__ );
 4515+ __METHOD__
 4516+ );
41844517
41854518 global $wgContLang;
 4519+
41864520 foreach ( $res as $row ) {
41874521 $tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true;
41884522 }
@@ -4227,7 +4561,9 @@
42284562 # Okay, nothing to do
42294563 return;
42304564 }
 4565+
42314566 $insertRows = array();
 4567+
42324568 foreach ( $insertCats as $cat ) {
42334569 $insertRows[] = array(
42344570 'cat_id' => $dbw->nextSequenceValue( 'category_cat_id_seq' ),
@@ -4238,6 +4574,7 @@
42394575
42404576 $addFields = array( 'cat_pages = cat_pages + 1' );
42414577 $removeFields = array( 'cat_pages = cat_pages - 1' );
 4578+
42424579 if ( $ns == NS_CATEGORY ) {
42434580 $addFields[] = 'cat_subcats = cat_subcats + 1';
42444581 $removeFields[] = 'cat_subcats = cat_subcats - 1';
@@ -4254,6 +4591,7 @@
42554592 __METHOD__
42564593 );
42574594 }
 4595+
42584596 if ( $deleted ) {
42594597 $dbw->update(
42604598 'category',
@@ -4276,11 +4614,12 @@
42774615
42784616 // Should the parser cache be used?
42794617 $useParserCache = $wgEnableParserCache &&
4280 - intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 &&
4281 - $this->exists() &&
4282 - $oldid === null;
 4618+ intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 &&
 4619+ $this->exists() &&
 4620+ $oldid === null;
42834621
42844622 wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
 4623+
42854624 if ( $wgUser->getOption( 'stubthreshold' ) ) {
42864625 wfIncrStats( 'pcache_miss_stub' );
42874626 }
Index: trunk/phase3/includes/AjaxDispatcher.php
@@ -42,31 +42,27 @@
4343 }
4444
4545 switch( $this->mode ) {
46 -
47 - case 'get':
48 - $this->func_name = isset( $_GET["rs"] ) ? $_GET["rs"] : '';
49 - if ( ! empty( $_GET["rsargs"] ) ) {
50 - $this->args = $_GET["rsargs"];
51 - } else {
52 - $this->args = array();
53 - }
54 - break;
55 -
56 - case 'post':
57 - $this->func_name = isset( $_POST["rs"] ) ? $_POST["rs"] : '';
58 - if ( ! empty( $_POST["rsargs"] ) ) {
59 - $this->args = $_POST["rsargs"];
60 - } else {
61 - $this->args = array();
62 - }
63 - break;
64 -
65 - default:
66 - wfProfileOut( __METHOD__ );
67 - return;
68 - # Or we could throw an exception:
69 - # throw new MWException( __METHOD__ . ' called without any data (mode empty).' );
70 -
 46+ case 'get':
 47+ $this->func_name = isset( $_GET["rs"] ) ? $_GET["rs"] : '';
 48+ if ( ! empty( $_GET["rsargs"] ) ) {
 49+ $this->args = $_GET["rsargs"];
 50+ } else {
 51+ $this->args = array();
 52+ }
 53+ break;
 54+ case 'post':
 55+ $this->func_name = isset( $_POST["rs"] ) ? $_POST["rs"] : '';
 56+ if ( ! empty( $_POST["rsargs"] ) ) {
 57+ $this->args = $_POST["rsargs"];
 58+ } else {
 59+ $this->args = array();
 60+ }
 61+ break;
 62+ default:
 63+ wfProfileOut( __METHOD__ );
 64+ return;
 65+ # Or we could throw an exception:
 66+ # throw new MWException( __METHOD__ . ' called without any data (mode empty).' );
7167 }
7268
7369 wfProfileOut( __METHOD__ );
@@ -89,8 +85,11 @@
9086 if ( ! in_array( $this->func_name, $wgAjaxExportList ) ) {
9187 wfDebug( __METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n" );
9288
93 - wfHttpError( 400, 'Bad Request',
94 - "unknown function " . (string) $this->func_name );
 89+ wfHttpError(
 90+ 400,
 91+ 'Bad Request',
 92+ "unknown function " . (string) $this->func_name
 93+ );
9594 } else {
9695 wfDebug( __METHOD__ . ' dispatching ' . $this->func_name . "\n" );
9796
@@ -99,6 +98,7 @@
10099 } else {
101100 $func = $this->func_name;
102101 }
 102+
103103 try {
104104 $result = call_user_func_array( $func, $this->args );
105105
@@ -109,8 +109,7 @@
110110
111111 wfHttpError( 500, 'Internal Error',
112112 "{$this->func_name} returned no data" );
113 - }
114 - else {
 113+ } else {
115114 if ( is_string( $result ) ) {
116115 $result = new AjaxResponse( $result );
117116 }
@@ -120,7 +119,6 @@
121120
122121 wfDebug( __METHOD__ . ' dispatch complete for ' . $this->func_name . "\n" );
123122 }
124 -
125123 } catch ( Exception $e ) {
126124 wfDebug( __METHOD__ . ' ERROR while dispatching '
127125 . $this->func_name . "(" . var_export( $this->args, true ) . "): "
Index: trunk/phase3/includes/AjaxFunctions.php
@@ -28,6 +28,7 @@
2929 if ( $charAt == '%' ) {
3030 $pos++;
3131 $charAt = substr ( $source, $pos, 1 );
 32+
3233 if ( $charAt == 'u' ) {
3334 // we got a unicode character
3435 $pos++;
@@ -62,14 +63,22 @@
6364 * @return utf8char
6465 */
6566 function code2utf( $num ) {
66 - if ( $num < 128 )
 67+ if ( $num < 128 ) {
6768 return chr( $num );
68 - if ( $num < 2048 )
 69+ }
 70+
 71+ if ( $num < 2048 ) {
6972 return chr( ( $num >> 6 ) + 192 ) . chr( ( $num&63 ) + 128 );
70 - if ( $num < 65536 )
 73+ }
 74+
 75+ if ( $num < 65536 ) {
7176 return chr( ( $num >> 12 ) + 224 ) . chr( ( ( $num >> 6 )&63 ) + 128 ) . chr( ( $num&63 ) + 128 );
72 - if ( $num < 2097152 )
 77+ }
 78+
 79+ if ( $num < 2097152 ) {
7380 return chr( ( $num >> 18 ) + 240 ) . chr( ( ( $num >> 12 )&63 ) + 128 ) . chr( ( ( $num >> 6 )&63 ) + 128 ) . chr( ( $num&63 ) + 128 );
 81+ }
 82+
7483 return '';
7584 }
7685
@@ -80,8 +89,9 @@
8190 function wfAjaxGetThumbnailUrl( $file, $width, $height ) {
8291 $file = wfFindFile( $file );
8392
84 - if ( !$file || !$file->exists() )
 93+ if ( !$file || !$file->exists() ) {
8594 return null;
 95+ }
8696
8797 $url = $file->getThumbnail( $width, $height )->url;
8898
@@ -95,8 +105,9 @@
96106 function wfAjaxGetFileUrl( $file ) {
97107 $file = wfFindFile( $file );
98108
99 - if ( !$file || !$file->exists() )
 109+ if ( !$file || !$file->exists() ) {
100110 return null;
 111+ }
101112
102113 $url = $file->getUrl();
103114
Index: trunk/phase3/includes/AjaxResponse.php
@@ -15,7 +15,6 @@
1616 * @ingroup Ajax
1717 */
1818 class AjaxResponse {
19 -
2019 /** Number of seconds to get the response cached by a proxy */
2120 private $mCacheDuration;
2221
@@ -99,19 +98,16 @@
10099
101100 if ( $this->mLastModified ) {
102101 header ( "Last-Modified: " . $this->mLastModified );
103 - }
104 - else {
 102+ } else {
105103 header ( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
106104 }
107105
108106 if ( $this->mCacheDuration ) {
109 -
110107 # If squid caches are configured, tell them to cache the response,
111108 # and tell the client to always check with the squid. Otherwise,
112109 # tell the client to use a cached copy, without a way to purge it.
113110
114111 if ( $wgUseSquid ) {
115 -
116112 # Expect explicite purge of the proxy cache, but require end user agents
117113 # to revalidate against the proxy on each visit.
118114 # Surrogate-Control controls our Squid, Cache-Control downstream caches
@@ -156,10 +152,12 @@
157153 wfDebug( "$fname: CACHE DISABLED, NO TIMESTAMP\n" );
158154 return;
159155 }
 156+
160157 if ( !$wgCachePages ) {
161158 wfDebug( "$fname: CACHE DISABLED\n", false );
162159 return;
163160 }
 161+
164162 if ( $wgUser->getOption( 'nocache' ) ) {
165163 wfDebug( "$fname: USER DISABLED CACHE\n", false );
166164 return;
@@ -177,6 +175,7 @@
178176 $ismodsince = wfTimestamp( TS_MW, $modsinceTime ? $modsinceTime : 1 );
179177 wfDebug( "$fname: -- client send If-Modified-Since: " . $modsince . "\n", false );
180178 wfDebug( "$fname: -- we might send Last-Modified : $lastmod\n", false );
 179+
181180 if ( ( $ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && $ismodsince >= $wgCacheEpoch ) {
182181 ini_set( 'zlib.output_compression', 0 );
183182 $this->setResponseCode( "304 Not Modified" );
@@ -198,14 +197,18 @@
199198
200199 function loadFromMemcached( $mckey, $touched ) {
201200 global $wgMemc;
202 - if ( !$touched ) return false;
203201
 202+ if ( !$touched ) {
 203+ return false;
 204+ }
 205+
204206 $mcvalue = $wgMemc->get( $mckey );
205207 if ( $mcvalue ) {
206208 # Check to see if the value has been invalidated
207209 if ( $touched <= $mcvalue['timestamp'] ) {
208210 wfDebug( "Got $mckey from cache\n" );
209211 $this->mText = $mcvalue['value'];
 212+
210213 return true;
211214 } else {
212215 wfDebug( "$mckey has expired\n" );

Status & tagging log