r105759 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105758‎ | r105759 | r105760 >
Date:09:35, 10 December 2011
Author:ialex
Status:ok
Tags:
Comment:
* Changed WikiPage::exists() to call Title::exists()
* Changed some getId() calls to exists() and call that method directly on $mTitle
Modified paths:
  • /trunk/phase3/includes/WikiPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WikiPage.php
@@ -404,7 +404,7 @@
405405 * @return bool Whether or not the page exists in the database
406406 */
407407 public function exists() {
408 - return $this->getId() > 0;
 408+ return $this->mTitle->exists();
409409 }
410410
411411 /**
@@ -416,7 +416,7 @@
417417 * @return bool
418418 */
419419 public function hasViewableContent() {
420 - return $this->exists() || $this->mTitle->isAlwaysKnown();
 420+ return $this->mTitle->exists() || $this->mTitle->isAlwaysKnown();
421421 }
422422
423423 /**
@@ -717,7 +717,7 @@
718718
719719 return $wgEnableParserCache
720720 && $parserOptions->getStubThreshold() == 0
721 - && $this->exists()
 721+ && $this->mTitle->exists()
722722 && ( $oldid === null || $oldid === 0 || $oldid === $this->getLatest() )
723723 && $this->mTitle->isWikitextPage();
724724 }
@@ -786,10 +786,10 @@
787787 }
788788
789789 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
790 - if ( $this->getId() == 0 ) {
 790+ if ( $this->mTitle->exists() ) {
 791+ $text = $this->getRawText();
 792+ } else {
791793 $text = false;
792 - } else {
793 - $text = $this->getRawText();
794794 }
795795
796796 MessageCache::singleton()->replace( $this->mTitle->getDBkey(), $text );
@@ -1985,7 +1985,7 @@
19861986 }
19871987
19881988 # Don't update page view counters on views from bot users (bug 14044)
1989 - if ( !$wgDisableCounters && !$user->isAllowed( 'bot' ) && $this->getId() ) {
 1989+ if ( !$wgDisableCounters && !$user->isAllowed( 'bot' ) && $this->mTitle->exists() ) {
19901990 DeferredUpdates::addUpdate( new ViewCountUpdate( $this->getId() ) );
19911991 DeferredUpdates::addUpdate( new SiteStatsUpdate( 1, 0, 0 ) );
19921992 }
@@ -2100,15 +2100,15 @@
21012101 }
21022102 }
21032103
 2104+ if ( !$this->mTitle->exists() ) {
 2105+ wfProfileOut( __METHOD__ );
 2106+ return;
 2107+ }
 2108+
21042109 $id = $this->getId();
21052110 $title = $this->mTitle->getPrefixedDBkey();
21062111 $shortTitle = $this->mTitle->getDBkey();
21072112
2108 - if ( 0 == $id ) {
2109 - wfProfileOut( __METHOD__ );
2110 - return;
2111 - }
2112 -
21132113 if ( !$options['changed'] ) {
21142114 $good = 0;
21152115 $total = 0;

Status & tagging log