class WikiPage extends Page {
/**
* @var Title
- * @protected
*/
public $mTitle = null;
public $mCounter = -1; // !< Integer (-1 means "not loaded")
public $mDataLoaded = false; // !< Boolean
public $mIsRedirect = false; // !< Boolean
- public $mLatest = false; // !< Boolean
+ public $mLatest = false; // !< Integer (false means "not loaded")
public $mPreparedEdit = false; // !< Array
- public $mRedirectTarget = null; // !< Title object
- public $mLastRevision = null; // !< Revision object
- public $mTimestamp = ''; // !< String
- public $mTouched = '19700101000000'; // !< String
- /**@}}*/
/**
- * @protected
- * @var ParserOptions: ParserOptions object for $wgUser articles
+ * @var Title
*/
- public $mParserOptions;
+ protected $mRedirectTarget = null;
+
+ /**
+ * @var Revision
+ */
+ protected $mLastRevision = null;
+
+ protected $mTimestamp = ''; // !< String
+ protected $mTouched = '19700101000000'; // !< String
+ /**@}}*/
/**
* Constructor and clear the article
return $rt->getFullURL( 'rdfrom=' . urlencode( $source ) );
}
} else {
- if ( $rt->getNamespace() == NS_SPECIAL ) {
+ if ( $rt->isSpecialPage() ) {
// Gotta handle redirects to special pages differently:
// Fill the HTTP response "Location" header and ignore
// the rest of the page we're on.
* Should the parser cache be used?
*
* @param $user User The relevant user
+ * @param $oldid int
* @return boolean
*/
public function isParserCacheUsed( User $user, $oldid ) {
return $wgEnableParserCache
&& $user->getStubThreshold() == 0
&& $this->exists()
- && empty( $oldid )
+ && ( $oldid === null || $oldid === 0 || $oldid === $this->getLatest() )
&& $this->mTitle->isWikitextPage();
}
*
* @param $dbw DatabaseBase
* @return int The newly created page_id key, or false if the title already existed
- * @private
*/
public function insertOn( $dbw ) {
wfProfileIn( __METHOD__ );
if ( $section == 'new' ) {
# Inserting a new section
$subject = $summary ? wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" : '';
- $text = strlen( trim( $oldtext ) ) > 0
+ if ( wfRunHooks( 'PlaceNewSection', array( $this, $oldtext, $subject, &$text ) ) ) {
+ $text = strlen( trim( $oldtext ) ) > 0
? "{$oldtext}\n\n{$subject}{$text}"
: "{$subject}{$text}";
+ }
} else {
# Replacing an existing section; roll out the big guns
global $wgParser;
$status = Status::newGood( array() );
# Load $this->mTitle->getArticleID() and $this->mLatest if it's not already
- $this->loadPageData();
+ $this->loadPageData( 'fromdbmaster' );
$flags = $this->checkFlags( $flags );
*/
public function estimateRevisionCount() {
$dbr = wfGetDB( DB_SLAVE );
-
- // For an exact count...
- // return $dbr->selectField( 'revision', 'COUNT(*)',
- // array( 'rev_page' => $this->getId() ), __METHOD__ );
return $dbr->estimateRowCount( 'revision', '*',
array( 'rev_page' => $this->getId() ), __METHOD__ );
}
* Deletes the article with database consistency, writes logs, purges caches
*
* @param $reason string delete reason for deletion log
- * @param suppress bitfield
+ * @param $suppress bitfield
* Revision::DELETED_TEXT
* Revision::DELETED_COMMENT
* Revision::DELETED_USER
public function doDeleteArticle(
$reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null
) {
- global $wgUseTrackbacks, $wgEnableInterwikiTemplatesTracking, $wgGlobalDatabase, $wgUser;
+ global $wgUseTrackbacks, $wgUser;
$user = is_null( $user ) ? $wgUser : $user;
wfDebug( __METHOD__ . "\n" );
'ar_flags' => '\'\'', // MySQL's "strict mode"...
'ar_len' => 'rev_len',
'ar_page_id' => 'page_id',
- 'ar_deleted' => $bitfield
+ 'ar_deleted' => $bitfield,
+ 'ar_sha1' => 'rev_sha1'
), array(
'page_id' => $id,
'page_id = rev_page'
$dbw->delete( 'iwlinks', array( 'iwl_from' => $id ), __METHOD__ );
$dbw->delete( 'redirect', array( 'rd_from' => $id ), __METHOD__ );
$dbw->delete( 'page_props', array( 'pp_page' => $id ), __METHOD__ );
-
- if ( $wgEnableInterwikiTemplatesTracking && $wgGlobalDatabase ) {
- $dbw2 = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase );
- $dbw2->delete( 'globaltemplatelinks',
- array( 'gtl_from_wiki' => wfGetID(),
- 'gtl_from_page' => $id )
- );
- }
}
# If using cleanup triggers, we can skip some manual deletes
* roll back to, e.g. user is the sole contributor. This function
* performs permissions checks on $user, then calls commitRollback()
* to do the dirty work
+ *
+ * @todo: seperate the business/permission stuff out from backend code
*
* @param $fromP String: Name of the user whose edits to rollback.
* @param $summary String: Custom summary. Set to default summary if empty.
* Returns a stdclass with source, pst and output members
*/
public function prepareTextForEdit( $text, $revid = null, User $user = null ) {
- global $wgParser, $wgUser;
+ global $wgParser, $wgContLang, $wgUser;
$user = is_null( $user ) ? $wgUser : $user;
// @TODO fixme: check $user->getId() here???
if ( $this->mPreparedEdit
return $this->mPreparedEdit;
}
- $popts = ParserOptions::newFromUser( $user );
+ $popts = ParserOptions::newFromUserAndLang( $user, $wgContLang );
wfRunHooks( 'ArticlePrepareTextForEdit', array( $this, $popts ) );
$edit = (object)array();
$title->touchLinks();
$title->purgeSquid();
$title->deleteTitleProtection();
-
- # Invalidate caches of distant articles which transclude this page
- DeferredUpdates::addHTMLCacheUpdate( $title, 'globaltemplatelinks' );
}
/**
# Image redirects
RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $title );
-
- # Invalidate caches of distant articles which transclude this page
- DeferredUpdates::addHTMLCacheUpdate( $title, 'globaltemplatelinks' );
}
/**
// Invalidate caches of articles which include this page
DeferredUpdates::addHTMLCacheUpdate( $title, 'templatelinks' );
- // Invalidate caches of distant articles which transclude this page
- DeferredUpdates::addHTMLCacheUpdate( $title, 'globaltemplatelinks' );
// Invalidate the caches of all pages which redirect here
DeferredUpdates::addHTMLCacheUpdate( $title, 'redirect' );
return $result;
}
- /**
- * Return a list of distant templates used by this article.
- * Uses the globaltemplatelinks table
- *
- * @return Array of Title objects
- */
- public function getUsedDistantTemplates() {
- global $wgGlobalDatabase;
-
- $result = array();
-
- if ( $wgGlobalDatabase ) {
- $id = $this->mTitle->getArticleID();
-
- if ( $id == 0 ) {
- return array();
- }
-
- $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
- $res = $dbr->select( 'globaltemplatelinks',
- array( 'gtl_to_prefix', 'gtl_to_namespace', 'gtl_to_title' ),
- array( 'gtl_from_wiki' => wfWikiID( ), 'gtl_from_page' => $id ),
- __METHOD__ );
-
- if ( $res !== false ) {
- foreach ( $res as $row ) {
- $result[] = Title::makeTitle( $row->gtl_to_namespace, $row->gtl_to_title, null, $row->gtl_to_prefix );
- }
- }
- }
-
- return $result;
- }
-
/**
* Returns a list of hidden categories this page is a member of.
* Uses the page_props and categorylinks tables.
* @return ParserOptions
*/
public function makeParserOptions( $user ) {
- global $wgLanguageCode;
+ global $wgContLang;
if ( $user instanceof User ) { // settings per user (even anons)
$options = ParserOptions::newFromUser( $user );
} else { // canonical settings
- $options = ParserOptions::newFromUser( new User );
- $options->setUserLang( $wgLanguageCode ); # Must be set explicitily
+ $options = ParserOptions::newFromUserAndLang( new User, $wgContLang );
}
$options->enableLimitReport(); // show inclusion/loop reports
$options->setTidy( true ); // fix bad HTML
* Updates cascading protections
*
* @param $parserOutput ParserOutput object for the current version
- **/
+ */
public function doCascadeProtectionUpdates( ParserOutput $parserOutput ) {
if ( wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
return;
}
}
- /*
- * @deprecated since 1.18
- */
+ /**
+ * @deprecated since 1.18
+ */
public function quickEdit( $text, $comment = '', $minor = 0 ) {
global $wgUser;
return $this->doQuickEdit( $text, $wgUser, $comment, $minor );
}
- /*
- * @deprecated since 1.18
- */
+ /**
+ * @deprecated since 1.18
+ */
public function viewUpdates() {
global $wgUser;
return $this->doViewUpdates( $wgUser );
}
- /*
- * @deprecated since 1.18
- */
+ /**
+ * @deprecated since 1.18
+ */
public function useParserCache( $oldid ) {
global $wgUser;
return $this->isParserCacheUsed( $wgUser, $oldid );