Revision: 48544
Author:   aboostani
Date:     2009-03-18 23:27:48 +0000 (Wed, 18 Mar 2009)

Log Message:
-----------
Fixed bug #11213 - [edit] section links in printable version interfere with 
cut-and-paste of article text

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES
    trunk/phase3/includes/Article.php
    trunk/phase3/includes/OutputPage.php
    trunk/phase3/includes/api/ApiParse.php
    trunk/phase3/includes/parser/Parser.php
    trunk/phase3/includes/parser/ParserCache.php
    trunk/phase3/includes/parser/ParserOptions.php

Modified: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES  2009-03-18 23:24:29 UTC (rev 48543)
+++ trunk/phase3/RELEASE-NOTES  2009-03-18 23:27:48 UTC (rev 48544)
@@ -278,6 +278,7 @@
   IS NULL
 * (bug 18018) Deleting a file redirect leaves behind a malfunctioning redirect
 * (bug 17537) Disable bad zlib.output_compression output on HTTP 304 responses
+* (bug 11213) [edit] section links in printable version no longer appear when 
you cut-and-paste article text
 
 == API changes in 1.15 ==
 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions

Modified: trunk/phase3/includes/Article.php
===================================================================
--- trunk/phase3/includes/Article.php   2009-03-18 23:24:29 UTC (rev 48543)
+++ trunk/phase3/includes/Article.php   2009-03-18 23:27:48 UTC (rev 48544)
@@ -727,6 +727,11 @@
                global $wgUseTrackbacks, $wgNamespaceRobotPolicies, 
$wgArticleRobotPolicies;
                global $wgDefaultRobotPolicy;
 
+               # Let the parser know if this is the printable version
+               if( $wgOut->isPrintable() ) {
+                       $wgOut->parserOptions()->setIsPrintable( true );
+               }
+               
                wfProfileIn( __METHOD__ );
 
                # Get variables from query string
@@ -737,7 +742,7 @@
                        global $wgUseETag;
                        if( $wgUseETag ) {
                                $parserCache = ParserCache::singleton();
-                               $wgOut->setETag( 
$parserCache->getETag($this,$wgUser) );
+                               $wgOut->setETag( $parserCache->getETag($this, 
$wgOut->parserOptions()) );
                        }
                        # Is is client cached?
                        if( $wgOut->checkLastModified( $this->getTouched() ) ) {
@@ -862,7 +867,7 @@
 
                $outputDone = false;
                wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, 
&$pcache ) );
-               if( $pcache && $wgOut->tryParserCache( $this, $wgUser ) ) {
+               if( $pcache && $wgOut->tryParserCache( $this ) ) {
                        // Ensure that UI elements requiring revision ID have
                        // the correct version information.
                        $wgOut->setRevisionId( $this->mLatest );
@@ -939,7 +944,7 @@
                                        }
                                        // Is this the current revision and 
otherwise cacheable? Try the parser cache...
                                        if( $oldid === $this->getLatest() && 
$this->useParserCache( false )
-                                               && $wgOut->tryParserCache( 
$this, $wgUser ) )
+                                               && $wgOut->tryParserCache( 
$this ) )
                                        {
                                                $outputDone = true;
                                        }
@@ -2916,8 +2921,11 @@
 
                # Save it to the parser cache
                if( $wgEnableParserCache ) {
+                       $popts = new ParserOptions;
+                       $popts->setTidy( true );
+                       $popts->enableLimitReport();
                        $parserCache = ParserCache::singleton();
-                       $parserCache->save( $editInfo->output, $this, $wgUser );
+                       $parserCache->save( $editInfo->output, $this, $popts );
                }
 
                # Update the links tables
@@ -3551,7 +3559,7 @@
                $popts->enableLimitReport( false );
                if( $wgEnableParserCache && $cache && $this && 
$parserOutput->getCacheTime() != -1 ) {
                        $parserCache = ParserCache::singleton();
-                       $parserCache->save( $parserOutput, $this, $wgUser );
+                       $parserCache->save( $parserOutput, $this, $popts );
                }
                // Make sure file cache is not used on uncacheable content.
                // Output that has magic words in it can still use the parser 
cache

Modified: trunk/phase3/includes/OutputPage.php
===================================================================
--- trunk/phase3/includes/OutputPage.php        2009-03-18 23:24:29 UTC (rev 
48543)
+++ trunk/phase3/includes/OutputPage.php        2009-03-18 23:27:48 UTC (rev 
48544)
@@ -597,7 +597,7 @@
                $popts->setTidy(false);
                if ( $cache && $article && $parserOutput->getCacheTime() != -1 
) {
                        $parserCache = ParserCache::singleton();
-                       $parserCache->save( $parserOutput, $article, $wgUser );
+                       $parserCache->save( $parserOutput, $article, $popts);
                }
 
                $this->addParserOutput( $parserOutput );
@@ -671,9 +671,9 @@
         *
         * @return bool True if successful, else false.
         */
-       public function tryParserCache( &$article, $user ) {
+       public function tryParserCache( &$article ) {
                $parserCache = ParserCache::singleton();
-               $parserOutput = $parserCache->get( $article, $user );
+               $parserOutput = $parserCache->get( $article, 
$this->parserOptions() );
                if ( $parserOutput !== false ) {
                        $this->addParserOutput( $parserOutput );
                        return true;

Modified: trunk/phase3/includes/api/ApiParse.php
===================================================================
--- trunk/phase3/includes/api/ApiParse.php      2009-03-18 23:24:29 UTC (rev 
48543)
+++ trunk/phase3/includes/api/ApiParse.php      2009-03-18 23:27:48 UTC (rev 
48544)
@@ -105,7 +105,7 @@
                                        $p_result = 
$wgParser->parse($articleObj->getContent(), $titleObj, $popts);
                                        global $wgUseParserCache;
                                        if($wgUseParserCache)
-                                               $pcache->save($p_result, 
$articleObj, $wgUser);
+                                               $pcache->save($p_result, 
$articleObj, $popts);
                                }
                        }
                }

Modified: trunk/phase3/includes/parser/Parser.php
===================================================================
--- trunk/phase3/includes/parser/Parser.php     2009-03-18 23:24:29 UTC (rev 
48543)
+++ trunk/phase3/includes/parser/Parser.php     2009-03-18 23:27:48 UTC (rev 
48544)
@@ -3378,7 +3378,7 @@
                }
 
                # Inhibit editsection links if requested in the page
-               if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
+               if ( isset( $this->mDoubleUnderscores['noeditsection'] )  || 
$this->mOptions->getIsPrintable() ) {
                        $showEditLink = 0;
                }
 

Modified: trunk/phase3/includes/parser/ParserCache.php
===================================================================
--- trunk/phase3/includes/parser/ParserCache.php        2009-03-18 23:24:29 UTC 
(rev 48543)
+++ trunk/phase3/includes/parser/ParserCache.php        2009-03-18 23:27:48 UTC 
(rev 48544)
@@ -26,8 +26,11 @@
                $this->mMemc =& $memCached;
        }
 
-       function getKey( &$article, &$user ) {
-               global $action;
+       function getKey( &$article, $popts ) {
+               global $wgRequest;
+               
+               $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
@@ -36,21 +39,21 @@
                        $edit = '';
                }
                $pageid = $article->getID();
-               $renderkey = (int)($action == 'render');
-               $key = wfMemcKey( 'pcache', 'idhash', 
"{$pageid}-{$renderkey}!{$hash}{$edit}" );
+               $renderkey = (int)($wgRequest->getVal('action') == 'render');
+               $key = wfMemcKey( 'pcache', 'idhash', 
"{$pageid}-{$renderkey}!{$hash}{$edit}{$printable}" );
                return $key;
        }
 
-       function getETag( &$article, &$user ) {
-               return 'W/"' . $this->getKey($article, $user) . "--" . 
$article->mTouched. '"';
+       function getETag( &$article, $popts ) {
+               return 'W/"' . $this->getKey($article, $popts) . "--" . 
$article->mTouched. '"';
        }
 
-       function get( &$article, &$user ) {
+       function get( &$article, $popts ) {
                global $wgCacheEpoch;
                $fname = 'ParserCache::get';
                wfProfileIn( $fname );
 
-               $key = $this->getKey( $article, $user );
+               $key = $this->getKey( $article, $popts );
 
                wfDebug( "Trying parser cache $key\n" );
                $value = $this->mMemc->get( $key );
@@ -86,9 +89,9 @@
                return $value;
        }
 
-       function save( $parserOutput, &$article, &$user ){
+       function save( $parserOutput, &$article, $popts ){
                global $wgParserCacheExpireTime;
-               $key = $this->getKey( $article, $user );
+               $key = $this->getKey( $article, $popts );
 
                if( $parserOutput->getCacheTime() != -1 ) {
 

Modified: trunk/phase3/includes/parser/ParserOptions.php
===================================================================
--- trunk/phase3/includes/parser/ParserOptions.php      2009-03-18 23:24:29 UTC 
(rev 48543)
+++ trunk/phase3/includes/parser/ParserOptions.php      2009-03-18 23:27:48 UTC 
(rev 48544)
@@ -35,7 +35,8 @@
        var $mUser;                      # Stored user object, just used to 
initialise the skin
        var $mIsPreview;                 # Parsing the page for a "preview" 
operation
        var $mIsSectionPreview;          # Parsing the page for a "preview" 
operation on a single section
-
+       var $mIsPrintable;                     # Parsing the printable version 
of the page
+       
        function getUseTeX()                        { return $this->mUseTeX; }
        function getUseDynamicDates()               { return 
$this->mUseDynamicDates; }
        function getInterwikiMagic()                { return 
$this->mInterwikiMagic; }
@@ -58,7 +59,8 @@
        function getExternalLinkTarget()            { return 
$this->mExternalLinkTarget; }
        function getIsPreview()                     { return $this->mIsPreview; 
}
        function getIsSectionPreview()              { return 
$this->mIsSectionPreview; }
-
+  function getIsPrintable()            { return $this->mIsPrintable; }
+  
        function getSkin() {
                if ( !isset( $this->mSkin ) ) {
                        $this->mSkin = $this->mUser->getSkin();
@@ -105,7 +107,8 @@
        function setExternalLinkTarget( $x )        { return wfSetVar( 
$this->mExternalLinkTarget, $x ); }
        function setIsPreview( $x )                 { return wfSetVar( 
$this->mIsPreview, $x ); }
        function setIsSectionPreview( $x )          { return wfSetVar( 
$this->mIsSectionPreview, $x ); }
-
+  function setIsPrintable( $x )        { return wfSetVar( $this->mIsPrintable, 
$x ); }
+  
        function __construct( $user = null ) {
                $this->initialiseFromUser( $user );
        }



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to