var $mTouched = '19700101000000'; // !<
var $mUser = -1; // !< Not loaded
var $mUserText = ''; // !< username from Revision if set
- var $mParserOptions; // !< ParserOptions object for $wgUser articles
+ var $mParserOptions; // !< ParserOptions object
var $mParserOutput; // !< ParserCache object if set
/**@}}*/
*
* @param $text string article content containing redirect info
* @return mixed false, Title of in-wiki target, or string with URL
- * @deprecated @since 1.17
+ * @deprecated since 1.17
*/
public function followRedirectText( $text ) {
// recurse through to only get the final target
# Get variables from query string
$oldid = $this->getOldID();
+
+ # getOldID may want us to redirect somewhere else
+ if ( $this->mRedirectUrl ) {
+ $wgOut->redirect( $this->mRedirectUrl );
+ wfDebug( __METHOD__ . ": redirecting due to oldid\n" );
+ wfProfileOut( __METHOD__ );
+
+ return;
+ }
+
+ $wgOut->setArticleFlag( true );
+ # Set page title (may be overridden by DISPLAYTITLE)
+ $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+
+ # If we got diff in the query, we want to see a diff page instead of the article.
+ if ( $wgRequest->getCheck( 'diff' ) ) {
+ wfDebug( __METHOD__ . ": showing diff page\n" );
+ $this->showDiffPage();
+ wfProfileOut( __METHOD__ );
+
+ return;
+ }
+
+ # Allow frames by default
+ $wgOut->allowClickjacking();
+
$parserCache = ParserCache::singleton();
$parserOptions = $this->getParserOptions();
}
}
- # getOldID may want us to redirect somewhere else
- if ( $this->mRedirectUrl ) {
- $wgOut->redirect( $this->mRedirectUrl );
- wfDebug( __METHOD__ . ": redirecting due to oldid\n" );
- wfProfileOut( __METHOD__ );
-
- return;
- }
-
- $wgOut->setArticleFlag( true );
- # Set page title (may be overridden by DISPLAYTITLE)
- $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
-
- # If we got diff in the query, we want to see a diff page instead of the article.
- if ( $wgRequest->getCheck( 'diff' ) ) {
- wfDebug( __METHOD__ . ": showing diff page\n" );
- $this->showDiffPage();
- wfProfileOut( __METHOD__ );
-
- return;
- }
-
- # Allow frames by default
- $wgOut->allowClickjacking();
-
if ( !$wgUseETag && !$this->mTitle->quickUserCan( 'edit' ) ) {
$parserOptions->setEditSection( false );
}
$this->mRevIdFetched = $de->mNewid;
$de->showDiffPage( $diffOnly );
- // Needed to get the page's current revision
- $this->loadPageData();
- if ( $diff == 0 || $diff == $this->mLatest ) {
+ if ( $diff == 0 || $diff == $this->getLatest() ) {
# Run view updates for current revision only
$this->viewUpdates();
}
if ( $ns == NS_USER || $ns == NS_USER_TALK ) {
# Don't index user and user talk pages for blocked users (bug 11443)
if ( !$this->mTitle->isSubpage() ) {
- $block = new Block();
- if ( $block->load( $this->mTitle->getText() ) ) {
+ if ( Block::newFromTarget( null, $this->mTitle->getText() ) instanceof Block ) {
return array(
'index' => 'noindex',
'follow' => 'nofollow'
global $wgOut, $wgUser, $wgRequest, $wgRedirectSources;
$rdfrom = $wgRequest->getVal( 'rdfrom' );
- $sk = $wgUser->getSkin();
if ( isset( $this->mRedirectedFrom ) ) {
// This is an internally redirected page view.
// We'll need a backlink to the source page for navigation.
if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
- $redir = $sk->link(
+ $redir = $wgUser->getSkin()->link(
$this->mRedirectedFrom,
null,
array(),
// This is an externally redirected view, from some other wiki.
// If it was reported from a trusted site, supply a backlink.
if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
- $redir = $sk->makeExternalLink( $rdfrom, $rdfrom );
+ $redir = $wgUser->getSkin()->makeExternalLink( $rdfrom, $rdfrom );
$s = wfMsgExt( 'redirectedfrom', array( 'parseinline', 'replaceafter' ), $redir );
$wgOut->setSubtitle( $s );
if ( !$isRedirect && !is_null( $lastRevIsRedirect ) && $lastRevIsRedirect === $isRedirect ) {
return true;
}
-
+
wfProfileIn( __METHOD__ );
if ( $isRedirect ) {
$this->insertRedirectEntry( $redirectTitle );
return $text;
}
- /**
- * @deprecated @since 1.7 use Article::doEdit()
- */
- function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC = false, $comment = false, $bot = false ) {
- wfDeprecated( __METHOD__ );
-
- $flags = EDIT_NEW | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
- ( $isminor ? EDIT_MINOR : 0 ) |
- ( $suppressRC ? EDIT_SUPPRESS_RC : 0 ) |
- ( $bot ? EDIT_FORCE_BOT : 0 );
-
- # If this is a comment, add the summary as headline
- if ( $comment && $summary != "" ) {
- $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" . $text;
- }
- $this->doEdit( $text, $summary, $flags );
-
- $dbw = wfGetDB( DB_MASTER );
- if ( $watchthis ) {
- if ( !$this->mTitle->userIsWatching() ) {
- $dbw->begin();
- $this->doWatch();
- $dbw->commit();
- }
- } else {
- if ( $this->mTitle->userIsWatching() ) {
- $dbw->begin();
- $this->doUnwatch();
- $dbw->commit();
- }
- }
- $this->doRedirect( $this->isRedirect( $text ) );
- }
-
- /**
- * @deprecated @since 1.7 use Article::doEdit()
- */
- function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) {
- wfDeprecated( __METHOD__ );
-
- $flags = EDIT_UPDATE | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
- ( $minor ? EDIT_MINOR : 0 ) |
- ( $forceBot ? EDIT_FORCE_BOT : 0 );
-
- $status = $this->doEdit( $text, $summary, $flags );
-
- if ( !$status->isOK() ) {
- return false;
- }
-
- $dbw = wfGetDB( DB_MASTER );
- if ( $watchthis ) {
- if ( !$this->mTitle->userIsWatching() ) {
- $dbw->begin();
- $this->doWatch();
- $dbw->commit();
- }
- } else {
- if ( $this->mTitle->userIsWatching() ) {
- $dbw->begin();
- $this->doUnwatch();
- $dbw->commit();
- }
- }
-
- $extraQuery = ''; // Give extensions a chance to modify URL query on update
- wfRunHooks( 'ArticleUpdateBeforeRedirect', array( $this, &$sectionanchor, &$extraQuery ) );
-
- $this->doRedirect( $this->isRedirect( $text ), $sectionanchor, $extraQuery );
- return true;
- }
-
/**
* Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed.
* @param $flags Int
$protect_description = '';
foreach ( $limit as $action => $restrictions ) {
if ( !isset( $expiry[$action] ) )
- $expiry[$action] = Block::infinity();
+ $expiry[$action] = $dbw->getInfinity();
- $encodedExpiry[$action] = Block::encodeExpiry( $expiry[$action], $dbw );
+ $encodedExpiry[$action] = $dbw->encodeExpiry( $expiry[$action] );
if ( $restrictions != '' ) {
$protect_description .= "[$action=$restrictions] (";
if ( $encodedExpiry[$action] != 'infinity' ) {
$flags |= EDIT_MINOR;
}
- if ( $bot && ( $wgUser->isAllowed( 'markbotedits' ) || $wgUser->isAllowed( 'bot' ) ) ) {
+ if ( $bot && ( $wgUser->isAllowedAny( 'markbotedits', 'bot' ) ) ) {
$flags |= EDIT_FORCE_BOT;
}
$edit->revid = $revid;
$edit->newText = $text;
$edit->pst = $this->preSaveTransform( $text, $user, $popts );
- $edit->popts = $this->getParserOptions( true );
+ $edit->popts = $this->getParserOptions();
$edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid );
$edit->oldText = $this->getRawText();
/**
* Get parser options suitable for rendering the primary article wikitext
- * @param $canonical boolean Determines that the generated must not depend on user preferences (see bug 14404)
* @return mixed ParserOptions object or boolean false
*/
- public function getParserOptions( $canonical = false ) {
- global $wgUser, $wgLanguageCode;
-
- if ( !$this->mParserOptions || $canonical ) {
- $user = !$canonical ? $wgUser : new User;
- $parserOptions = new ParserOptions( $user );
- $parserOptions->setTidy( true );
- $parserOptions->enableLimitReport();
-
- if ( $canonical ) {
- $parserOptions->setUserLang( $wgLanguageCode ); # Must be set explicitely
- return $parserOptions;
- }
- $this->mParserOptions = $parserOptions;
+ public function getParserOptions() {
+ global $wgUser;
+
+ if ( !$this->mParserOptions ) {
+ $this->mParserOptions = new ParserOptions( $wgUser );
+ $this->mParserOptions->setTidy( true );
+ $this->mParserOptions->enableLimitReport();
}
// Clone to allow modifications of the return value without affecting
* @since 1.16 (r52326) for LiquidThreads
*
* @param $oldid mixed integer Revision ID or null
- * @return ParserOutput
+ * @return ParserOutput or false if the given revsion ID is not found
*/
public function getParserOutput( $oldid = null ) {
global $wgEnableParserCache, $wgUser;
}
}
- $text = false;
// Cache miss; parse and output it.
- if ( $oldid !== null ) {
+ if ( $oldid === null ) {
+ $text = $this->getRawText();
+ } else {
$rev = Revision::newFromTitle( $this->getTitle(), $oldid );
- if ( $rev !== null ) {
- $text = $rev->getText();
+ if ( $rev === null ) {
+ return false;
}
- }
- if ( $text === false ) {
- $text = $this->getRawText();
+ $text = $rev->getText();
}
return $this->getOutputFromWikitext( $text, $useParserCache );