public $mPreparedEdit = false; // !< Array
/**@}}*/
+ /**
+ * @var int
+ */
+ protected $mId = null;
+
/**
* @var int; one of the READ_* constants
*/
* @return void
*/
protected function clearCacheFields() {
+ $this->mId = null;
$this->mCounter = null;
$this->mRedirectTarget = null; // Title object if set
$this->mLastRevision = null; // Latest revision
// Old-fashioned restrictions
$this->mTitle->loadRestrictions( $data->page_restrictions );
+ $this->mId = intval( $data->page_id );
$this->mCounter = intval( $data->page_counter );
$this->mTouched = wfTimestamp( TS_MW, $data->page_touched );
$this->mIsRedirect = intval( $data->page_is_redirect );
$this->mTitle->loadFromRow( false );
$this->clearCacheFields();
+
+ $this->mId = 0;
}
$this->mDataLoaded = true;
* @return int Page ID
*/
public function getId() {
- return $this->mTitle->getArticleID();
+ if ( !$this->mDataLoaded ) {
+ $this->loadPageData();
+ }
+ return $this->mId;
}
/**
* @return bool Whether or not the page exists in the database
*/
public function exists() {
- return $this->mTitle->exists();
+ if ( !$this->mDataLoaded ) {
+ $this->loadPageData();
+ }
+ return $this->mId > 0;
}
/**
* @return bool
*/
public function hasViewableContent() {
- return $this->mTitle->exists() || $this->mTitle->isAlwaysKnown();
+ return $this->exists() || $this->mTitle->isAlwaysKnown();
}
/**
return $wgEnableParserCache
&& $parserOptions->getStubThreshold() == 0
- && $this->mTitle->exists()
+ && $this->exists()
&& ( $oldid === null || $oldid === 0 || $oldid === $this->getLatest() )
&& $this->getContentHandler()->isParserCacheSupported();
}
}
// Don't update page view counters on views from bot users (bug 14044)
- if ( !$wgDisableCounters && !$user->isAllowed( 'bot' ) && $this->mTitle->exists() ) {
+ if ( !$wgDisableCounters && !$user->isAllowed( 'bot' ) && $this->exists() ) {
DeferredUpdates::addUpdate( new ViewCountUpdate( $this->getId() ) );
DeferredUpdates::addUpdate( new SiteStatsUpdate( 1, 0, 0 ) );
}
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
// @todo: move this logic to MessageCache
- if ( $this->mTitle->exists() ) {
+ if ( $this->exists() ) {
// NOTE: use transclusion text for messages.
// This is consistent with MessageCache::getMsgFromNamespace()
if ( $affected ) {
$newid = $dbw->insertId();
+ $this->mId = $newid;
$this->mTitle->resetArticleID( $newid );
}
wfProfileOut( __METHOD__ );
*/
function checkFlags( $flags ) {
if ( !( $flags & EDIT_NEW ) && !( $flags & EDIT_UPDATE ) ) {
- if ( $this->mTitle->getArticleID() ) {
+ if ( $this->exists() ) {
$flags |= EDIT_UPDATE;
} else {
$flags |= EDIT_NEW;
}
}
- if ( !$this->mTitle->exists() ) {
+ if ( !$this->exists() ) {
wfProfileOut( __METHOD__ );
return;
}
$restrictionTypes = $this->mTitle->getRestrictionTypes();
- $id = $this->mTitle->getArticleID();
+ $id = $this->getId();
if ( !$cascade ) {
$cascade = false;
// Now that it's safely backed up, delete it
$dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__ );
- $ok = ( $dbw->affectedRows() > 0 ); // getArticleID() uses slave, could be laggy
+ $ok = ( $dbw->affectedRows() > 0 ); // $id could be laggy
if ( !$ok ) {
$dbw->rollback( __METHOD__ );
// Clear caches
WikiPage::onArticleDelete( $this->mTitle );
- // Reset this object
- $this->clear();
-
- // Clear the cached article id so the interface doesn't act like we exist
- $this->mTitle->resetArticleID( 0 );
+ // Reset this object and the Title object
+ $this->loadFromRow( false, self::READ_LATEST );
}
/**
*/
public function getHiddenCategories() {
$result = array();
- $id = $this->mTitle->getArticleID();
+ $id = $this->getId();
if ( $id == 0 ) {
return array();
// are visible.
// Get templates from templatelinks
- $id = $this->mTitle->getArticleID();
+ $id = $this->getId();
$tlTemplates = array();