/**@{{
* @protected
*/
- public $mCounter = -1; // !< Integer (-1 means "not loaded")
public $mDataLoaded = false; // !< Boolean
public $mIsRedirect = false; // !< Boolean
public $mLatest = false; // !< Integer (false means "not loaded")
public function clear() {
$this->mDataLoaded = false;
- $this->mCounter = -1; # Not loaded
$this->mRedirectTarget = null; # Title object if set
$this->mLastRevision = null; # Latest revision
$this->mTimestamp = '';
# Old-fashioned restrictions
$this->mTitle->loadRestrictions( $data->page_restrictions );
- $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 );
* @return bool Whether or not the page exists in the database
*/
public function exists() {
- return $this->getId() > 0;
+ return $this->mTitle->exists();
}
/**
* @return bool
*/
public function hasViewableContent() {
- return $this->exists() || $this->mTitle->isAlwaysKnown();
+ return $this->mTitle->exists() || $this->mTitle->isAlwaysKnown();
}
/**
+ * Get the number of views of this page
+ *
* @return int The view count for the page
*/
public function getCount() {
- if ( -1 == $this->mCounter ) {
- $id = $this->getId();
-
- if ( $id == 0 ) {
- $this->mCounter = 0;
- } else {
- $dbr = wfGetDB( DB_SLAVE );
- $this->mCounter = $dbr->selectField( 'page',
- 'page_counter',
- array( 'page_id' => $id ),
- __METHOD__
- );
- }
- }
-
- return $this->mCounter;
+ return $this->mTitle->getCount();
}
/**
return $wgEnableParserCache
&& $parserOptions->getStubThreshold() == 0
- && $this->exists()
+ && $this->mTitle->exists()
&& ( $oldid === null || $oldid === 0 || $oldid === $this->getLatest() )
&& $this->mTitle->isWikitextPage();
}
/**
* Get a ParserOutput for the given ParserOptions and revision ID.
- * The the parser cache will be used if possible.
+ * The parser cache will be used if possible.
*
* @since 1.19
* @param $parserOptions ParserOptions to use for the parse operation
* @return ParserOutput or false if the revision was not found
*/
public function getParserOutput( ParserOptions $parserOptions, $oldid = null ) {
- global $wgParser;
-
wfProfileIn( __METHOD__ );
$useParserCache = $this->isParserCacheUsed( $parserOptions, $oldid );
}
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
- if ( $this->getId() == 0 ) {
- $text = false;
- } else {
+ if ( $this->mTitle->exists() ) {
$text = $this->getRawText();
+ } else {
+ $text = false;
}
MessageCache::singleton()->replace( $this->mTitle->getDBkey(), $text );
public function doDeleteArticle(
$reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null
) {
- global $wgUseTrackbacks, $wgUser;
+ global $wgUser;
$user = is_null( $user ) ? $wgUser : $user;
wfDebug( __METHOD__ . "\n" );
if ( !$dbw->cascadingDeletes() ) {
$dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ );
- if ( $wgUseTrackbacks ) {
- $dbw->delete( 'trackbacks', array( 'tb_page' => $id ), __METHOD__ );
- }
-
# Delete outgoing links
$dbw->delete( 'pagelinks', array( 'pl_from' => $id ), __METHOD__ );
$dbw->delete( 'imagelinks', array( 'il_from' => $id ), __METHOD__ );
}
# Don't update page view counters on views from bot users (bug 14044)
- if ( !$wgDisableCounters && !$user->isAllowed( 'bot' ) && $this->getId() ) {
+ if ( !$wgDisableCounters && !$user->isAllowed( 'bot' ) && $this->mTitle->exists() ) {
DeferredUpdates::addUpdate( new ViewCountUpdate( $this->getId() ) );
DeferredUpdates::addUpdate( new SiteStatsUpdate( 1, 0, 0 ) );
}
$edit->newText = $text;
$edit->pst = $wgParser->preSaveTransform( $text, $this->mTitle, $user, $popts );
$edit->popts = $this->makeParserOptions( 'canonical' );
- $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid );
+
+ // Bug 32858: For a CSS/JS page, put a blank parser output into the
+ // prepared edit, so that links etc. won't be registered in the
+ // database. We could have set $edit->output to false or something if
+ // we thought of this bug earlier, but now that would break the
+ // interface with AbuseFilter etc.
+ if ( $this->mTitle->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage() ) {
+ $input = '';
+ } else {
+ $input = $edit->pst;
+ }
+ $edit->output = $wgParser->parse( $input, $this->mTitle, $edit->popts, true, true, $revid );
$edit->oldText = $this->getRawText();
$this->mPreparedEdit = $edit;
}
}
- $id = $this->getId();
- $title = $this->mTitle->getPrefixedDBkey();
- $shortTitle = $this->mTitle->getDBkey();
-
- if ( 0 == $id ) {
+ if ( !$this->mTitle->exists() ) {
wfProfileOut( __METHOD__ );
return;
}
+ $id = $this->getId();
+ $title = $this->mTitle->getPrefixedDBkey();
+ $shortTitle = $this->mTitle->getDBkey();
+
if ( !$options['changed'] ) {
$good = 0;
$total = 0;
# User talk pages
if ( $title->getNamespace() == NS_USER_TALK ) {
$user = User::newFromName( $title->getText(), false );
- $user->setNewtalk( false );
+ if ( $user ) {
+ $user->setNewtalk( false );
+ }
}
# Image redirects