Reedy has uploaded a new change for review.
https://gerrit.wikimedia.org/r/55670
Change subject: Revert "Maintain the page ID in WikiPage instead of relying on
Title"
......................................................................
Revert "Maintain the page ID in WikiPage instead of relying on Title"
Likely cause of bug 46427.
This reverts commit c80efe3218c54f0b6fdc971e4a4ffb9ba390df1a
Change-Id: I2dbf8cac53f61662c0c6b8229bfb16b0336a42be
---
M includes/WikiPage.php
1 file changed, 21 insertions(+), 34 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/70/55670/1
diff --git a/includes/WikiPage.php b/includes/WikiPage.php
index 8d9d740..de881ef 100644
--- a/includes/WikiPage.php
+++ b/includes/WikiPage.php
@@ -51,11 +51,6 @@
/**@}}*/
/**
- * @var int
- */
- protected $mId = null;
-
- /**
* @var int; one of the READ_* constants
*/
protected $mDataLoadedFrom = self::READ_NONE;
@@ -233,7 +228,6 @@
* @return void
*/
protected function clearCacheFields() {
- $this->mId = null;
$this->mCounter = null;
$this->mRedirectTarget = null; // Title object if set
$this->mLastRevision = null; // Latest revision
@@ -387,11 +381,10 @@
// 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->mLatest = intval( $data->page_latest );
+ $this->mCounter = intval( $data->page_counter );
+ $this->mTouched = wfTimestamp( TS_MW,
$data->page_touched );
+ $this->mIsRedirect = intval( $data->page_is_redirect );
+ $this->mLatest = intval( $data->page_latest );
// Bug 37225: $latest may no longer match the cached
latest Revision object.
// Double-check the ID of any cached latest Revision
object for consistency.
if ( $this->mLastRevision &&
$this->mLastRevision->getId() != $this->mLatest ) {
@@ -404,8 +397,6 @@
$this->mTitle->loadFromRow( false );
$this->clearCacheFields();
-
- $this->mId = 0;
}
$this->mDataLoaded = true;
@@ -416,20 +407,14 @@
* @return int Page ID
*/
public function getId() {
- if ( !$this->mDataLoaded ) {
- $this->loadPageData();
- }
- return $this->mId;
+ return $this->mTitle->getArticleID();
}
/**
* @return bool Whether or not the page exists in the database
*/
public function exists() {
- if ( !$this->mDataLoaded ) {
- $this->loadPageData();
- }
- return $this->mId > 0;
+ return $this->mTitle->exists();
}
/**
@@ -441,7 +426,7 @@
* @return bool
*/
public function hasViewableContent() {
- return $this->exists() || $this->mTitle->isAlwaysKnown();
+ return $this->mTitle->exists() ||
$this->mTitle->isAlwaysKnown();
}
/**
@@ -1083,7 +1068,7 @@
return $wgEnableParserCache
&& $parserOptions->getStubThreshold() == 0
- && $this->exists()
+ && $this->mTitle->exists()
&& ( $oldid === null || $oldid === 0 || $oldid ===
$this->getLatest() )
&& $this->getContentHandler()->isParserCacheSupported();
}
@@ -1139,7 +1124,7 @@
}
// Don't update page view counters on views from bot users (bug
14044)
- if ( !$wgDisableCounters && !$user->isAllowed( 'bot' ) &&
$this->exists() ) {
+ if ( !$wgDisableCounters && !$user->isAllowed( 'bot' ) &&
$this->mTitle->exists() ) {
DeferredUpdates::addUpdate( new ViewCountUpdate(
$this->getId() ) );
DeferredUpdates::addUpdate( new SiteStatsUpdate( 1, 0,
0 ) );
}
@@ -1176,7 +1161,7 @@
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
// @todo: move this logic to MessageCache
- if ( $this->exists() ) {
+ if ( $this->mTitle->exists() ) {
// NOTE: use transclusion text for messages.
// This is consistent with
MessageCache::getMsgFromNamespace()
@@ -1225,7 +1210,6 @@
if ( $affected ) {
$newid = $dbw->insertId();
- $this->mId = $newid;
$this->mTitle->resetArticleID( $newid );
}
wfProfileOut( __METHOD__ );
@@ -1523,7 +1507,7 @@
*/
function checkFlags( $flags ) {
if ( !( $flags & EDIT_NEW ) && !( $flags & EDIT_UPDATE ) ) {
- if ( $this->exists() ) {
+ if ( $this->mTitle->getArticleID() ) {
$flags |= EDIT_UPDATE;
} else {
$flags |= EDIT_NEW;
@@ -2085,7 +2069,7 @@
}
}
- if ( !$this->exists() ) {
+ if ( !$this->mTitle->exists() ) {
wfProfileOut( __METHOD__ );
return;
}
@@ -2224,7 +2208,7 @@
$restrictionTypes = $this->mTitle->getRestrictionTypes();
- $id = $this->getId();
+ $id = $this->mTitle->getArticleID();
if ( !$cascade ) {
$cascade = false;
@@ -2605,7 +2589,7 @@
// Now that it's safely backed up, delete it
$dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__ );
- $ok = ( $dbw->affectedRows() > 0 ); // $id could be laggy
+ $ok = ( $dbw->affectedRows() > 0 ); // getArticleID() uses
slave, could be laggy
if ( !$ok ) {
$dbw->rollback( __METHOD__ );
@@ -2652,8 +2636,11 @@
// Clear caches
WikiPage::onArticleDelete( $this->mTitle );
- // Reset this object and the Title object
- $this->loadFromRow( false, self::READ_LATEST );
+ // Reset this object
+ $this->clear();
+
+ // Clear the cached article id so the interface doesn't act
like we exist
+ $this->mTitle->resetArticleID( 0 );
}
/**
@@ -2957,7 +2944,7 @@
*/
public function getHiddenCategories() {
$result = array();
- $id = $this->getId();
+ $id = $this->mTitle->getArticleID();
if ( $id == 0 ) {
return array();
@@ -3101,7 +3088,7 @@
// are visible.
// Get templates from templatelinks
- $id = $this->getId();
+ $id = $this->mTitle->getArticleID();
$tlTemplates = array();
--
To view, visit https://gerrit.wikimedia.org/r/55670
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2dbf8cac53f61662c0c6b8229bfb16b0336a42be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_21
Gerrit-Owner: Reedy <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits