/**
* @var Content
+ * @since 1.WD
*/
var $mContentObject;
* This function has side effects! Do not use this function if you
* only want the real revision text if any.
*
- * @deprecated in 1.20; use getContentObject() instead
+ * @deprecated in 1.WD; use getContentObject() instead
*
* @return string The text of this revision
*/
public function getContent() {
- wfDeprecated( __METHOD__, '1.20' );
+ wfDeprecated( __METHOD__, '1.WD' );
$content = $this->getContentObject();
return ContentHandler::getContentText( $content );
}
/**
- * Note that getContent/loadContent do not follow redirects anymore.
+ * Returns a Content object representing the pages effective display content,
+ * not necessarily the revision's content!
+ *
+ * Note that getContent/loadContent do not follow redirects anymore.
* If you need to fetch redirectable content easily, try
* the shortcut in WikiPage::getRedirectTarget()
*
* only want the real revision text if any.
*
* @return Content
+ *
+ * @since 1.WD
*/
- public function getContentObject() {
+ protected function getContentObject() {
global $wgUser;
wfProfileIn( __METHOD__ );
if ( $oldid !== 0 ) {
# Load the given revision and check whether the page is another one.
# In that case, update this instance to reflect the change.
- $this->mRevision = Revision::newFromId( $oldid );
- if ( $this->mRevision !== null ) {
- // Revision title doesn't match the page title given?
- if ( $this->mPage->getID() != $this->mRevision->getPage() ) {
- $function = array( get_class( $this->mPage ), 'newFromID' );
- $this->mPage = call_user_func( $function, $this->mRevision->getPage() );
+ if ( $oldid === $this->mPage->getLatest() ) {
+ $this->mRevision = $this->mPage->getRevision();
+ } else {
+ $this->mRevision = Revision::newFromId( $oldid );
+ if ( $this->mRevision !== null ) {
+ // Revision title doesn't match the page title given?
+ if ( $this->mPage->getID() != $this->mRevision->getPage() ) {
+ $function = array( get_class( $this->mPage ), 'newFromID' );
+ $this->mPage = call_user_func( $function, $this->mRevision->getPage() );
+ }
}
}
}
* Does *NOT* follow redirects.
*
* @return mixed string containing article contents, or false if null
- * @deprecated in 1.20, use getContentObject() instead
+ * @deprecated in 1.WD, use getContentObject() instead
*/
protected function fetchContent() { #BC cruft!
- wfDeprecated( __METHOD__, '1.20' );
+ wfDeprecated( __METHOD__, '1.WD' );
if ( $this->mContentLoaded && $this->mContent ) {
return $this->mContent;
* TODO: when is this null?
*
* @return Content|null
+ *
+ * @since 1.WD
*/
protected function fetchContentObject() {
if ( $this->mContentLoaded ) {
# fails we'll have something telling us what we intended.
$t = $this->getTitle()->getPrefixedText();
$d = $oldid ? wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid ) : '';
- $this->mContentObject = new MessageContent( 'missing-article', array($t, $d), array() ) ;
+ $this->mContentObject = new MessageContent( 'missing-article', array($t, $d), array() ) ; // @todo: this isn't page content but a UI message. horrible.
if ( $oldid ) {
# $this->mRevision might already be fetched by getOldIDFromRequest()
if ( $wgOut->isPrintable() ) {
$parserOptions->setIsPrintable( true );
$parserOptions->setEditSection( false );
- } elseif ( !$this->getTitle()->quickUserCan( 'edit' ) ) {
+ } elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit' ) ) {
$parserOptions->setEditSection( false );
}
# Viewing a redirect page (e.g. with parameter redirect=no)
$wgOut->addHTML( $this->viewRedirect( $rt ) );
# Parse just to get categories, displaytitle, etc.
- $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid, $parserOptions );
+ $this->mParserOutput = $content->getParserOutput( $this->getContext(), $oldid, $parserOptions, false );
$wgOut->addParserOutputNoText( $this->mParserOutput );
$outputDone = true;
}
# Run the parse, protected by a pool counter
wfDebug( __METHOD__ . ": doing uncached parse\n" );
+ // @todo: shouldn't we be passing $this->getPage() to PoolWorkArticleView instead of plain $this?
$poolArticleView = new PoolWorkArticleView( $this, $parserOptions,
- $this->getRevIdFetched(), $useParserCache, $this->getContentObject() );
+ $this->getRevIdFetched(), $useParserCache, $this->getContentObject(), $this->getContext() );
if ( !$poolArticleView->execute() ) {
$error = $poolArticleView->getError();
$oldid = $this->getOldID();
$contentHandler = ContentHandler::getForTitle( $this->getTitle() );
- $de = $contentHandler->getDifferenceEngine( $this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
+ $de = $contentHandler->createDifferenceEngine( $this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
// DifferenceEngine directly fetched the revision:
$this->mRevIdFetched = $de->mNewid;
// Give hooks a chance to customise the output
if ( !Hooks::isRegistered('ShowRawCssJs') || wfRunHooks( 'ShowRawCssJs', array( $this->fetchContent(), $this->getTitle(), $wgOut ) ) ) { #FIXME: fetchContent() is deprecated #FIXME: hook is deprecated
- $po = $this->mContentObject->getParserOutput();
+ $po = $this->mContentObject->getParserOutput( $this->getContext() );
$wgOut->addHTML( $po->getText() );
}
}
'msgKey' => array( 'moveddeleted-notice' ) )
);
+ if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) {
+ // If there's no backing content, send a 404 Not Found
+ // for better machine handling of broken links.
+ $wgRequest->response()->header( "HTTP/1.1 404 Not Found" );
+ }
+
+ $hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) );
+
+ if ( ! $hookResult ) {
+ return;
+ }
+
# Show error message
$oldid = $this->getOldID();
if ( $oldid ) {
}
$text = "<div class='noarticletext'>\n$text\n</div>";
- if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) {
- // If there's no backing content, send a 404 Not Found
- // for better machine handling of broken links.
- $wgRequest->response()->header( "HTTP/1.1 404 Not Found" );
- }
-
$wgOut->addWikiText( $text );
}
# Cascade unhide param in links for easy deletion browsing
$extraParams = array();
- if ( $wgRequest->getVal( 'unhide' ) ) {
+ if ( $unhide ) {
$extraParams['unhide'] = 1;
}
- $revision = Revision::newFromId( $oldid );
+ if ( $this->mRevision && $this->mRevision->getId() === $oldid ) {
+ $revision = $this->mRevision;
+ } else {
+ $revision = Revision::newFromId( $oldid );
+ }
+
$timestamp = $revision->getTimestamp();
$current = ( $oldid == $this->mPage->getLatest() );
/**
* Get parser options suitable for rendering the primary article wikitext
- * @return ParserOptions|false
+ * @return ParserOptions
*/
public function getParserOptions() {
global $wgUser;
*
* @param $fname String Name of called method
* @param $args Array Arguments to the method
+ * @return mixed
*/
public function __call( $fname, $args ) {
if ( is_callable( array( $this->mPage, $fname ) ) ) {
* @param $newtext
* @param $flags
* @return string
- * @deprecated since 1.20, use ContentHandler::getAutosummary() instead
+ * @deprecated since 1.WD, use ContentHandler::getAutosummary() instead
*/
public static function getAutosummary( $oldtext, $newtext, $flags ) {
return WikiPage::getAutosummary( $oldtext, $newtext, $flags );