return;
}
}
-
- $text = $this->getContent( false ); # May change mTitle by following a redirect
- # Another whitelist check in case oldid or redirects are altering the title
- if ( !$this->mTitle->userCanRead() ) {
- $wgOut->loginToUse();
- $wgOut->output();
- exit;
+ # Should the parser cache be used?
+ if ( $wgEnableParserCache && intval($wgUser->getOption( "stubthreshold" )) == 0 && empty( $oldid ) ) {
+ $pcache = true;
+ } else {
+ $pcache = false;
}
- $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+ $outputDone = false;
+ if ( $pcache ) {
+ if ( $wgOut->tryParserCache( $this, $wgUser ) ) {
+ $outputDone = true;
+ }
+ }
- # We're looking at an old revision
+ if ( !$outputDone ) {
+ $text = $this->getContent( false ); # May change mTitle by following a redirect
+
+ # Another whitelist check in case oldid or redirects are altering the title
+ if ( !$this->mTitle->userCanRead() ) {
+ $wgOut->loginToUse();
+ $wgOut->output();
+ exit;
+ }
+
+ $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
- if ( !empty( $oldid ) ) {
- $this->setOldSubtitle();
- $wgOut->setRobotpolicy( "noindex,follow" );
- }
- if ( "" != $this->mRedirectedFrom ) {
- $sk = $wgUser->getSkin();
- $redir = $sk->makeKnownLink( $this->mRedirectedFrom, "",
- "redirect=no" );
- $s = wfMsg( "redirectedfrom", $redir );
- $wgOut->setSubtitle( $s );
- }
+ # We're looking at an old revision
- $wgLinkCache->preFill( $this->mTitle );
+ if ( !empty( $oldid ) ) {
+ $this->setOldSubtitle();
+ $wgOut->setRobotpolicy( "noindex,follow" );
+ }
+ if ( "" != $this->mRedirectedFrom ) {
+ $sk = $wgUser->getSkin();
+ $redir = $sk->makeKnownLink( $this->mRedirectedFrom, "",
+ "redirect=no" );
+ $s = wfMsg( "redirectedfrom", $redir );
+ $wgOut->setSubtitle( $s );
+
+ # Can't cache redirects
+ $pcache = false;
+ }
- # wrap user css and user js in pre and don't parse
- # XXX: use $this->mTitle->usCssJsSubpage() when php is fixed/ a workaround is found
- if (
- $this->mTitle->getNamespace() == Namespace::getUser() &&
- preg_match("/\\/[\\w]+\\.(css|js)$/", $this->mTitle->getDBkey())
- ) {
- $wgOut->addWikiText( wfMsg('usercssjs'));
- $wgOut->addHTML( '<pre>'.htmlspecialchars($this->mContent)."\n</pre>" );
- } else if( $wgEnableParserCache && intval($wgUser->getOption( "stubthreshold" )) == 0 && empty( $oldid ) ){
- $wgOut->addWikiText( $text, true, $this );
- } else {
- $wgOut->addWikiText( $text );
+ $wgLinkCache->preFill( $this->mTitle );
+
+ # wrap user css and user js in pre and don't parse
+ # XXX: use $this->mTitle->usCssJsSubpage() when php is fixed/ a workaround is found
+ if (
+ $this->mTitle->getNamespace() == Namespace::getUser() &&
+ preg_match("/\\/[\\w]+\\.(css|js)$/", $this->mTitle->getDBkey())
+ ) {
+ $wgOut->addWikiText( wfMsg('usercssjs'));
+ $wgOut->addHTML( '<pre>'.htmlspecialchars($this->mContent)."\n</pre>" );
+ } else if ( $pcache ) {
+ $wgOut->addWikiText( $text, true, $this );
+ } else {
+ $wgOut->addWikiText( $text );
+ }
}
-
+
# Add link titles as META keywords
$wgOut->addMetaTags() ;
and (!$this->mRedirectedFrom);
}
+ # Loads cur_touched and returns a value indicating if it should be used
function checkTouched() {
$id = $this->getID();
$sql = "SELECT cur_touched,cur_is_redirect FROM cur WHERE cur_id=$id";
}
}
- function getTouched() {
- return $this->mTouched;
- }
-
# Edit an article without doing all that other stuff
function quickEdit( $text, $comment = "", $minor = 0 ) {
global $wgUser, $wgMwRedir;
function addWikiText( $text, $linestart = true, $cacheArticle = NULL )
{
global $wgParser, $wgParserCache, $wgUser, $wgTitle;
-
- $parserOutput = false;
+
+ $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions, $linestart );
if ( $cacheArticle ) {
- $parserOutput = $wgParserCache->get( $cacheArticle, $wgUser );
- }
-
- if ( $parserOutput === false ) {
- $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions, $linestart );
- if ( $cacheArticle ) {
- $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
- }
+ $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
}
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->mCategoryLinks += $parserOutput->getCategoryLinks();
-
$this->addHTML( $parserOutput->getText() );
-
}
+ function tryParserCache( $article, $user ) {
+ $parserOutput = $wgParserCache->get( $article, $user );
+ if ( $parserOutput !== false ) {
+ $this->mLanguageLinks += $parserOutput->getLanguageLinks();
+ $this->mCategoryLinks += $parserOutput->getCategoryLinks();
+ $this->addHTML( $parserOutput->getText() );
+ return true;
+ } else {
+ return false;
+ }
+ }
+
# Set the maximum cache time on the Squid in seconds
function setSquidMaxage( $maxage ) {
$this->mSquidMaxage = $maxage;
if ( $value ) {
wfDebug( "Found.\n" );
# Delete if article has changed since the cache was made
- $touched = $article->getTouched();
+ $canCache = $article->checkTouched();
$cacheTime = $value->getCacheTime();
- if ( $value->getCacheTime() <= $touched || $cacheTime < $wgCacheEpoch ) {
- wfDebug( "Key expired, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" );
+ if ( !$canCache || $value->getCacheTime() <= $touched || $cacheTime < $wgCacheEpoch ) {
+ if ( !$canCache ) {
+ wfDebug( "Invalid cached redirect, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" );
+ } else {
+ wfDebug( "Key expired, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" );
+ }
$wgMemc->delete( $key );
$value = false;
}
function save( $parserOutput, &$article, &$user ){
global $wgMemc;
+
$key = $this->getKey( $article, $user );
$now = wfTimestampNow();
$parserOutput->setCacheTime( $now );