diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/Article.php | 23 | ||||
-rw-r--r-- | includes/parser/Parser.php | 6 | ||||
-rw-r--r-- | includes/parser/ParserCache.php | 5 | ||||
-rw-r--r-- | includes/parser/ParserOptions.php | 1 |
4 files changed, 26 insertions, 9 deletions
diff --git a/includes/Article.php b/includes/Article.php index 3812658514da..2614aea68283 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -826,7 +826,7 @@ class Article { */ public function view() { global $wgUser, $wgOut, $wgRequest, $wgParser; - global $wgUseFileCache; + global $wgUseFileCache, $wgUseETag; wfProfileIn( __METHOD__ ); @@ -838,12 +838,13 @@ class Article { # Render printable version, use printable version cache if ( $wgOut->isPrintable() ) { $parserOptions->setIsPrintable( true ); + $parserOptions->setEditSection( false ); + } else if ( $wgUseETag && !$this->mTitle->quickUserCan( 'edit' ) ) { + $parserOptions->setEditSection( false ); } # Try client and file cache if ( $oldid === 0 && $this->checkTouched() ) { - global $wgUseETag; - if ( $wgUseETag ) { $wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) ); } @@ -888,6 +889,10 @@ class Article { return; } + if ( !$wgUseETag && !$this->mTitle->quickUserCan( 'edit' ) ) { + $parserOptions->setEditSection( false ); + } + # Should the parser cache be used? $useParserCache = $this->useParserCache( $oldid ); wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); @@ -1471,7 +1476,10 @@ class Article { $parserOptions->setIsPrintable( $wgOut->isPrintable() ); # Don't show section-edit links on old revisions... this way lies madness. - $parserOptions->setEditSection( $this->isCurrent() ); + if ( !$this->isCurrent() || $wgOut->isPrintable() ) { + $parserOptions->setEditSection( false ); + } + $useParserCache = $this->useParserCache( $oldid ); $this->outputWikiText( $this->getContent(), $useParserCache, $parserOptions ); } @@ -1489,7 +1497,12 @@ class Article { global $wgOut; $parserCache = ParserCache::singleton(); $options = $this->getParserOptions(); - $options->setIsPrintable( $wgOut->isPrintable() ); + + if ( $wgOut->isPrintable() ) { + $options->setIsPrintable( true ); + $parserOptions->setEditSection( false ); + } + $output = $parserCache->getDirty( $this, $options ); if ( $output ) { diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index a4e9058c2d48..6efa1f268f71 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3700,7 +3700,7 @@ class Parser { global $wgMaxTocLevel, $wgContLang, $wgHtml5, $wgExperimentalHtmlIds; $doNumberHeadings = $this->mOptions->getNumberHeadings(); - $showEditLink = $this->mOptions->getEditSection(); + # Do not call quickUserCan unless necessary if ( $showEditLink && !$this->mTitle->quickUserCan( 'edit' ) ) { @@ -3708,8 +3708,10 @@ class Parser { } # Inhibit editsection links if requested in the page - if ( isset( $this->mDoubleUnderscores['noeditsection'] ) || $this->mOptions->getIsPrintable() ) { + if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) { $showEditLink = 0; + } else { + $showEditLink = $this->mOptions->getEditSection(); } # Get all headlines for numbering them and adding funky stuff like [edit] diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index 20de904a992e..1f0458b0a725 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -41,8 +41,9 @@ class ParserCache { $user = $popts->mUser; $printable = ( $popts->getIsPrintable() ) ? '!printable=1' : ''; $hash = $user->getPageRenderingHash(); - if( !$article->mTitle->quickUserCan( 'edit' ) ) { - // section edit links are suppressed even if the user has them on + + if( ! $popts->getEditSection() ) { + // section edit links have been suppressed $edit = '!edit=0'; } else { $edit = ''; diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 71377e311d34..977803f55c04 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -165,6 +165,7 @@ class ParserOptions { $this->mExternalLinkTarget = $wgExternalLinkTarget; $this->mIsPreview = false; $this->mIsSectionPreview = false; + $this->mIsPrintable = false; wfProfileOut( __METHOD__ ); } |