From: Platonides Date: Thu, 5 Aug 2010 14:37:50 +0000 (+0000) Subject: Change quickUserCan( 'edit' ) and getIsPrintable() into setEditSection( false ) X-Git-Tag: 1.31.0-rc.0~35708 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=7bfebad30875b852e1e70bde10dbd12fa3e8a673;p=lhc%2Fweb%2Fwiklou.git Change quickUserCan( 'edit' ) and getIsPrintable() into setEditSection( false ) Follow up r48544. Init ParserOptions::mIsPrintable in initialiseFromUser() Move the "No edit section it's printable" from Parser to Article. This leaves getIsPrintable() unused. Left there for extensions (none seems to be using it, could be removed). The "even if the user has them on" comment wasn't accurate. The user preference only controls them via CSS. Anyway, it would work as expected now if it got moved into ParserOptions. The setEditSection() no longer set it to true. Remove the quickUserCan( 'edit' ) which is just a hidden way of calling $wgUser from the Parser to be explicitely done in Article to disable the editsection. This results in quickUserCan being called once instead of twice if $wgUseETag == true;. --- diff --git a/includes/Article.php b/includes/Article.php index 3812658514..2614aea682 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 a4e9058c2d..6efa1f268f 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 20de904a99..1f0458b0a7 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 71377e311d..977803f55c 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__ ); }