r44015 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44014‎ | r44015 | r44016 >
Date:14:29, 28 November 2008
Author:aaron
Status:resolved (Comments)
Tags:
Comment:
*Remove getContent() side-effects
*Fix/set visibility
*Refactor deletion log stuff to helper function
*Add wfDeprecated( __METHOD__ ) to some places
*Various minor cleanup/spacing
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -47,7 +47,7 @@
4848 * @param $title Reference to a Title object.
4949 * @param $oldId Integer revision ID, null to fetch from request, zero for current
5050 */
51 - function __construct( Title $title, $oldId = null ) {
 51+ public function __construct( Title $title, $oldId = null ) {
5252 $this->mTitle =& $title;
5353 $this->mOldId = $oldId;
5454 }
@@ -58,7 +58,6 @@
5959 */
6060 public static function newFromID( $id ) {
6161 $t = Title::newFromID( $id );
62 -
6362 return $t == null ? null : new Article( $t );
6463 }
6564
@@ -67,7 +66,7 @@
6867 * from another page on the wiki.
6968 * @param $from Title object.
7069 */
71 - function setRedirectedFrom( $from ) {
 70+ public function setRedirectedFrom( $from ) {
7271 $this->mRedirectedFrom = $from;
7372 }
7473
@@ -79,22 +78,20 @@
8079 * @return mixed Title object, or null if this page is not a redirect
8180 */
8281 public function getRedirectTarget() {
83 - if(!$this->mTitle || !$this->mTitle->isRedirect())
 82+ if( !$this->mTitle || !$this->mTitle->isRedirect() )
8483 return null;
85 - if(!is_null($this->mRedirectTarget))
 84+ if( !is_null($this->mRedirectTarget) )
8685 return $this->mRedirectTarget;
87 -
8886 # Query the redirect table
89 - $dbr = wfGetDB(DB_SLAVE);
90 - $res = $dbr->select('redirect',
91 - array('rd_namespace', 'rd_title'),
92 - array('rd_from' => $this->getID()),
93 - __METHOD__
 87+ $dbr = wfGetDB( DB_SLAVE );
 88+ $res = $dbr->select( 'redirect',
 89+ array('rd_namespace', 'rd_title'),
 90+ array('rd_from' => $this->getID()),
 91+ __METHOD__
9492 );
95 - $row = $dbr->fetchObject($res);
96 - if($row)
 93+ if( $row = $dbr->fetchObject($res) ) {
9794 return $this->mRedirectTarget = Title::makeTitle($row->rd_namespace, $row->rd_title);
98 -
 95+ }
9996 # This page doesn't have an entry in the redirect table
10097 return $this->mRedirectTarget = $this->insertRedirect();
10198 }
@@ -106,15 +103,19 @@
107104 * @return Title object
108105 */
109106 public function insertRedirect() {
110 - $retval = Title::newFromRedirect($this->getContent());
111 - if(!$retval)
 107+ $retval = Title::newFromRedirect( $this->getContent() );
 108+ if( !$retval ) {
112109 return null;
113 - $dbw = wfGetDB(DB_MASTER);
114 - $dbw->replace('redirect', array('rd_from'), array(
 110+ }
 111+ $dbw = wfGetDB( DB_MASTER );
 112+ $dbw->replace( 'redirect', array('rd_from'),
 113+ array(
115114 'rd_from' => $this->getID(),
116115 'rd_namespace' => $retval->getNamespace(),
117116 'rd_title' => $retval->getDBKey()
118 - ), __METHOD__);
 117+ ),
 118+ __METHOD__
 119+ );
119120 return $retval;
120121 }
121122
@@ -143,7 +144,6 @@
144145 //
145146 // This can be hard to reverse and may produce loops,
146147 // so they may be disabled in the site configuration.
147 -
148148 $source = $this->mTitle->getFullURL( 'redirect=no' );
149149 return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) );
150150 }
@@ -154,7 +154,6 @@
155155 // the rest of the page we're on.
156156 //
157157 // This can be hard to reverse, so they may be disabled.
158 -
159158 if( $rt->isSpecial( 'Userlogout' ) ) {
160159 // rolleyes
161160 } else {
@@ -171,7 +170,7 @@
172171 /**
173172 * get the title object of the article
174173 */
175 - function getTitle() {
 174+ public function getTitle() {
176175 return $this->mTitle;
177176 }
178177
@@ -179,7 +178,7 @@
180179 * Clear the object
181180 * @private
182181 */
183 - function clear() {
 182+ public function clear() {
184183 $this->mDataLoaded = false;
185184 $this->mContentLoaded = false;
186185
@@ -202,30 +201,23 @@
203202 * Note that getContent/loadContent do not follow redirects anymore.
204203 * If you need to fetch redirectable content easily, try
205204 * the shortcut in Article::followContent()
206 - * FIXME
207 - * @todo There are still side-effects in this!
208 - * In general, you should use the Revision class, not Article,
209 - * to fetch text for purposes other than page views.
210205 *
211206 * @return Return the text of this revision
212207 */
213 - function getContent() {
 208+ public function getContent() {
214209 global $wgUser, $wgOut, $wgMessageCache;
215 -
216210 wfProfileIn( __METHOD__ );
217 -
218 - if ( 0 == $this->getID() ) {
219 - wfProfileOut( __METHOD__ );
220 - $wgOut->setRobotPolicy( 'noindex,nofollow' );
221 -
222 - if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 211+ if( $this->getID() === 0 ) {
 212+ # If this is a MediaWiki:x message, then load the messages
 213+ # and return the message value for x.
 214+ if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
223215 $wgMessageCache->loadAllMessages();
224 - $ret = wfMsgWeirdKey ( $this->mTitle->getText() ) ;
 216+ $text = wfMsgWeirdKey( $this->mTitle->getText() ) ;
225217 } else {
226 - $ret = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' );
 218+ $text = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' );
227219 }
228 -
229 - return "<div class='noarticletext'>\n$ret\n</div>";
 220+ wfProfileOut( __METHOD__ );
 221+ return $text;
230222 } else {
231223 $this->loadContent();
232224 wfProfileOut( __METHOD__ );
@@ -245,7 +237,7 @@
246238 * @return string text of the requested section
247239 * @deprecated
248240 */
249 - function getSection($text,$section) {
 241+ public function getSection( $text, $section ) {
250242 global $wgParser;
251243 return $wgParser->getSection( $text, $section );
252244 }
@@ -254,8 +246,8 @@
255247 * @return int The oldid of the article that is to be shown, 0 for the
256248 * current revision
257249 */
258 - function getOldID() {
259 - if ( is_null( $this->mOldId ) ) {
 250+ public function getOldID() {
 251+ if( is_null( $this->mOldId ) ) {
260252 $this->mOldId = $this->getOldIDFromRequest();
261253 }
262254 return $this->mOldId;
@@ -270,28 +262,23 @@
271263 global $wgRequest;
272264 $this->mRedirectUrl = false;
273265 $oldid = $wgRequest->getVal( 'oldid' );
274 - if ( isset( $oldid ) ) {
 266+ if( isset( $oldid ) ) {
275267 $oldid = intval( $oldid );
276 - if ( $wgRequest->getVal( 'direction' ) == 'next' ) {
 268+ if( $wgRequest->getVal( 'direction' ) == 'next' ) {
277269 $nextid = $this->mTitle->getNextRevisionID( $oldid );
278 - if ( $nextid ) {
 270+ if( $nextid ) {
279271 $oldid = $nextid;
280272 } else {
281273 $this->mRedirectUrl = $this->mTitle->getFullURL( 'redirect=no' );
282274 }
283 - } elseif ( $wgRequest->getVal( 'direction' ) == 'prev' ) {
 275+ } elseif( $wgRequest->getVal( 'direction' ) == 'prev' ) {
284276 $previd = $this->mTitle->getPreviousRevisionID( $oldid );
285 - if ( $previd ) {
 277+ if( $previd ) {
286278 $oldid = $previd;
287 - } else {
288 - # TODO
289279 }
290280 }
291 - # unused:
292 - # $lastid = $oldid;
293281 }
294 -
295 - if ( !$oldid ) {
 282+ if( !$oldid ) {
296283 $oldid = 0;
297284 }
298285 return $oldid;
@@ -301,15 +288,15 @@
302289 * Load the revision (including text) into this object
303290 */
304291 function loadContent() {
305 - if ( $this->mContentLoaded ) return;
306 -
 292+ if( $this->mContentLoaded ) return;
 293+ wfProfileIn( __METHOD__ );
307294 # Query variables :P
308295 $oldid = $this->getOldID();
309 -
310296 # Pre-fill content with error message so that if something
311297 # fails we'll have something telling us what we intended.
312298 $this->mOldId = $oldid;
313299 $this->fetchContent( $oldid );
 300+ wfProfileOut( __METHOD__ );
314301 }
315302
316303
@@ -317,9 +304,8 @@
318305 * Fetch a page record with the given conditions
319306 * @param Database $dbr
320307 * @param array $conditions
321 - * @private
322308 */
323 - function pageData( $dbr, $conditions ) {
 309+ protected function pageData( $dbr, $conditions ) {
324310 $fields = array(
325311 'page_id',
326312 'page_namespace',
@@ -348,7 +334,7 @@
349335 * @param Database $dbr
350336 * @param Title $title
351337 */
352 - function pageDataFromTitle( $dbr, $title ) {
 338+ public function pageDataFromTitle( $dbr, $title ) {
353339 return $this->pageData( $dbr, array(
354340 'page_namespace' => $title->getNamespace(),
355341 'page_title' => $title->getDBkey() ) );
@@ -358,7 +344,7 @@
359345 * @param Database $dbr
360346 * @param int $id
361347 */
362 - function pageDataFromId( $dbr, $id ) {
 348+ protected function pageDataFromId( $dbr, $id ) {
363349 return $this->pageData( $dbr, array( 'page_id' => $id ) );
364350 }
365351
@@ -367,16 +353,15 @@
368354 * some source.
369355 *
370356 * @param object $data
371 - * @private
372357 */
373 - function loadPageData( $data = 'fromdb' ) {
374 - if ( $data === 'fromdb' ) {
 358+ public function loadPageData( $data = 'fromdb' ) {
 359+ if( $data === 'fromdb' ) {
375360 $dbr = wfGetDB( DB_MASTER );
376361 $data = $this->pageDataFromId( $dbr, $this->getId() );
377362 }
378363
379364 $lc = LinkCache::singleton();
380 - if ( $data ) {
 365+ if( $data ) {
381366 $lc->addGoodLinkObj( $data->page_id, $this->mTitle, $data->page_len, $data->page_is_redirect );
382367
383368 $this->mTitle->mArticleID = $data->page_id;
@@ -389,7 +374,7 @@
390375 $this->mIsRedirect = $data->page_is_redirect;
391376 $this->mLatest = $data->page_latest;
392377 } else {
393 - if ( is_object( $this->mTitle ) ) {
 378+ if( is_object( $this->mTitle ) ) {
394379 $lc->addBadLinkObj( $this->mTitle );
395380 }
396381 $this->mTitle->mArticleID = 0;
@@ -405,7 +390,7 @@
406391 * @return string
407392 */
408393 function fetchContent( $oldid = 0 ) {
409 - if ( $this->mContentLoaded ) {
 394+ if( $this->mContentLoaded ) {
410395 return $this->mContent;
411396 }
412397
@@ -469,7 +454,7 @@
470455 *
471456 * @param $x Mixed: FIXME
472457 */
473 - function forUpdate( $x = NULL ) {
 458+ public function forUpdate( $x = NULL ) {
474459 return wfSetVar( $this->mForUpdate, $x );
475460 }
476461
@@ -491,9 +476,9 @@
492477 * the default
493478 * @return Array: options
494479 */
495 - function getSelectOptions( $options = '' ) {
496 - if ( $this->mForUpdate ) {
497 - if ( is_array( $options ) ) {
 480+ protected function getSelectOptions( $options = '' ) {
 481+ if( $this->mForUpdate ) {
 482+ if( is_array( $options ) ) {
498483 $options[] = 'FOR UPDATE';
499484 } else {
500485 $options = 'FOR UPDATE';
@@ -505,7 +490,7 @@
506491 /**
507492 * @return int Page ID
508493 */
509 - function getID() {
 494+ public function getID() {
510495 if( $this->mTitle ) {
511496 return $this->mTitle->getArticleID();
512497 } else {
@@ -516,22 +501,26 @@
517502 /**
518503 * @return bool Whether or not the page exists in the database
519504 */
520 - function exists() {
521 - return $this->getId() != 0;
 505+ public function exists() {
 506+ return $this->getId() > 0;
522507 }
523508
524509 /**
525510 * @return int The view count for the page
526511 */
527 - function getCount() {
528 - if ( -1 == $this->mCounter ) {
 512+ public function getCount() {
 513+ if( -1 == $this->mCounter ) {
529514 $id = $this->getID();
530 - if ( $id == 0 ) {
 515+ if( $id == 0 ) {
531516 $this->mCounter = 0;
532517 } else {
533518 $dbr = wfGetDB( DB_SLAVE );
534 - $this->mCounter = $dbr->selectField( 'page', 'page_counter', array( 'page_id' => $id ),
535 - 'Article::getCount', $this->getSelectOptions() );
 519+ $this->mCounter = $dbr->selectField( 'page',
 520+ 'page_counter',
 521+ array( 'page_id' => $id ),
 522+ __METHOD__,
 523+ $this->getSelectOptions()
 524+ );
536525 }
537526 }
538527 return $this->mCounter;
@@ -544,14 +533,11 @@
545534 * @param $text String: text to analyze
546535 * @return bool
547536 */
548 - function isCountable( $text ) {
 537+ public function isCountable( $text ) {
549538 global $wgUseCommaCount;
550539
551540 $token = $wgUseCommaCount ? ',' : '[[';
552 - return
553 - $this->mTitle->isContentPage()
554 - && !$this->isRedirect( $text )
555 - && in_string( $token, $text );
 541+ return $this->mTitle->isContentPage() && !$this->isRedirect($text) && in_string($token,$text);
556542 }
557543
558544 /**
@@ -560,11 +546,11 @@
561547 * @param $text String: FIXME
562548 * @return bool
563549 */
564 - function isRedirect( $text = false ) {
565 - if ( $text === false ) {
566 - if ( $this->mDataLoaded )
 550+ public function isRedirect( $text = false ) {
 551+ if( $text === false ) {
 552+ if( $this->mDataLoaded ) {
567553 return $this->mIsRedirect;
568 -
 554+ }
569555 // Apparently loadPageData was never called
570556 $this->loadContent();
571557 $titleObj = Title::newFromRedirect( $this->fetchContent() );
@@ -579,28 +565,25 @@
580566 * to this page (and it exists).
581567 * @return bool
582568 */
583 - function isCurrent() {
 569+ public function isCurrent() {
584570 # If no oldid, this is the current version.
585 - if ($this->getOldID() == 0)
 571+ if( $this->getOldID() == 0 ) {
586572 return true;
587 -
588 - return $this->exists() &&
589 - isset( $this->mRevision ) &&
590 - $this->mRevision->isCurrent();
 573+ }
 574+ return $this->exists() && isset($this->mRevision) && $this->mRevision->isCurrent();
591575 }
592576
593577 /**
594578 * Loads everything except the text
595579 * This isn't necessary for all uses, so it's only done if needed.
596 - * @private
597580 */
598 - function loadLastEdit() {
599 - if ( -1 != $this->mUser )
 581+ protected function loadLastEdit() {
 582+ if( -1 != $this->mUser )
600583 return;
601584
602585 # New or non-existent articles have no user information
603586 $id = $this->getID();
604 - if ( 0 == $id ) return;
 587+ if( 0 == $id ) return;
605588
606589 $this->mLastRevision = Revision::loadFromPageId( wfGetDB( DB_MASTER ), $id );
607590 if( !is_null( $this->mLastRevision ) ) {
@@ -613,35 +596,36 @@
614597 }
615598 }
616599
617 - function getTimestamp() {
 600+ public function getTimestamp() {
618601 // Check if the field has been filled by ParserCache::get()
619 - if ( !$this->mTimestamp ) {
 602+ if( !$this->mTimestamp ) {
620603 $this->loadLastEdit();
621604 }
622605 return wfTimestamp(TS_MW, $this->mTimestamp);
623606 }
624607
625 - function getUser() {
 608+ public function getUser() {
626609 $this->loadLastEdit();
627610 return $this->mUser;
628611 }
629612
630 - function getUserText() {
 613+ public function getUserText() {
631614 $this->loadLastEdit();
632615 return $this->mUserText;
633616 }
634617
635 - function getComment() {
 618+ public function getComment() {
636619 $this->loadLastEdit();
637620 return $this->mComment;
638621 }
639622
640 - function getMinorEdit() {
 623+ public function getMinorEdit() {
641624 $this->loadLastEdit();
642625 return $this->mMinorEdit;
643626 }
644627
645 - function getRevIdFetched() {
 628+ /* Use this to fetch the rev ID used on page views */
 629+ public function getRevIdFetched() {
646630 $this->loadLastEdit();
647631 return $this->mRevIdFetched;
648632 }
@@ -650,7 +634,7 @@
651635 * @param $limit Integer: default 0.
652636 * @param $offset Integer: default 0.
653637 */
654 - function getContributors($limit = 0, $offset = 0) {
 638+ public function getContributors($limit = 0, $offset = 0) {
655639 # XXX: this is expensive; cache this info somewhere.
656640
657641 $contribs = array();
@@ -667,8 +651,8 @@
668652 GROUP BY rev_user, rev_user_text, user_real_name
669653 ORDER BY timestamp DESC";
670654
671 - if ($limit > 0) { $sql .= ' LIMIT '.$limit; }
672 - if ($offset > 0) { $sql .= ' OFFSET '.$offset; }
 655+ if($limit > 0) { $sql .= ' LIMIT '.$limit; }
 656+ if($offset > 0) { $sql .= ' OFFSET '.$offset; }
673657
674658 $sql .= ' '. $this->getSelectOptions();
675659
@@ -681,7 +665,7 @@
682666 * This is the default action of the script: just view the page of
683667 * the given title.
684668 */
685 - function view() {
 669+ public function view() {
686670 global $wgUser, $wgOut, $wgRequest, $wgContLang;
687671 global $wgEnableParserCache, $wgStylePath, $wgParser;
688672 global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies;
@@ -697,7 +681,7 @@
698682 $oldid = $this->getOldID();
699683
700684 # getOldID may want us to redirect somewhere else
701 - if ( $this->mRedirectUrl ) {
 685+ if( $this->mRedirectUrl ) {
702686 $wgOut->redirect( $this->mRedirectUrl );
703687 wfProfileOut( __METHOD__ );
704688 return;
@@ -714,7 +698,7 @@
715699 # Discourage indexing of printable versions, but encourage following
716700 if( $wgOut->isPrintable() ) {
717701 $policy = 'noindex,follow';
718 - } elseif ( isset( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) ) {
 702+ } elseif( isset( $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()] ) ) {
719703 $policy = $wgArticleRobotPolicies[$this->mTitle->getPrefixedText()];
720704 } elseif( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
721705 # Honour customised robot policies for this namespace
@@ -727,7 +711,7 @@
728712 # If we got diff and oldid in the query, we want to see a
729713 # diff page instead of the article.
730714
731 - if ( !is_null( $diff ) ) {
 715+ if( !is_null( $diff ) ) {
732716 $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
733717
734718 $diff = $wgRequest->getVal( 'diff' );
@@ -747,13 +731,13 @@
748732 return;
749733 }
750734
751 - if ( empty( $oldid ) && $this->checkTouched() ) {
 735+ if( empty( $oldid ) && $this->checkTouched() ) {
752736 $wgOut->setETag($parserCache->getETag($this, $wgUser));
753737
754738 if( $wgOut->checkLastModified( $this->mTouched ) ){
755739 wfProfileOut( __METHOD__ );
756740 return;
757 - } else if ( $this->tryFileCache() ) {
 741+ } else if( $this->tryFileCache() ) {
758742 # tell wgOut that output is taken care of
759743 $wgOut->disable();
760744 $this->viewUpdates();
@@ -765,27 +749,27 @@
766750 # Should the parser cache be used?
767751 $pcache = $this->useParserCache( $oldid );
768752 wfDebug( 'Article::view using parser cache: ' . ($pcache ? 'yes' : 'no' ) . "\n" );
769 - if ( $wgUser->getOption( 'stubthreshold' ) ) {
 753+ if( $wgUser->getOption( 'stubthreshold' ) ) {
770754 wfIncrStats( 'pcache_miss_stub' );
771755 }
772756
773757 $wasRedirected = false;
774 - if ( isset( $this->mRedirectedFrom ) ) {
 758+ if( isset( $this->mRedirectedFrom ) ) {
775759 // This is an internally redirected page view.
776760 // We'll need a backlink to the source page for navigation.
777 - if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
 761+ if( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
778762 $redir = $sk->makeKnownLinkObj( $this->mRedirectedFrom, '', 'redirect=no' );
779763 $s = wfMsg( 'redirectedfrom', $redir );
780764 $wgOut->setSubtitle( $s );
781765
782766 // Set the fragment if one was specified in the redirect
783 - if ( strval( $this->mTitle->getFragment() ) != '' ) {
 767+ if( strval( $this->mTitle->getFragment() ) != '' ) {
784768 $fragment = Xml::escapeJsString( $this->mTitle->getFragmentForURL() );
785769 $wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" );
786770 }
787771 $wasRedirected = true;
788772 }
789 - } elseif ( !empty( $rdfrom ) ) {
 773+ } elseif( !empty( $rdfrom ) ) {
790774 // This is an externally redirected view, from some other wiki.
791775 // If it was reported from a trusted site, supply a backlink.
792776 global $wgRedirectSources;
@@ -799,44 +783,20 @@
800784
801785 $outputDone = false;
802786 wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$pcache ) );
803 - if ( $pcache ) {
804 - if ( $wgOut->tryParserCache( $this, $wgUser ) ) {
805 - // Ensure that UI elements requiring revision ID have
806 - // the correct version information.
807 - $wgOut->setRevisionId( $this->mLatest );
808 - $outputDone = true;
809 - }
 787+ if( $pcache && $wgOut->tryParserCache( $this, $wgUser ) ) {
 788+ // Ensure that UI elements requiring revision ID have
 789+ // the correct version information.
 790+ $wgOut->setRevisionId( $this->mLatest );
 791+ $outputDone = true;
810792 }
811793 # Fetch content and check for errors
812 - if ( !$outputDone ) {
 794+ if( !$outputDone ) {
813795 # If the article does not exist and was deleted, show the log
814 - if ($this->getID() == 0) {
815 - $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut );
816 - $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() );
817 - $count = $pager->getNumRows();
818 - if( $count > 0 ) {
819 - $pager->mLimit = 10;
820 - $wgOut->addHTML( '<div class="mw-warning-with-logexcerpt">' );
821 - $wgOut->addWikiMsg( 'deleted-notice' );
822 - $wgOut->addHTML(
823 - $loglist->beginLogEventsList() .
824 - $pager->getBody() .
825 - $loglist->endLogEventsList()
826 - );
827 - if($count > 10){
828 - $wgOut->addHTML( $wgUser->getSkin()->link(
829 - SpecialPage::getTitleFor( 'Log' ),
830 - wfMsgHtml( 'deletelog-fulllog' ),
831 - array(),
832 - array(
833 - 'type' => 'delete',
834 - 'page' => $this->mTitle->getPrefixedText() ) ) );
835 - }
836 - $wgOut->addHTML( '</div>' );
837 - }
 796+ if( $this->getID() == 0 ) {
 797+ $this->showDeletionLog();
838798 }
839799 $text = $this->getContent();
840 - if ( $text === false ) {
 800+ if( $text === false ) {
841801 # Failed to load, replace text with error message
842802 $t = $this->mTitle->getPrefixedText();
843803 if( $oldid ) {
@@ -846,9 +806,14 @@
847807 $text = wfMsg( 'noarticletext' );
848808 }
849809 }
 810+ # Non-existent pages
 811+ if( $this->getID() === 0 ) {
 812+ $wgOut->setRobotPolicy( 'noindex,nofollow' );
 813+ $text = "<div class='noarticletext'>\n$text\n</div>";
 814+ }
850815
851816 # Another whitelist check in case oldid is altering the title
852 - if ( !$this->mTitle->userCanRead() ) {
 817+ if( !$this->mTitle->userCanRead() ) {
853818 $wgOut->loginToUse();
854819 $wgOut->output();
855820 wfProfileOut( __METHOD__ );
@@ -856,7 +821,7 @@
857822 }
858823
859824 # We're looking at an old revision
860 - if ( !empty( $oldid ) ) {
 825+ if( !empty( $oldid ) ) {
861826 $wgOut->setRobotPolicy( 'noindex,nofollow' );
862827 if( is_null( $this->mRevision ) ) {
863828 // FIXME: This would be a nice place to load the 'no such page' text.
@@ -890,12 +855,12 @@
891856 $wgOut->addHTML( htmlspecialchars( $this->mContent ) );
892857 $wgOut->addHTML( "\n</pre>\n" );
893858 }
894 - } else if ( $rt = Title::newFromRedirect( $text ) ) {
 859+ } else if( $rt = Title::newFromRedirect( $text ) ) {
895860 # Don't append the subtitle if this was an old revision
896861 $wgOut->addHTML( $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ) );
897862 $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser));
898863 $wgOut->addParserOutputNoText( $parseout );
899 - } else if ( $pcache ) {
 864+ } else if( $pcache ) {
900865 # Display content and save to parser cache
901866 $this->outputWikiText( $text );
902867 } else {
@@ -911,7 +876,7 @@
912877 $time += wfTime();
913878
914879 # Timing hack
915 - if ( $time > 3 ) {
 880+ if( $time > 3 ) {
916881 wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time,
917882 $this->mTitle->getPrefixedDBkey()));
918883 }
@@ -954,12 +919,38 @@
955920 }
956921
957922 # Trackbacks
958 - if ($wgUseTrackbacks)
 923+ if( $wgUseTrackbacks ) {
959924 $this->addTrackbacks();
 925+ }
960926
961927 $this->viewUpdates();
962928 wfProfileOut( __METHOD__ );
963929 }
 930+
 931+ protected function showDeletionLog() {
 932+ global $wgUser, $wgOut;
 933+ $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut );
 934+ $pager = new LogPager( $loglist, 'delete', false, $this->mTitle->getPrefixedText() );
 935+ if( $pager->getNumRows() > 0 ) {
 936+ $pager->mLimit = 10;
 937+ $wgOut->addHTML( '<div class="mw-warning-with-logexcerpt">' );
 938+ $wgOut->addWikiMsg( 'deleted-notice' );
 939+ $wgOut->addHTML(
 940+ $loglist->beginLogEventsList() .
 941+ $pager->getBody() .
 942+ $loglist->endLogEventsList()
 943+ );
 944+ if( $pager->getNumRows() > 10 ) {
 945+ $wgOut->addHTML( $wgUser->getSkin()->link(
 946+ SpecialPage::getTitleFor( 'Log' ),
 947+ wfMsgHtml( 'deletelog-fulllog' ),
 948+ array(),
 949+ array( 'type' => 'delete', 'page' => $this->mTitle->getPrefixedText() )
 950+ ) );
 951+ }
 952+ $wgOut->addHTML( '</div>' );
 953+ }
 954+ }
964955
965956 /*
966957 * Should the parser cache be used?
@@ -978,12 +969,11 @@
979970 /**
980971 * View redirect
981972 * @param Title $target Title of destination to redirect
982 - * @param Bool $appendSubtitle Object[optional]
 973+ * @param Bool $appendSubtitle [optional]
983974 * @param Bool $forceKnown Should the image be shown as a bluelink regardless of existence?
984975 */
985976 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
986977 global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser;
987 -
988978 # Display redirect
989979 $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
990980 $imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png';
@@ -992,35 +982,31 @@
993983 $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) );
994984 }
995985 $sk = $wgUser->getSkin();
996 - if ( $forceKnown )
 986+ if( $forceKnown ) {
997987 $link = $sk->makeKnownLinkObj( $target, htmlspecialchars( $target->getFullText() ) );
998 - else
 988+ } else {
999989 $link = $sk->makeLinkObj( $target, htmlspecialchars( $target->getFullText() ) );
1000 -
 990+ }
1001991 return '<img src="'.$imageUrl.'" alt="#REDIRECT " />' .
1002992 '<span class="redirectText">'.$link.'</span>';
1003993
1004994 }
1005995
1006 - function addTrackbacks() {
 996+ public function addTrackbacks() {
1007997 global $wgOut, $wgUser;
1008 -
1009 - $dbr = wfGetDB(DB_SLAVE);
1010 - $tbs = $dbr->select(
1011 - /* FROM */ 'trackbacks',
1012 - /* SELECT */ array('tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name'),
1013 - /* WHERE */ array('tb_page' => $this->getID())
 998+ $dbr = wfGetDB( DB_SLAVE );
 999+ $tbs = $dbr->select( 'trackbacks',
 1000+ array('tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name'),
 1001+ array('tb_page' => $this->getID() )
10141002 );
 1003+ if( !$dbr->numRows($tbs) ) return;
10151004
1016 - if (!$dbr->numrows($tbs))
1017 - return;
1018 -
10191005 $tbtext = "";
1020 - while ($o = $dbr->fetchObject($tbs)) {
 1006+ while( $o = $dbr->fetchObject($tbs) ) {
10211007 $rmvtxt = "";
1022 - if ($wgUser->isAllowed( 'trackback' )) {
1023 - $delurl = $this->mTitle->getFullURL("action=deletetrackback&tbid="
1024 - . $o->tb_id . "&token=" . urlencode( $wgUser->editToken() ) );
 1008+ if( $wgUser->isAllowed( 'trackback' ) ) {
 1009+ $delurl = $this->mTitle->getFullURL("action=deletetrackback&tbid=" .
 1010+ $o->tb_id . "&token=" . urlencode( $wgUser->editToken() ) );
10251011 $rmvtxt = wfMsg( 'trackbackremove', htmlspecialchars( $delurl ) );
10261012 }
10271013 $tbtext .= "\n";
@@ -1032,33 +1018,31 @@
10331019 $rmvtxt);
10341020 }
10351021 $wgOut->addWikiMsg( 'trackbackbox', $tbtext );
 1022+ $this->mTitle->invalidateCache();
10361023 }
10371024
1038 - function deletetrackback() {
 1025+ public function deletetrackback() {
10391026 global $wgUser, $wgRequest, $wgOut, $wgTitle;
1040 -
1041 - if (!$wgUser->matchEditToken($wgRequest->getVal('token'))) {
 1027+ if( !$wgUser->matchEditToken($wgRequest->getVal('token')) ) {
10421028 $wgOut->addWikiMsg( 'sessionfailure' );
10431029 return;
10441030 }
10451031
10461032 $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
1047 -
1048 - if (count($permission_errors)>0)
1049 - {
 1033+ if( count($permission_errors) ) {
10501034 $wgOut->showPermissionsErrorPage( $permission_errors );
10511035 return;
10521036 }
10531037
1054 - $db = wfGetDB(DB_MASTER);
1055 - $db->delete('trackbacks', array('tb_id' => $wgRequest->getInt('tbid')));
1056 - $wgTitle->invalidateCache();
1057 - $wgOut->addWikiMsg('trackbackdeleteok');
 1038+ $db = wfGetDB( DB_MASTER );
 1039+ $db->delete( 'trackbacks', array('tb_id' => $wgRequest->getInt('tbid')) );
 1040+
 1041+ $wgOut->addWikiMsg( 'trackbackdeleteok' );
 1042+ $this->mTitle->invalidateCache();
10581043 }
10591044
1060 - function render() {
 1045+ public function render() {
10611046 global $wgOut;
1062 -
10631047 $wgOut->setArticleBodyOnly(true);
10641048 $this->view();
10651049 }
@@ -1066,10 +1050,9 @@
10671051 /**
10681052 * Handle action=purge
10691053 */
1070 - function purge() {
 1054+ public function purge() {
10711055 global $wgUser, $wgRequest, $wgOut;
1072 -
1073 - if ( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) {
 1056+ if( $wgUser->isAllowed( 'purge' ) || $wgRequest->wasPosted() ) {
10741057 if( wfRunHooks( 'ArticlePurge', array( &$this ) ) ) {
10751058 $this->doPurge();
10761059 $this->view();
@@ -1091,12 +1074,12 @@
10921075 /**
10931076 * Perform the actions of a page purging
10941077 */
1095 - function doPurge() {
 1078+ public function doPurge() {
10961079 global $wgUseSquid;
10971080 // Invalidate the cache
10981081 $this->mTitle->invalidateCache();
10991082
1100 - if ( $wgUseSquid ) {
 1083+ if( $wgUseSquid ) {
11011084 // Commit the transaction before the purge is sent
11021085 $dbw = wfGetDB( DB_MASTER );
11031086 $dbw->immediateCommit();
@@ -1105,9 +1088,9 @@
11061089 $update = SquidUpdate::newSimplePurge( $this->mTitle );
11071090 $update->doUpdate();
11081091 }
1109 - if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 1092+ if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
11101093 global $wgMessageCache;
1111 - if ( $this->getID() == 0 ) {
 1094+ if( $this->getID() == 0 ) {
11121095 $text = false;
11131096 } else {
11141097 $text = $this->getContent();
@@ -1127,7 +1110,7 @@
11281111 * @return int The newly created page_id key, or false if the title already existed
11291112 * @private
11301113 */
1131 - function insertOn( $dbw ) {
 1114+ public function insertOn( $dbw ) {
11321115 wfProfileIn( __METHOD__ );
11331116
11341117 $page_id = $dbw->nextSequenceValue( 'page_page_id_seq' );
@@ -1146,7 +1129,7 @@
11471130 ), __METHOD__, 'IGNORE' );
11481131
11491132 $affected = $dbw->affectedRows();
1150 - if ( $affected ) {
 1133+ if( $affected ) {
11511134 $newid = $dbw->insertId();
11521135 $this->mTitle->resetArticleId( $newid );
11531136 }
@@ -1169,7 +1152,7 @@
11701153 * @return bool true on success, false on failure
11711154 * @private
11721155 */
1173 - function updateRevisionOn( &$dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null ) {
 1156+ public function updateRevisionOn( &$dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null ) {
11741157 wfProfileIn( __METHOD__ );
11751158
11761159 $text = $revision->getText();
@@ -1193,8 +1176,7 @@
11941177 __METHOD__ );
11951178
11961179 $result = $dbw->affectedRows() != 0;
1197 -
1198 - if ($result) {
 1180+ if( $result ) {
11991181 $this->updateRedirectOn( $dbw, $rt, $lastRevIsRedirect );
12001182 }
12011183
@@ -1213,38 +1195,32 @@
12141196 * @return bool true on success, false on failure
12151197 * @private
12161198 */
1217 - function updateRedirectOn( &$dbw, $redirectTitle, $lastRevIsRedirect = null ) {
1218 -
 1199+ public function updateRedirectOn( &$dbw, $redirectTitle, $lastRevIsRedirect = null ) {
12191200 // Always update redirects (target link might have changed)
12201201 // Update/Insert if we don't know if the last revision was a redirect or not
12211202 // Delete if changing from redirect to non-redirect
12221203 $isRedirect = !is_null($redirectTitle);
1223 - if ($isRedirect || is_null($lastRevIsRedirect) || $lastRevIsRedirect !== $isRedirect) {
1224 -
 1204+ if($isRedirect || is_null($lastRevIsRedirect) || $lastRevIsRedirect !== $isRedirect) {
12251205 wfProfileIn( __METHOD__ );
1226 -
1227 - if ($isRedirect) {
1228 -
 1206+ if( $isRedirect ) {
12291207 // This title is a redirect, Add/Update row in the redirect table
12301208 $set = array( /* SET */
12311209 'rd_namespace' => $redirectTitle->getNamespace(),
12321210 'rd_title' => $redirectTitle->getDBkey(),
12331211 'rd_from' => $this->getId(),
12341212 );
1235 -
12361213 $dbw->replace( 'redirect', array( 'rd_from' ), $set, __METHOD__ );
12371214 } else {
12381215 // This is not a redirect, remove row from redirect table
12391216 $where = array( 'rd_from' => $this->getId() );
12401217 $dbw->delete( 'redirect', $where, __METHOD__);
12411218 }
1242 -
1243 - if( $this->getTitle()->getNamespace() == NS_IMAGE )
 1219+ if( $this->getTitle()->getNamespace() == NS_IMAGE ) {
12441220 RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $this->getTitle() );
 1221+ }
12451222 wfProfileOut( __METHOD__ );
12461223 return ( $dbw->affectedRows() != 0 );
12471224 }
1248 -
12491225 return true;
12501226 }
12511227
@@ -1255,9 +1231,8 @@
12561232 * @param Database $dbw
12571233 * @param Revision $revision
12581234 */
1259 - function updateIfNewerOn( &$dbw, $revision ) {
 1235+ public function updateIfNewerOn( &$dbw, $revision ) {
12601236 wfProfileIn( __METHOD__ );
1261 -
12621237 $row = $dbw->selectRow(
12631238 array( 'revision', 'page' ),
12641239 array( 'rev_id', 'rev_timestamp', 'page_is_redirect' ),
@@ -1277,7 +1252,6 @@
12781253 $prev = 0;
12791254 $lastRevIsRedirect = null;
12801255 }
1281 -
12821256 $ret = $this->updateRevisionOn( $dbw, $revision, $prev, $lastRevIsRedirect );
12831257 wfProfileOut( __METHOD__ );
12841258 return $ret;
@@ -1286,19 +1260,18 @@
12871261 /**
12881262 * @return string Complete article text, or null if error
12891263 */
1290 - function replaceSection($section, $text, $summary = '', $edittime = NULL) {
 1264+ function replaceSection( $section, $text, $summary = '', $edittime = NULL ) {
12911265 wfProfileIn( __METHOD__ );
1292 -
1293 - if( $section == '' ) {
1294 - // Whole-page edit; let the text through unmolested.
 1266+ if( $section === '' ) {
 1267+ // Whole-page edit; let the whole text through
12951268 } else {
1296 - if( is_null( $edittime ) ) {
 1269+ if( is_null($edittime) ) {
12971270 $rev = Revision::newFromTitle( $this->mTitle );
12981271 } else {
12991272 $dbw = wfGetDB( DB_MASTER );
13001273 $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime );
13011274 }
1302 - if( is_null( $rev ) ) {
 1275+ if( !$rev ) {
13031276 wfDebug( "Article::replaceSection asked for bogus section (page: " .
13041277 $this->getId() . "; section: $section; edittime: $edittime)\n" );
13051278 return null;
@@ -1316,9 +1289,7 @@
13171290 global $wgParser;
13181291 $text = $wgParser->replaceSection( $oldtext, $section, $text );
13191292 }
1320 -
13211293 }
1322 -
13231294 wfProfileOut( __METHOD__ );
13241295 return $text;
13251296 }
@@ -1327,27 +1298,28 @@
13281299 * @deprecated use Article::doEdit()
13291300 */
13301301 function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false, $bot=false ) {
 1302+ wfDeprecated( __METHOD__ );
13311303 $flags = EDIT_NEW | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
13321304 ( $isminor ? EDIT_MINOR : 0 ) |
13331305 ( $suppressRC ? EDIT_SUPPRESS_RC : 0 ) |
13341306 ( $bot ? EDIT_FORCE_BOT : 0 );
13351307
13361308 # If this is a comment, add the summary as headline
1337 - if ( $comment && $summary != "" ) {
 1309+ if( $comment && $summary != "" ) {
13381310 $text = wfMsgForContent('newsectionheaderdefaultlevel',$summary) . "\n\n".$text;
13391311 }
13401312
13411313 $this->doEdit( $text, $summary, $flags );
13421314
13431315 $dbw = wfGetDB( DB_MASTER );
1344 - if ($watchthis) {
1345 - if (!$this->mTitle->userIsWatching()) {
 1316+ if($watchthis) {
 1317+ if(!$this->mTitle->userIsWatching()) {
13461318 $dbw->begin();
13471319 $this->doWatch();
13481320 $dbw->commit();
13491321 }
13501322 } else {
1351 - if ( $this->mTitle->userIsWatching() ) {
 1323+ if( $this->mTitle->userIsWatching() ) {
13521324 $dbw->begin();
13531325 $this->doUnwatch();
13541326 $dbw->commit();
@@ -1360,24 +1332,25 @@
13611333 * @deprecated use Article::doEdit()
13621334 */
13631335 function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) {
 1336+ wfDeprecated( __METHOD__ );
13641337 $flags = EDIT_UPDATE | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
13651338 ( $minor ? EDIT_MINOR : 0 ) |
13661339 ( $forceBot ? EDIT_FORCE_BOT : 0 );
13671340
13681341 $status = $this->doEdit( $text, $summary, $flags );
1369 - if ( !$status->isOK() ) {
 1342+ if( !$status->isOK() ) {
13701343 return false;
13711344 }
13721345
13731346 $dbw = wfGetDB( DB_MASTER );
1374 - if ($watchthis) {
1375 - if (!$this->mTitle->userIsWatching()) {
 1347+ if($watchthis) {
 1348+ if(!$this->mTitle->userIsWatching()) {
13761349 $dbw->begin();
13771350 $this->doWatch();
13781351 $dbw->commit();
13791352 }
13801353 } else {
1381 - if ( $this->mTitle->userIsWatching() ) {
 1354+ if( $this->mTitle->userIsWatching() ) {
13821355 $dbw->begin();
13831356 $this->doUnwatch();
13841357 $dbw->commit();
@@ -1440,7 +1413,7 @@
14411414 *
14421415 * Compatibility note: this function previously returned a boolean value indicating success/failure
14431416 */
1444 - function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
 1417+ public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
14451418 global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries;
14461419
14471420 # Low-level sanity check
@@ -1450,30 +1423,27 @@
14511424
14521425 wfProfileIn( __METHOD__ );
14531426
1454 - if ($user == null) {
1455 - $user = $wgUser;
1456 - }
 1427+ $user = is_null($user) ? $wgUser : $user;
14571428 $status = Status::newGood( array() );
14581429
14591430 # Load $this->mTitle->getArticleID() and $this->mLatest if it's not already
14601431 $this->loadPageData();
14611432
1462 - if ( !($flags & EDIT_NEW) && !($flags & EDIT_UPDATE) ) {
 1433+ if( !($flags & EDIT_NEW) && !($flags & EDIT_UPDATE) ) {
14631434 $aid = $this->mTitle->getArticleID();
1464 - if ( $aid ) {
 1435+ if( $aid ) {
14651436 $flags |= EDIT_UPDATE;
14661437 } else {
14671438 $flags |= EDIT_NEW;
14681439 }
14691440 }
14701441
1471 - if( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text,
1472 - &$summary, $flags & EDIT_MINOR,
1473 - null, null, &$flags, &$status ) ) )
 1442+ if( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, &$summary,
 1443+ $flags & EDIT_MINOR, null, null, &$flags, &$status ) ) )
14741444 {
14751445 wfDebug( __METHOD__ . ": ArticleSave hook aborted save!\n" );
14761446 wfProfileOut( __METHOD__ );
1477 - if ( $status->isOK() ) {
 1447+ if( $status->isOK() ) {
14781448 $status->fatal( 'edit-hook-aborted');
14791449 }
14801450 return $status;
@@ -1498,10 +1468,9 @@
14991469 $dbw = wfGetDB( DB_MASTER );
15001470 $now = wfTimestampNow();
15011471
1502 - if ( $flags & EDIT_UPDATE ) {
 1472+ if( $flags & EDIT_UPDATE ) {
15031473 # Update article, but only if changed.
15041474 $status->value['new'] = false;
1505 -
15061475 # Make sure the revision is either completely inserted or not inserted at all
15071476 if( !$wgDBtransactions ) {
15081477 $userAbort = ignore_user_abort( true );
@@ -1511,12 +1480,12 @@
15121481
15131482 $changed = ( strcmp( $text, $oldtext ) != 0 );
15141483
1515 - if ( $changed ) {
 1484+ if( $changed ) {
15161485 $this->mGoodAdjustment = (int)$this->isCountable( $text )
15171486 - (int)$this->isCountable( $oldtext );
15181487 $this->mTotalAdjustment = 0;
15191488
1520 - if ( !$this->mLatest ) {
 1489+ if( !$this->mLatest ) {
15211490 # Article gone missing
15221491 wfDebug( __METHOD__.": EDIT_UPDATE specified but article doesn't exist\n" );
15231492 $status->fatal( 'edit-gone-missing' );
@@ -1550,7 +1519,7 @@
15511520 /* Belated edit conflict! Run away!! */
15521521 $status->fatal( 'edit-conflict' );
15531522 # Delete the invalid revision if the DB is not transactional
1554 - if ( !$wgDBtransactions ) {
 1523+ if( !$wgDBtransactions ) {
15551524 $dbw->delete( 'revision', array( 'rev_id' => $revisionId ), __METHOD__ );
15561525 }
15571526 $revisionId = 0;
@@ -1589,7 +1558,7 @@
15901559 ignore_user_abort( $userAbort );
15911560 }
15921561 // Now that ignore_user_abort is restored, we can respond to fatal errors
1593 - if ( !$status->isOK() ) {
 1562+ if( !$status->isOK() ) {
15941563 wfProfileOut( __METHOD__ );
15951564 return $status;
15961565 }
@@ -1615,7 +1584,7 @@
16161585 # This will return false if the article already exists
16171586 $newid = $this->insertOn( $dbw );
16181587
1619 - if ( $newid === false ) {
 1588+ if( $newid === false ) {
16201589 $dbw->rollback();
16211590 $status->fatal( 'edit-already-exists' );
16221591 wfProfileOut( __METHOD__ );
@@ -1666,7 +1635,7 @@
16671636 }
16681637
16691638 # Do updates right now unless deferral was requested
1670 - if ( !( $flags & EDIT_DEFER_UPDATES ) ) {
 1639+ if( !( $flags & EDIT_DEFER_UPDATES ) ) {
16711640 wfDoUpdates();
16721641 }
16731642
@@ -1683,7 +1652,8 @@
16841653 /**
16851654 * @deprecated wrapper for doRedirect
16861655 */
1687 - function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) {
 1656+ public function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) {
 1657+ wfDeprecated( __METHOD__ );
16881658 $this->doRedirect( $this->isRedirect( $text ), $sectionanchor );
16891659 }
16901660
@@ -1695,9 +1665,9 @@
16961666 * @param string $sectionAnchor section to redirect to, including "#"
16971667 * @param string $extraQuery, extra query params
16981668 */
1699 - function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) {
 1669+ public function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) {
17001670 global $wgOut;
1701 - if ( $noRedir ) {
 1671+ if( $noRedir ) {
17021672 $query = 'redirect=no';
17031673 if( $extraQuery )
17041674 $query .= "&$query";
@@ -1710,14 +1680,14 @@
17111681 /**
17121682 * Mark this particular edit/page as patrolled
17131683 */
1714 - function markpatrolled() {
 1684+ public function markpatrolled() {
17151685 global $wgOut, $wgRequest, $wgUseRCPatrol, $wgUseNPPatrol, $wgUser;
17161686 $wgOut->setRobotPolicy( 'noindex,nofollow' );
17171687
17181688 # If we haven't been given an rc_id value, we can't do anything
17191689 $rcid = (int) $wgRequest->getVal('rcid');
17201690 $rc = RecentChange::newFromId($rcid);
1721 - if ( is_null($rc) ) {
 1691+ if( is_null($rc) ) {
17221692 $wgOut->showErrorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
17231693 return;
17241694 }
@@ -1729,24 +1699,24 @@
17301700 $dbw = wfGetDB( DB_MASTER );
17311701 $errors = $rc->doMarkPatrolled();
17321702
1733 - if ( in_array(array('rcpatroldisabled'), $errors) ) {
 1703+ if( in_array(array('rcpatroldisabled'), $errors) ) {
17341704 $wgOut->showErrorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
17351705 return;
17361706 }
17371707
1738 - if ( in_array(array('hookaborted'), $errors) ) {
 1708+ if( in_array(array('hookaborted'), $errors) ) {
17391709 // The hook itself has handled any output
17401710 return;
17411711 }
17421712
1743 - if ( in_array(array('markedaspatrollederror-noautopatrol'), $errors) ) {
 1713+ if( in_array(array('markedaspatrollederror-noautopatrol'), $errors) ) {
17441714 $wgOut->setPageTitle( wfMsg( 'markedaspatrollederror' ) );
17451715 $wgOut->addWikiMsg( 'markedaspatrollederror-noautopatrol' );
17461716 $wgOut->returnToMain( false, $return );
17471717 return;
17481718 }
17491719
1750 - if ( !empty($errors) ) {
 1720+ if( !empty($errors) ) {
17511721 $wgOut->showPermissionsErrorPage( $errors );
17521722 return;
17531723 }
@@ -1761,26 +1731,21 @@
17621732 * User-interface handler for the "watch" action
17631733 */
17641734
1765 - function watch() {
1766 -
 1735+ public function watch() {
17671736 global $wgUser, $wgOut;
1768 -
1769 - if ( $wgUser->isAnon() ) {
 1737+ if( $wgUser->isAnon() ) {
17701738 $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
17711739 return;
17721740 }
1773 - if ( wfReadOnly() ) {
 1741+ if( wfReadOnly() ) {
17741742 $wgOut->readOnlyPage();
17751743 return;
17761744 }
1777 -
17781745 if( $this->doWatch() ) {
17791746 $wgOut->setPagetitle( wfMsg( 'addedwatch' ) );
17801747 $wgOut->setRobotPolicy( 'noindex,nofollow' );
1781 -
17821748 $wgOut->addWikiMsg( 'addedwatchtext', $this->mTitle->getPrefixedText() );
17831749 }
1784 -
17851750 $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );
17861751 }
17871752
@@ -1788,44 +1753,36 @@
17891754 * Add this page to $wgUser's watchlist
17901755 * @return bool true on successful watch operation
17911756 */
1792 - function doWatch() {
 1757+ public function doWatch() {
17931758 global $wgUser;
17941759 if( $wgUser->isAnon() ) {
17951760 return false;
17961761 }
1797 -
1798 - if (wfRunHooks('WatchArticle', array(&$wgUser, &$this))) {
 1762+ if( wfRunHooks('WatchArticle', array(&$wgUser, &$this)) ) {
17991763 $wgUser->addWatch( $this->mTitle );
1800 -
18011764 return wfRunHooks('WatchArticleComplete', array(&$wgUser, &$this));
18021765 }
1803 -
18041766 return false;
18051767 }
18061768
18071769 /**
18081770 * User interface handler for the "unwatch" action.
18091771 */
1810 - function unwatch() {
1811 -
 1772+ public function unwatch() {
18121773 global $wgUser, $wgOut;
1813 -
1814 - if ( $wgUser->isAnon() ) {
 1774+ if( $wgUser->isAnon() ) {
18151775 $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' );
18161776 return;
18171777 }
1818 - if ( wfReadOnly() ) {
 1778+ if( wfReadOnly() ) {
18191779 $wgOut->readOnlyPage();
18201780 return;
18211781 }
1822 -
18231782 if( $this->doUnwatch() ) {
18241783 $wgOut->setPagetitle( wfMsg( 'removedwatch' ) );
18251784 $wgOut->setRobotPolicy( 'noindex,nofollow' );
1826 -
18271785 $wgOut->addWikiMsg( 'removedwatchtext', $this->mTitle->getPrefixedText() );
18281786 }
1829 -
18301787 $wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );
18311788 }
18321789
@@ -1833,25 +1790,22 @@
18341791 * Stop watching a page
18351792 * @return bool true on successful unwatch
18361793 */
1837 - function doUnwatch() {
 1794+ public function doUnwatch() {
18381795 global $wgUser;
18391796 if( $wgUser->isAnon() ) {
18401797 return false;
18411798 }
1842 -
1843 - if (wfRunHooks('UnwatchArticle', array(&$wgUser, &$this))) {
 1799+ if( wfRunHooks('UnwatchArticle', array(&$wgUser, &$this)) ) {
18441800 $wgUser->removeWatch( $this->mTitle );
1845 -
18461801 return wfRunHooks('UnwatchArticleComplete', array(&$wgUser, &$this));
18471802 }
1848 -
18491803 return false;
18501804 }
18511805
18521806 /**
18531807 * action=protect handler
18541808 */
1855 - function protect() {
 1809+ public function protect() {
18561810 $form = new ProtectionForm( $this );
18571811 $form->execute();
18581812 }
@@ -1859,7 +1813,7 @@
18601814 /**
18611815 * action=unprotect handler (alias)
18621816 */
1863 - function unprotect() {
 1817+ public function unprotect() {
18641818 $this->protect();
18651819 }
18661820
@@ -1870,7 +1824,7 @@
18711825 * @param string $reason
18721826 * @return bool true on success
18731827 */
1874 - function updateRestrictions( $limit = array(), $reason = '', $cascade = 0, $expiry = array() ) {
 1828+ public function updateRestrictions( $limit = array(), $reason = '', $cascade = 0, $expiry = array() ) {
18751829 global $wgUser, $wgRestrictionTypes, $wgContLang;
18761830
18771831 $id = $this->mTitle->getArticleID();
@@ -1957,7 +1911,7 @@
19581912 $editComment .= "$cascade_description";
19591913 # Update restrictions table
19601914 foreach( $limit as $action => $restrictions ) {
1961 - if ($restrictions != '' ) {
 1915+ if($restrictions != '' ) {
19621916 $dbw->replace( 'page_restrictions', array(array('pr_page', 'pr_type')),
19631917 array( 'pr_page' => $id,
19641918 'pr_type' => $action,
@@ -2009,9 +1963,8 @@
20101964 * suitable for insertion into the page_restrictions field.
20111965 * @param array $limit
20121966 * @return string
2013 - * @private
20141967 */
2015 - function flattenRestrictions( $limit ) {
 1968+ protected static function flattenRestrictions( $limit ) {
20161969 if( !is_array( $limit ) ) {
20171970 throw new MWException( 'Article::flattenRestrictions given non-array restriction set' );
20181971 }
@@ -2104,7 +2057,7 @@
21052058 /*
21062059 * UI entry point for page deletion
21072060 */
2108 - function delete() {
 2061+ public function delete() {
21092062 global $wgUser, $wgOut, $wgRequest;
21102063
21112064 $confirm = $wgRequest->wasPosted() &&
@@ -2115,10 +2068,10 @@
21162069
21172070 $reason = $this->DeleteReasonList;
21182071
2119 - if ( $reason != 'other' && $this->DeleteReason != '') {
 2072+ if( $reason != 'other' && $this->DeleteReason != '') {
21202073 // Entry from drop down menu + additional comment
21212074 $reason .= ': ' . $this->DeleteReason;
2122 - } elseif ( $reason == 'other' ) {
 2075+ } elseif( $reason == 'other' ) {
21232076 $reason = $this->DeleteReason;
21242077 }
21252078 # Flag to hide all contents of the archived revisions
@@ -2127,7 +2080,7 @@
21282081 # This code desperately needs to be totally rewritten
21292082
21302083 # Read-only check...
2131 - if ( wfReadOnly() ) {
 2084+ if( wfReadOnly() ) {
21322085 $wgOut->readOnlyPage();
21332086 return;
21342087 }
@@ -2135,7 +2088,7 @@
21362089 # Check permissions
21372090 $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
21382091
2139 - if (count($permission_errors)>0) {
 2092+ if(count($permission_errors)>0) {
21402093 $wgOut->showPermissionsErrorPage( $permission_errors );
21412094 return;
21422095 }
@@ -2146,7 +2099,7 @@
21472100 $dbw = wfGetDB( DB_MASTER );
21482101 $conds = $this->mTitle->pageCond();
21492102 $latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ );
2150 - if ( $latest === false ) {
 2103+ if( $latest === false ) {
21512104 $wgOut->showFatalError( wfMsg( 'cannotdelete' ) );
21522105 return;
21532106 }
@@ -2172,7 +2125,7 @@
21732126
21742127 // Generate deletion reason
21752128 $hasHistory = false;
2176 - if ( !$reason ) $reason = $this->generateReason($hasHistory);
 2129+ if( !$reason ) $reason = $this->generateReason($hasHistory);
21772130
21782131 // If the page has a history, insert a warning
21792132 if( $hasHistory && !$confirm ) {
@@ -2191,7 +2144,7 @@
21922145 /**
21932146 * @return bool whether or not the page surpasses $wgDeleteRevisionsLimit revisions
21942147 */
2195 - function isBigDeletion() {
 2148+ public function isBigDeletion() {
21962149 global $wgDeleteRevisionsLimit;
21972150 if( $wgDeleteRevisionsLimit ) {
21982151 $revCount = $this->estimateRevisionCount();
@@ -2203,7 +2156,7 @@
22042157 /**
22052158 * @return int approximate revision count
22062159 */
2207 - function estimateRevisionCount() {
 2160+ public function estimateRevisionCount() {
22082161 $dbr = wfGetDB( DB_SLAVE );
22092162 // For an exact count...
22102163 //return $dbr->selectField( 'revision', 'COUNT(*)',
@@ -2218,9 +2171,8 @@
22192172 * @param string $revLatest The latest rev_id, selected from the master (optional)
22202173 * @return array Array of authors, duplicates not removed
22212174 */
2222 - function getLastNAuthors( $num, $revLatest = 0 ) {
 2175+ public function getLastNAuthors( $num, $revLatest = 0 ) {
22232176 wfProfileIn( __METHOD__ );
2224 -
22252177 // First try the slave
22262178 // If that doesn't have the latest revision, try the master
22272179 $continue = 2;
@@ -2237,12 +2189,12 @@
22382190 'LIMIT' => $num
22392191 ) )
22402192 );
2241 - if ( !$res ) {
 2193+ if( !$res ) {
22422194 wfProfileOut( __METHOD__ );
22432195 return array();
22442196 }
22452197 $row = $db->fetchObject( $res );
2246 - if ( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) {
 2198+ if( $continue == 2 && $revLatest && $row->rev_id != $revLatest ) {
22472199 $db = wfGetDB( DB_MASTER );
22482200 $continue--;
22492201 } else {
@@ -2262,7 +2214,7 @@
22632215 * Output deletion confirmation dialog
22642216 * @param $reason string Prefilled reason
22652217 */
2266 - function confirmDelete( $reason ) {
 2218+ public function confirmDelete( $reason ) {
22672219 global $wgOut, $wgUser;
22682220
22692221 wfDebug( "Article::confirmDelete\n" );
@@ -2328,21 +2280,22 @@
23292281 Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
23302282 Xml::closeElement( 'form' );
23312283
2332 - if ( $wgUser->isAllowed( 'editinterface' ) ) {
 2284+ if( $wgUser->isAllowed( 'editinterface' ) ) {
23332285 $skin = $wgUser->getSkin();
23342286 $link = $skin->makeLink ( 'MediaWiki:Deletereason-dropdown', wfMsgHtml( 'delete-edit-reasonlist' ) );
23352287 $form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
23362288 }
23372289
23382290 $wgOut->addHTML( $form );
2339 - $this->showLogExtract( $wgOut );
 2291+ LogEventsList::showLogExtract( $wgOut, 'delete', $this->mTitle->getPrefixedText() );
23402292 }
23412293
23422294
23432295 /**
23442296 * Show relevant lines from the deletion log
23452297 */
2346 - function showLogExtract( $out ) {
 2298+ public function showLogExtract( $out ) {
 2299+ wfDeprecated( __METHOD__ );
23472300 $out->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
23482301 LogEventsList::showLogExtract( $out, 'delete', $this->mTitle->getPrefixedText() );
23492302 }
@@ -2351,16 +2304,13 @@
23522305 /**
23532306 * Perform a deletion and output success or failure messages
23542307 */
2355 - function doDelete( $reason, $suppress = false ) {
 2308+ public function doDelete( $reason, $suppress = false ) {
23562309 global $wgOut, $wgUser;
2357 - wfDebug( __METHOD__."\n" );
2358 -
23592310 $id = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
23602311
23612312 $error = '';
2362 -
2363 - if ( wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason, &$error)) ) {
2364 - if ( $this->doDeleteArticle( $reason, $suppress, $id ) ) {
 2313+ if( wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason, &$error)) ) {
 2314+ if( $this->doDeleteArticle( $reason, $suppress, $id ) ) {
23652315 $deleted = $this->mTitle->getPrefixedText();
23662316
23672317 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
@@ -2372,7 +2322,7 @@
23732323 $wgOut->returnToMain( false );
23742324 wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason, $id));
23752325 } else {
2376 - if ($error == '')
 2326+ if( $error == '' )
23772327 $wgOut->showFatalError( wfMsg( 'cannotdelete' ) );
23782328 else
23792329 $wgOut->showFatalError( $error );
@@ -2385,7 +2335,7 @@
23862336 * Deletes the article with database consistency, writes logs, purges caches
23872337 * Returns success
23882338 */
2389 - function doDeleteArticle( $reason, $suppress = false, $id = 0 ) {
 2339+ public function doDeleteArticle( $reason, $suppress = false, $id = 0 ) {
23902340 global $wgUseSquid, $wgDeferredUpdateList;
23912341 global $wgUseTrackbacks;
23922342
@@ -2396,7 +2346,7 @@
23972347 $t = $this->mTitle->getDBkey();
23982348 $id = $id ? $id : $this->mTitle->getArticleID( GAID_FOR_UPDATE );
23992349
2400 - if ( $t == '' || $id == 0 ) {
 2350+ if( $t == '' || $id == 0 ) {
24012351 return false;
24022352 }
24032353
@@ -2404,7 +2354,7 @@
24052355 array_push( $wgDeferredUpdateList, $u );
24062356
24072357 // Bitfields to further suppress the content
2408 - if ( $suppress ) {
 2358+ if( $suppress ) {
24092359 $bitfield = 0;
24102360 // This should be 15...
24112361 $bitfield |= Revision::DELETED_TEXT;
@@ -2460,10 +2410,10 @@
24612411 }
24622412
24632413 # If using cascading deletes, we can skip some explicit deletes
2464 - if ( !$dbw->cascadingDeletes() ) {
 2414+ if( !$dbw->cascadingDeletes() ) {
24652415 $dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ );
24662416
2467 - if ($wgUseTrackbacks)
 2417+ if($wgUseTrackbacks)
24682418 $dbw->delete( 'trackbacks', array( 'tb_page' => $id ), __METHOD__ );
24692419
24702420 # Delete outgoing links
@@ -2477,7 +2427,7 @@
24782428 }
24792429
24802430 # If using cleanup triggers, we can skip some manual deletes
2481 - if ( !$dbw->cleanupTriggers() ) {
 2431+ if( !$dbw->cleanupTriggers() ) {
24822432 # Clean up recentchanges entries...
24832433 $dbw->delete( 'recentchanges',
24842434 array( 'rc_type != '.RC_LOG,
@@ -2547,7 +2497,7 @@
25482498 if( !$wgUser->matchEditToken( $token, array( $this->mTitle->getPrefixedText(), $fromP ) ) )
25492499 $errors[] = array( 'sessionfailure' );
25502500
2551 - if ( $wgUser->pingLimiter('rollback') || $wgUser->pingLimiter() ) {
 2501+ if( $wgUser->pingLimiter('rollback') || $wgUser->pingLimiter() ) {
25522502 $errors[] = array( 'actionthrottledtext' );
25532503 }
25542504 # If there were errors, bail out now
@@ -2597,7 +2547,7 @@
25982548 $s = $dbw->selectRow( 'revision',
25992549 array( 'rev_id', 'rev_timestamp', 'rev_deleted' ),
26002550 array( 'rev_page' => $current->getPage(),
2601 - "rev_user <> {$user} OR rev_user_text <> {$user_text}"
 2551+ "rev_user != {$user} OR rev_user_text != {$user_text}"
26022552 ), __METHOD__,
26032553 array( 'USE INDEX' => 'page_timestamp',
26042554 'ORDER BY' => 'rev_timestamp DESC' )
@@ -2611,16 +2561,16 @@
26122562 }
26132563
26142564 $set = array();
2615 - if ( $bot && $wgUser->isAllowed('markbotedits') ) {
 2565+ if( $bot && $wgUser->isAllowed('markbotedits') ) {
26162566 # Mark all reverted edits as bot
26172567 $set['rc_bot'] = 1;
26182568 }
2619 - if ( $wgUseRCPatrol ) {
 2569+ if( $wgUseRCPatrol ) {
26202570 # Mark all reverted edits as patrolled
26212571 $set['rc_patrolled'] = 1;
26222572 }
26232573
2624 - if ( $set ) {
 2574+ if( $set ) {
26252575 $dbw->update( 'recentchanges', $set,
26262576 array( /* WHERE */
26272577 'rc_cur_id' => $current->getPage(),
@@ -2654,7 +2604,7 @@
26552605 $flags |= EDIT_FORCE_BOT;
26562606 # Actually store the edit
26572607 $status = $this->doEdit( $target->getText(), $summary, $flags, $target->getId() );
2658 - if ( !empty( $status->value['revision'] ) ) {
 2608+ if( !empty( $status->value['revision'] ) ) {
26592609 $revId = $status->value['revision']->getId();
26602610 } else {
26612611 $revId = false;
@@ -2674,7 +2624,7 @@
26752625 /**
26762626 * User interface for rollback operations
26772627 */
2678 - function rollback() {
 2628+ public function rollback() {
26792629 global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol;
26802630 $details = null;
26812631
@@ -2749,12 +2699,10 @@
27502700
27512701 /**
27522702 * Do standard deferred updates after page view
2753 - * @private
27542703 */
2755 - function viewUpdates() {
 2704+ protected function viewUpdates() {
27562705 global $wgDeferredUpdateList, $wgUser;
2757 -
2758 - if ( 0 != $this->getID() ) {
 2706+ if( 0 != $this->getID() ) {
27592707 # Don't update page view counters on views from bot users (bug 14044)
27602708 global $wgDisableCounters;
27612709 if( !$wgDisableCounters && !$wgUser->isAllowed( 'bot' ) ) {
@@ -2763,7 +2711,6 @@
27642712 array_push( $wgDeferredUpdateList, $u );
27652713 }
27662714 }
2767 -
27682715 # Update newtalk / watchlist notification status
27692716 $wgUser->clearNotification( $this->mTitle );
27702717 }
@@ -2772,8 +2719,8 @@
27732720 * Prepare text which is about to be saved.
27742721 * Returns a stdclass with source, pst and output members
27752722 */
2776 - function prepareTextForEdit( $text, $revid=null ) {
2777 - if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid) {
 2723+ public function prepareTextForEdit( $text, $revid=null ) {
 2724+ if( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid) {
27782725 // Already prepared
27792726 return $this->mPreparedEdit;
27802727 }
@@ -2805,14 +2752,14 @@
28062753 * @param $newid rev_id value of the new revision
28072754 * @param $changed Whether or not the content actually changed
28082755 */
2809 - function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true ) {
 2756+ public function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true ) {
28102757 global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgParser, $wgEnableParserCache;
28112758
28122759 wfProfileIn( __METHOD__ );
28132760
28142761 # Parse the text
28152762 # Be careful not to double-PST: $text is usually already PST-ed once
2816 - if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) {
 2763+ if( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) {
28172764 wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" );
28182765 $editInfo = $this->prepareTextForEdit( $text, $newid );
28192766 } else {
@@ -2821,7 +2768,7 @@
28222769 }
28232770
28242771 # Save it to the parser cache
2825 - if ( $wgEnableParserCache ) {
 2772+ if( $wgEnableParserCache ) {
28262773 $parserCache = ParserCache::singleton();
28272774 $parserCache->save( $editInfo->output, $this, $wgUser );
28282775 }
@@ -2834,7 +2781,7 @@
28352782 wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $changed ) );
28362783
28372784 if( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) {
2838 - if ( 0 == mt_rand( 0, 99 ) ) {
 2785+ if( 0 == mt_rand( 0, 99 ) ) {
28392786 // Flush old entries from the `recentchanges` table; we do this on
28402787 // random requests so as to avoid an increase in writes for no good reason
28412788 global $wgRCMaxAge;
@@ -2850,7 +2797,7 @@
28512798 $title = $this->mTitle->getPrefixedDBkey();
28522799 $shortTitle = $this->mTitle->getDBkey();
28532800
2854 - if ( 0 == $id ) {
 2801+ if( 0 == $id ) {
28552802 wfProfileOut( __METHOD__ );
28562803 return;
28572804 }
@@ -2868,7 +2815,7 @@
28692816 && !( $minoredit && $wgUser->isAllowed( 'nominornewtalk' ) ) ) {
28702817 if( wfRunHooks('ArticleEditUpdateNewTalk', array( &$this ) ) ) {
28712818 $other = User::newFromName( $shortTitle, false );
2872 - if ( !$other ) {
 2819+ if( !$other ) {
28732820 wfDebug( __METHOD__.": invalid username\n" );
28742821 } elseif( User::isIP( $shortTitle ) ) {
28752822 // An anonymous user
@@ -2881,7 +2828,7 @@
28822829 }
28832830 }
28842831
2885 - if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 2832+ if( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
28862833 $wgMessageCache->replace( $shortTitle, $text );
28872834 }
28882835
@@ -2897,7 +2844,7 @@
28982845 * other shitty functions like editUpdates and such so it's not needed
28992846 * anymore.
29002847 */
2901 - function createUpdates( $rev ) {
 2848+ public function createUpdates( $rev ) {
29022849 $this->mGoodAdjustment = $this->isCountable( $rev->getText() );
29032850 $this->mTotalAdjustment = 1;
29042851 $this->editUpdates( $rev->getText(), $rev->getComment(),
@@ -2910,14 +2857,13 @@
29112858 * Revision as of \<date\>; view current revision
29122859 * \<- Previous version | Next Version -\>
29132860 *
2914 - * @private
29152861 * @param string $oldid Revision ID of this article revision
29162862 */
2917 - function setOldSubtitle( $oldid=0 ) {
 2863+ protected function setOldSubtitle( $oldid=0 ) {
29182864 global $wgLang, $wgOut, $wgUser;
29192865
2920 - if ( !wfRunHooks( 'DisplayOldSubtitle', array(&$this, &$oldid) ) ) {
2921 - return;
 2866+ if( !wfRunHooks( 'DisplayOldSubtitle', array(&$this, &$oldid) ) ) {
 2867+ return;
29222868 }
29232869
29242870 $revision = Revision::newFromId( $oldid );
@@ -2987,7 +2933,7 @@
29882934 *
29892935 * @param string $text
29902936 */
2991 - function preSaveTransform( $text ) {
 2937+ public function preSaveTransform( $text ) {
29922938 global $wgParser, $wgUser;
29932939 return $wgParser->preSaveTransform( $text, $this->mTitle, $wgUser, ParserOptions::newFromUser( $wgUser ) );
29942940 }
@@ -2999,7 +2945,7 @@
30002946 * output to the client that is necessary for this request.
30012947 * (that is, it has sent a cached version of the page)
30022948 */
3003 - function tryFileCache() {
 2949+ protected function tryFileCache() {
30042950 static $called = false;
30052951 if( $called ) {
30062952 wfDebug( "Article::tryFileCache(): called twice!?\n" );
@@ -3027,7 +2973,7 @@
30282974 * Check if the page can be cached
30292975 * @return bool
30302976 */
3031 - function isFileCacheable() {
 2977+ public function isFileCacheable() {
30322978 global $wgUser, $wgUseFileCache, $wgShowIPinHeader, $wgRequest, $wgLang, $wgContLang;
30332979 // Get all query values
30342980 $queryVals = $wgRequest->getValues();
@@ -3061,7 +3007,7 @@
30623008 * Loads page_touched and returns a value indicating if it should be used
30633009 *
30643010 */
3065 - function checkTouched() {
 3011+ public function checkTouched() {
30663012 if( !$this->mDataLoaded ) {
30673013 $this->loadPageData();
30683014 }
@@ -3071,7 +3017,7 @@
30723018 /**
30733019 * Get the page_touched field
30743020 */
3075 - function getTouched() {
 3021+ public function getTouched() {
30763022 # Ensure that page data has been loaded
30773023 if( !$this->mDataLoaded ) {
30783024 $this->loadPageData();
@@ -3082,8 +3028,8 @@
30833029 /**
30843030 * Get the page_latest field
30853031 */
3086 - function getLatest() {
3087 - if ( !$this->mDataLoaded ) {
 3032+ public function getLatest() {
 3033+ if( !$this->mDataLoaded ) {
30883034 $this->loadPageData();
30893035 }
30903036 return $this->mLatest;
@@ -3098,7 +3044,7 @@
30993045 * @param string $comment comment submitted
31003046 * @param bool $minor whereas it's a minor modification
31013047 */
3102 - function quickEdit( $text, $comment = '', $minor = 0 ) {
 3048+ public function quickEdit( $text, $comment = '', $minor = 0 ) {
31033049 wfProfileIn( __METHOD__ );
31043050
31053051 $dbw = wfGetDB( DB_MASTER );
@@ -3119,10 +3065,9 @@
31203066 /**
31213067 * Used to increment the view counter
31223068 *
3123 - * @static
31243069 * @param integer $id article id
31253070 */
3126 - function incViewCount( $id ) {
 3071+ public static function incViewCount( $id ) {
31273072 $id = intval( $id );
31283073 global $wgHitcounterUpdateFreq, $wgDBtype;
31293074
@@ -3155,14 +3100,14 @@
31563101 wfProfileIn( 'Article::incViewCount-collect' );
31573102 $old_user_abort = ignore_user_abort( true );
31583103
3159 - if ($wgDBtype == 'mysql')
 3104+ if($wgDBtype == 'mysql')
31603105 $dbw->query("LOCK TABLES $hitcounterTable WRITE");
31613106 $tabletype = $wgDBtype == 'mysql' ? "ENGINE=HEAP " : '';
31623107 $dbw->query("CREATE TEMPORARY TABLE $acchitsTable $tabletype AS ".
31633108 "SELECT hc_id,COUNT(*) AS hc_n FROM $hitcounterTable ".
31643109 'GROUP BY hc_id');
31653110 $dbw->query("DELETE FROM $hitcounterTable");
3166 - if ($wgDBtype == 'mysql') {
 3111+ if($wgDBtype == 'mysql') {
31673112 $dbw->query('UNLOCK TABLES');
31683113 $dbw->query("UPDATE $pageTable,$acchitsTable SET page_counter=page_counter + hc_n ".
31693114 'WHERE page_id = hc_id');
@@ -3193,7 +3138,7 @@
31943139
31953140 public static function onArticleCreate( $title ) {
31963141 # Update existence markers on article/talk tabs...
3197 - if ( $title->isTalkPage() ) {
 3142+ if( $title->isTalkPage() ) {
31983143 $other = $title->getSubjectPage();
31993144 } else {
32003145 $other = $title->getTalkPage();
@@ -3221,7 +3166,7 @@
32223167 $title->purgeSquid();
32233168
32243169 # File cache
3225 - if ( $wgUseFileCache ) {
 3170+ if( $wgUseFileCache ) {
32263171 $cm = new HTMLFileCache( $title );
32273172 @unlink( $cm->fileCacheName() );
32283173 }
@@ -3259,7 +3204,7 @@
32603205 $title->purgeSquid();
32613206
32623207 # Clear file cache for this page only
3263 - if ( $wgUseFileCache ) {
 3208+ if( $wgUseFileCache ) {
32643209 $cm = new HTMLFileCache( $title );
32653210 @unlink( $cm->fileCacheName() );
32663211 }
@@ -3271,7 +3216,7 @@
32723217 * Overriden by ImagePage class, only present here to avoid a fatal error
32733218 * Called for ?action=revert
32743219 */
3275 - public function revert(){
 3220+ public function revert() {
32763221 global $wgOut;
32773222 $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
32783223 }
@@ -3282,10 +3227,10 @@
32833228 *
32843229 * @public
32853230 */
3286 - function info() {
 3231+ public function info() {
32873232 global $wgLang, $wgOut, $wgAllowPageInfo, $wgUser;
32883233
3289 - if ( !$wgAllowPageInfo ) {
 3234+ if( !$wgAllowPageInfo ) {
32903235 $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
32913236 return;
32923237 }
@@ -3334,7 +3279,6 @@
33353280 $wgOut->addHTML( '<li>' . wfMsg('numtalkauthors', $wgLang->formatNum( $talkInfo['authors'] ) ) . '</li>' );
33363281 }
33373282 $wgOut->addHTML( '</ul>' );
3338 -
33393283 }
33403284 }
33413285
@@ -3344,32 +3288,28 @@
33453289 *
33463290 * @param Title $title
33473291 * @return array
3348 - * @private
33493292 */
3350 - function pageCountInfo( $title ) {
 3293+ protected function pageCountInfo( $title ) {
33513294 $id = $title->getArticleId();
33523295 if( $id == 0 ) {
33533296 return false;
33543297 }
3355 -
33563298 $dbr = wfGetDB( DB_SLAVE );
3357 -
33583299 $rev_clause = array( 'rev_page' => $id );
3359 -
33603300 $edits = $dbr->selectField(
33613301 'revision',
33623302 'COUNT(rev_page)',
33633303 $rev_clause,
33643304 __METHOD__,
3365 - $this->getSelectOptions() );
3366 -
 3305+ $this->getSelectOptions()
 3306+ );
33673307 $authors = $dbr->selectField(
33683308 'revision',
33693309 'COUNT(DISTINCT rev_user_text)',
33703310 $rev_clause,
33713311 __METHOD__,
3372 - $this->getSelectOptions() );
3373 -
 3312+ $this->getSelectOptions()
 3313+ );
33743314 return array( 'edits' => $edits, 'authors' => $authors );
33753315 }
33763316
@@ -3385,13 +3325,12 @@
33863326 if( $id == 0 ) {
33873327 return array();
33883328 }
3389 -
33903329 $dbr = wfGetDB( DB_SLAVE );
33913330 $res = $dbr->select( array( 'templatelinks' ),
33923331 array( 'tl_namespace', 'tl_title' ),
33933332 array( 'tl_from' => $id ),
33943333 __METHOD__ );
3395 - if( false !== $res ) {
 3334+ if( $res !== false ) {
33963335 foreach( $res as $row ) {
33973336 $result[] = Title::makeTitle( $row->tl_namespace, $row->tl_title );
33983337 }
@@ -3412,14 +3351,13 @@
34133352 if( $id == 0 ) {
34143353 return array();
34153354 }
3416 -
34173355 $dbr = wfGetDB( DB_SLAVE );
34183356 $res = $dbr->select( array( 'categorylinks', 'page_props', 'page' ),
34193357 array( 'cl_to' ),
34203358 array( 'cl_from' => $id, 'pp_page=page_id', 'pp_propname' => 'hiddencat',
34213359 'page_namespace' => NS_CATEGORY, 'page_title=cl_to'),
34223360 __METHOD__ );
3423 - if ( false !== $res ) {
 3361+ if( $res !== false ) {
34243362 foreach( $res as $row ) {
34253363 $result[] = Title::makeTitle( NS_CATEGORY, $row->cl_to );
34263364 }
@@ -3493,7 +3431,7 @@
34943432 $popts, true, true, $this->getRevIdFetched() );
34953433 $popts->setTidy(false);
34963434 $popts->enableLimitReport( false );
3497 - if ( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != -1 ) {
 3435+ if( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != -1 ) {
34983436 $parserCache = ParserCache::singleton();
34993437 $parserCache->save( $parserOutput, $this, $wgUser );
35003438 }
@@ -3504,7 +3442,7 @@
35053443 $wgUseFileCache = false;
35063444 }
35073445
3508 - if ( $this->isCurrent() && !wfReadOnly() && $this->mTitle->areRestrictionsCascading() ) {
 3446+ if( $this->isCurrent() && !wfReadOnly() && $this->mTitle->areRestrictionsCascading() ) {
35093447 // templatelinks table may have become out of sync,
35103448 // especially if using variable-based transclusions.
35113449 // For paranoia, check if things have changed and if
@@ -3525,7 +3463,7 @@
35263464
35273465 global $wgContLang;
35283466
3529 - if ( false !== $res ) {
 3467+ if( $res !== false ) {
35303468 foreach( $res as $row ) {
35313469 $tlTemplates[] = $wgContLang->getNsText( $row->tl_namespace ) . ':' . $row->tl_title ;
35323470 }
@@ -3542,7 +3480,7 @@
35433481 # Get the diff
35443482 $templates_diff = array_diff( $poTemplates, $tlTemplates );
35453483
3546 - if ( count( $templates_diff ) > 0 ) {
 3484+ if( count( $templates_diff ) > 0 ) {
35473485 # Whee, link updates time.
35483486 $u = new LinksUpdate( $this->mTitle, $parserOutput );
35493487 $u->doUpdate();
@@ -3591,7 +3529,7 @@
35923530 $removeFields[] = 'cat_files = cat_files - 1';
35933531 }
35943532
3595 - if ( $added ) {
 3533+ if( $added ) {
35963534 $dbw->update(
35973535 'category',
35983536 $addFields,
@@ -3599,7 +3537,7 @@
36003538 __METHOD__
36013539 );
36023540 }
3603 - if ( $deleted ) {
 3541+ if( $deleted ) {
36043542 $dbw->update(
36053543 'category',
36063544 $removeFields,
Index: trunk/phase3/includes/ImagePage.php
@@ -24,20 +24,20 @@
2525 }
2626
2727 protected function loadFile() {
28 - if ( $this->fileLoaded ) {
 28+ if( $this->fileLoaded ) {
2929 return true;
3030 }
3131 $this->fileLoaded = true;
3232
3333 $this->displayImg = $this->img = false;
3434 wfRunHooks( 'ImagePageFindFile', array( $this, &$this->img, &$this->displayImg ) );
35 - if ( !$this->img ) {
 35+ if( !$this->img ) {
3636 $this->img = wfFindFile( $this->mTitle );
37 - if ( !$this->img ) {
 37+ if( !$this->img ) {
3838 $this->img = wfLocalFile( $this->mTitle );
3939 }
4040 }
41 - if ( !$this->displayImg ) {
 41+ if( !$this->displayImg ) {
4242 $this->displayImg = $this->img;
4343 }
4444 $this->repo = $this->img->getRepo();
@@ -47,18 +47,18 @@
4848 * Handler for action=render
4949 * Include body text only; none of the image extras
5050 */
51 - function render() {
 51+ public function render() {
5252 global $wgOut;
5353 $wgOut->setArticleBodyOnly( true );
5454 parent::view();
5555 }
5656
57 - function view() {
 57+ public function view() {
5858 global $wgOut, $wgShowEXIF, $wgRequest, $wgUser;
5959 $this->loadFile();
6060
61 - if ( $this->mTitle->getNamespace() == NS_IMAGE && $this->img->getRedirected() ) {
62 - if ( $this->mTitle->getDBkey() == $this->img->getName() ) {
 61+ if( $this->mTitle->getNamespace() == NS_IMAGE && $this->img->getRedirected() ) {
 62+ if( $this->mTitle->getDBkey() == $this->img->getName() ) {
6363 // mTitle is the same as the redirect target so ask Article
6464 // to perform the redirect for us.
6565 return Article::view();
@@ -76,10 +76,10 @@
7777 $diff = $wgRequest->getVal( 'diff' );
7878 $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
7979
80 - if ( $this->mTitle->getNamespace() != NS_IMAGE || ( isset( $diff ) && $diffOnly ) )
 80+ if( $this->mTitle->getNamespace() != NS_IMAGE || ( isset( $diff ) && $diffOnly ) )
8181 return Article::view();
8282
83 - if ( $wgShowEXIF && $this->displayImg->exists() ) {
 83+ if( $wgShowEXIF && $this->displayImg->exists() ) {
8484 // FIXME: bad interface, see note on MediaHandler::formatMetadata().
8585 $formattedMetadata = $this->displayImg->formatMetadata();
8686 $showmeta = $formattedMetadata !== false;
@@ -87,13 +87,13 @@
8888 $showmeta = false;
8989 }
9090
91 - if ( $this->displayImg->exists() )
 91+ if( $this->displayImg->exists() )
9292 $wgOut->addHTML( $this->showTOC($showmeta) );
9393
9494 $this->openShowImage();
9595
9696 # No need to display noarticletext, we use our own message, output in openShowImage()
97 - if ( $this->getID() ) {
 97+ if( $this->getID() ) {
9898 Article::view();
9999 } else {
100100 # Just need to set the right headers
@@ -104,7 +104,7 @@
105105 }
106106
107107 # Show shared description, if needed
108 - if ( $this->mExtraDescription ) {
 108+ if( $this->mExtraDescription ) {
109109 $fol = wfMsgNoTrans( 'shareddescriptionfollows' );
110110 if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) {
111111 $wgOut->addWikiText( $fol );
@@ -124,12 +124,12 @@
125125 $this->imageDupes();
126126 // TODO: We may want to find local images redirecting to a foreign
127127 // file: "The following local files redirect to this file"
128 - if ( $this->img->isLocal() ) {
 128+ if( $this->img->isLocal() ) {
129129 $this->imageRedirects();
130130 }
131131 $this->imageLinks();
132132
133 - if ( $showmeta ) {
 133+ if( $showmeta ) {
134134 global $wgStylePath, $wgStyleVersion;
135135 $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
136136 $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
@@ -143,32 +143,32 @@
144144
145145 public function getRedirectTarget() {
146146 $this->loadFile();
147 - if ( $this->img->isLocal() ) {
 147+ if( $this->img->isLocal() ) {
148148 return parent::getRedirectTarget();
149149 }
150150 // Foreign image page
151151 $from = $this->img->getRedirected();
152152 $to = $this->img->getName();
153 - if ( $from == $to ) {
 153+ if( $from == $to ) {
154154 return null;
155155 }
156156 return $this->mRedirectTarget = Title::makeTitle( NS_IMAGE, $to );
157157 }
158158 public function followRedirect() {
159159 $this->loadFile();
160 - if ( $this->img->isLocal() ) {
 160+ if( $this->img->isLocal() ) {
161161 return parent::followRedirect();
162162 }
163163 $from = $this->img->getRedirected();
164164 $to = $this->img->getName();
165 - if ( $from == $to ) {
 165+ if( $from == $to ) {
166166 return false;
167167 }
168168 return Title::makeTitle( NS_IMAGE, $to );
169169 }
170170 public function isRedirect( $text = false ) {
171171 $this->loadFile();
172 - if ( $this->img->isLocal() )
 172+ if( $this->img->isLocal() )
173173 return parent::isRedirect( $text );
174174
175175 return (bool)$this->img->getRedirected();
@@ -191,10 +191,10 @@
192192
193193 public function getDuplicates() {
194194 $this->loadFile();
195 - if ( !is_null($this->dupes) ) {
 195+ if( !is_null($this->dupes) ) {
196196 return $this->dupes;
197197 }
198 - if ( !( $hash = $this->img->getSha1() ) ) {
 198+ if( !( $hash = $this->img->getSha1() ) ) {
199199 return $this->dupes = array();
200200 }
201201 $dupes = RepoGroup::singleton()->findBySha1( $hash );
@@ -203,9 +203,9 @@
204204 $size = $this->img->getSize();
205205 foreach ( $dupes as $index => $file ) {
206206 $key = $file->getRepoName().':'.$file->getName();
207 - if ( $key == $self )
 207+ if( $key == $self )
208208 unset( $dupes[$index] );
209 - if ( $file->getSize() != $size )
 209+ if( $file->getSize() != $size )
210210 unset( $dupes[$index] );
211211 }
212212 return $this->dupes = $dupes;
@@ -216,12 +216,10 @@
217217 /**
218218 * Create the TOC
219219 *
220 - * @access private
221 - *
222220 * @param bool $metadata Whether or not to show the metadata link
223221 * @return string
224222 */
225 - function showTOC( $metadata ) {
 223+ protected function showTOC( $metadata ) {
226224 global $wgLang;
227225 $r = '<ul id="filetoc">
228226 <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE ) . '</a></li>
@@ -237,12 +235,10 @@
238236 *
239237 * FIXME: bad interface, see note on MediaHandler::formatMetadata().
240238 *
241 - * @access private
242 - *
243239 * @param array $exif The array containing the EXIF data
244240 * @return string
245241 */
246 - function makeMetadataTable( $metadata ) {
 242+ protected function makeMetadataTable( $metadata ) {
247243 $r = wfMsg( 'metadata-help' ) . "\n\n";
248244 $r .= "{| id=mw_metadata class=mw_metadata\n";
249245 foreach ( $metadata as $type => $stuff ) {
@@ -266,7 +262,7 @@
267263 * Omit noarticletext if sharedupload; text will be fetched from the
268264 * shared upload server if possible.
269265 */
270 - function getContent() {
 266+ public function getContent() {
271267 $this->loadFile();
272268 if( $this->img && !$this->img->isLocal() && 0 == $this->getID() ) {
273269 return '';
@@ -274,7 +270,7 @@
275271 return Article::getContent();
276272 }
277273
278 - function openShowImage() {
 274+ protected function openShowImage() {
279275 global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang;
280276
281277 $this->loadFile();
@@ -298,10 +294,10 @@
299295 $sk = $wgUser->getSkin();
300296 $dirmark = $wgContLang->getDirMark();
301297
302 - if ( $this->displayImg->exists() ) {
 298+ if( $this->displayImg->exists() ) {
303299 # image
304300 $page = $wgRequest->getIntOrNull( 'page' );
305 - if ( is_null( $page ) ) {
 301+ if( is_null( $page ) ) {
306302 $params = array();
307303 $page = 1;
308304 } else {
@@ -318,16 +314,16 @@
319315
320316 wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this , &$wgOut ) ) ;
321317
322 - if ( $this->displayImg->allowInlineDisplay() ) {
 318+ if( $this->displayImg->allowInlineDisplay() ) {
323319 # image
324320
325321 # "Download high res version" link below the image
326322 #$msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->displayImg->getSize() ), $mime );
327323 # We'll show a thumbnail of this image
328 - if ( $width > $maxWidth || $height > $maxHeight ) {
 324+ if( $width > $maxWidth || $height > $maxHeight ) {
329325 # Calculate the thumbnail size.
330326 # First case, the limiting factor is the width, not the height.
331 - if ( $width / $height >= $maxWidth / $maxHeight ) {
 327+ if( $width / $height >= $maxWidth / $maxHeight ) {
332328 $height = round( $height * $maxWidth / $width);
333329 $width = $maxWidth;
334330 # Note that $height <= $maxHeight now.
@@ -361,11 +357,11 @@
362358 '<br />' . Xml::tags( 'a', $linkAttribs, $msgbig ) . "$dirmark " . $longDesc;
363359 }
364360
365 - if ( $this->displayImg->isMultipage() ) {
 361+ if( $this->displayImg->isMultipage() ) {
366362 $wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
367363 }
368364
369 - if ( $thumbnail ) {
 365+ if( $thumbnail ) {
370366 $options = array(
371367 'alt' => $this->displayImg->getTitle()->getPrefixedText(),
372368 'file-link' => true,
@@ -375,10 +371,10 @@
376372 $anchorclose . '</div>' );
377373 }
378374
379 - if ( $this->displayImg->isMultipage() ) {
 375+ if( $this->displayImg->isMultipage() ) {
380376 $count = $this->displayImg->pageCount();
381377
382 - if ( $page > 1 ) {
 378+ if( $page > 1 ) {
383379 $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
384380 $link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page-1) );
385381 $thumb1 = $sk->makeThumbLinkObj( $this->mTitle, $this->displayImg, $link, $label, 'none',
@@ -387,7 +383,7 @@
388384 $thumb1 = '';
389385 }
390386
391 - if ( $page < $count ) {
 387+ if( $page < $count ) {
392388 $label = wfMsg( 'imgmultipagenext' );
393389 $link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page+1) );
394390 $thumb2 = $sk->makeThumbLinkObj( $this->mTitle, $this->displayImg, $link, $label, 'none',
@@ -424,7 +420,7 @@
425421 }
426422 } else {
427423 #if direct link is allowed but it's not a renderable image, show an icon.
428 - if ( $this->displayImg->isSafeFile() ) {
 424+ if( $this->displayImg->isSafeFile() ) {
429425 $icon= $this->displayImg->iconThumb();
430426
431427 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
@@ -436,10 +432,10 @@
437433 }
438434
439435
440 - if ($showLink) {
 436+ if($showLink) {
441437 $filename = wfEscapeWikiText( $this->displayImg->getName() );
442438
443 - if ( !$this->displayImg->isSafeFile() ) {
 439+ if( !$this->displayImg->isSafeFile() ) {
444440 $warning = wfMsgNoTrans( 'mediawarning' );
445441 $wgOut->addWikiText( <<<EOT
446442 <div class="fullMedia">
@@ -476,7 +472,7 @@
477473 /**
478474 * Show a notice that the file is from a shared repository
479475 */
480 - function printSharedImageText() {
 476+ protected function printSharedImageText() {
481477 global $wgOut, $wgUser;
482478
483479 $this->loadFile();
@@ -484,12 +480,12 @@
485481 $descUrl = $this->img->getDescriptionUrl();
486482 $descText = $this->img->getDescriptionText();
487483 $s = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml( 'sharedupload' );
488 - if ( $descUrl ) {
 484+ if( $descUrl ) {
489485 $sk = $wgUser->getSkin();
490486 $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadwiki-linktext' ) );
491487 $msg = ( $descText ) ? 'shareduploadwiki-desc' : 'shareduploadwiki';
492488 $msg = wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link );
493 - if ( $msg != '-' ) {
 489+ if( $msg != '-' ) {
494490 # Show message only if not voided by local sysops
495491 $s .= $msg;
496492 }
@@ -497,7 +493,7 @@
498494 $s .= "</div>";
499495 $wgOut->addHTML( $s );
500496
501 - if ( $descText ) {
 497+ if( $descText ) {
502498 $this->mExtraDescription = $descText;
503499 }
504500 }
@@ -505,7 +501,7 @@
506502 /*
507503 * Check for files with the same name on the foreign repos.
508504 */
509 - function checkSharedConflict() {
 505+ protected function checkSharedConflict() {
510506 global $wgOut, $wgUser;
511507
512508 $repoGroup = RepoGroup::singleton();
@@ -540,7 +536,7 @@
541537 }
542538 }
543539
544 - function checkSharedConflictCallback( $repo ) {
 540+ protected function checkSharedConflictCallback( $repo ) {
545541 $this->loadFile();
546542 $dupfile = $repo->newFile( $this->img->getTitle() );
547543 if( $dupfile && $dupfile->exists() ) {
@@ -550,7 +546,7 @@
551547 return false;
552548 }
553549
554 - function getUploadUrl() {
 550+ public function getUploadUrl() {
555551 $this->loadFile();
556552 $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
557553 return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) );
@@ -560,7 +556,7 @@
561557 * Print out the various links at the bottom of the image page, e.g. reupload,
562558 * external editing (and instructions link) etc.
563559 */
564 - function uploadLinksBox() {
 560+ protected function uploadLinksBox() {
565561 global $wgUser, $wgOut;
566562
567563 $this->loadFile();
@@ -588,21 +584,18 @@
589585 $wgOut->addHTML( '</ul>' );
590586 }
591587
592 - function closeShowImage()
593 - {
594 - # For overloading
 588+ protected function closeShowImage() {} # For overloading
595589
596 - }
597 -
598590 /**
599591 * If the page we've just displayed is in the "Image" namespace,
600592 * we follow it with an upload history of the image and its usage.
601593 */
602 - function imageHistory() {
 594+ protected function imageHistory() {
603595 global $wgOut, $wgUseExternalEditor;
604596
605597 $this->loadFile();
606 - if ( $this->img->exists() ) {
 598+ $s = '';
 599+ if( $this->img->exists() ) {
607600 $list = new ImageHistoryList( $this );
608601 $file = $this->img;
609602 $s = $list->beginImageHistoryList();
@@ -613,7 +606,7 @@
614607 $s .= $list->imageHistoryLine( false, $file );
615608 }
616609 $s .= $list->endImageHistoryList();
617 - } else { $s=''; }
 610+ }
618611 $wgOut->addHTML( $s );
619612
620613 $this->img->resetHistory(); // free db resources
@@ -623,10 +616,9 @@
624617 if( $wgUseExternalEditor && $this->img->exists() ) {
625618 $this->uploadLinksBox();
626619 }
627 -
628620 }
629621
630 - function imageLinks() {
 622+ protected function imageLinks() {
631623 global $wgUser, $wgOut, $wgLang;
632624
633625 $limit = 100;
@@ -641,7 +633,7 @@
642634 array( 'LIMIT' => $limit + 1)
643635 );
644636 $count = $dbr->numRows( $res );
645 - if ( $count == 0 ) {
 637+ if( $count == 0 ) {
646638 $wgOut->addHTML( "<div id='mw-imagepage-nolinkstoimage'>\n" );
647639 $wgOut->addWikiMsg( 'nolinkstoimage' );
648640 $wgOut->addHTML( "</div>\n" );
@@ -649,7 +641,7 @@
650642 }
651643
652644 $wgOut->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" );
653 - if ( $count <= $limit - 1 ) {
 645+ if( $count <= $limit - 1 ) {
654646 $wgOut->addWikiMsg( 'linkstoimage', $count );
655647 } else {
656648 // More links than the limit. Add a link to [[Special:Whatlinkshere]]
@@ -664,7 +656,7 @@
665657 $count = 0;
666658 while ( $s = $res->fetchObject() ) {
667659 $count++;
668 - if ( $count <= $limit ) {
 660+ if( $count <= $limit ) {
669661 // We have not yet reached the extra one that tells us there is more to fetch
670662 $name = Title::makeTitle( $s->page_namespace, $s->page_title );
671663 $link = $sk->makeKnownLinkObj( $name, "" );
@@ -675,15 +667,15 @@
676668 $res->free();
677669
678670 // Add a links to [[Special:Whatlinkshere]]
679 - if ( $count > $limit )
 671+ if( $count > $limit )
680672 $wgOut->addWikiMsg( 'morelinkstoimage', $this->mTitle->getPrefixedDBkey() );
681673 }
682674
683 - function imageRedirects() {
 675+ protected function imageRedirects() {
684676 global $wgUser, $wgOut, $wgLang;
685677
686678 $redirects = $this->getTitle()->getRedirectsHere( NS_IMAGE );
687 - if ( count( $redirects ) == 0 ) return;
 679+ if( count( $redirects ) == 0 ) return;
688680
689681 $wgOut->addHTML( "<div id='mw-imagepage-section-redirectstofile'>\n" );
690682 $wgOut->addWikiMsg( 'redirectstofile',
@@ -700,13 +692,13 @@
701693
702694 }
703695
704 - function imageDupes() {
 696+ protected function imageDupes() {
705697 global $wgOut, $wgUser, $wgLang;
706698
707699 $this->loadFile();
708700
709701 $dupes = $this->getDuplicates();
710 - if ( count( $dupes ) == 0 ) return;
 702+ if( count( $dupes ) == 0 ) return;
711703
712704 $wgOut->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
713705 $wgOut->addWikiMsg( 'duplicatesoffile',
@@ -716,7 +708,7 @@
717709
718710 $sk = $wgUser->getSkin();
719711 foreach ( $dupes as $file ) {
720 - if ( $file->isLocal() )
 712+ if( $file->isLocal() )
721713 $link = $sk->makeKnownLinkObj( $file->getTitle(), "" );
722714 else {
723715 $link = $sk->makeExternalLink( $file->getDescriptionUrl(),
@@ -753,7 +745,7 @@
754746 /**
755747 * Override handling of action=purge
756748 */
757 - function doPurge() {
 749+ public function doPurge() {
758750 $this->loadFile();
759751 if( $this->img->exists() ) {
760752 wfDebug( "ImagePage::doPurge purging " . $this->img->getName() . "\n" );
@@ -799,15 +791,15 @@
800792 $this->imagePage = $imagePage;
801793 }
802794
803 - function getImagePage() {
 795+ public function getImagePage() {
804796 return $this->imagePage;
805797 }
806798
807 - function getSkin() {
 799+ public function getSkin() {
808800 return $this->skin;
809801 }
810802
811 - function getFile() {
 803+ public function getFile() {
812804 return $this->img;
813805 }
814806
@@ -961,7 +953,7 @@
962954 $row .= '</td><td>';
963955
964956 // Don't show deleted descriptions
965 - if ( $file->isDeleted(File::DELETED_COMMENT) ) {
 957+ if( $file->isDeleted(File::DELETED_COMMENT) ) {
966958 $row .= '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
967959 } else {
968960 $row .= $this->skin->commentBlock( $description, $this->title );

Follow-up revisions

RevisionCommit summaryAuthorDate
r44394API: (bug 16581) Fix regression from r44015 ("Various minor cleanup") which c...catrope14:12, 10 December 2008
r44486Fix regression from r44015 "Various minor cleanup/spacing"...brion00:55, 12 December 2008

Comments

#Comment by Platonides (talk | contribs)   22:22, 29 November 2008

This edit introduced bugzilla:16498 (setOldSubtitle is called from EditPage on line 1182), fixed on 44051-

#Comment by Catrope (talk | contribs)   17:49, 10 December 2008

Also caused [https://bugzilla.wikimedia.org/show_bug.cgi?id=16581 bug 16581] (API edit uses section=0 for non-section edit, flooding pages), fixed in [[Special:Code/MediaWiki/44394|r44394]].

#Comment by Catrope (talk | contribs)   18:52, 10 December 2008

WTF? CodeReview parsing bug?

#Comment by Brion VIBBER (talk | contribs)   18:28, 10 December 2008

I'd suggest doing widespread things like formatting cleanup in separate commits which don't make any functional changes, so it'll be a lot easier to review the changes that actually make behavior changes. It's easy to slip a little bug in when rearranging lots of things at once...

Status & tagging log