Revert r38196, r38204 -- "(bugs 6089, 13079) Show edit section links for transcluded...
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 29 Jul 2008 23:56:30 +0000 (23:56 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 29 Jul 2008 23:56:30 +0000 (23:56 +0000)
Cause regression in 19 parser test cases, looks like messing up the tooltips for section edit links.

  19 previously failing test(s) now PASSING! :)
      * Bug 6563: Edit link generation for section shown by <includeonly>  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Bug 6563: Edit link generation for section suppressed by <includeonly>  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Basic section headings  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Section headings with TOC  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Handling of sections up to level 6 and beyond  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * TOC regression (bug 9764)  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * TOC with wgMaxTocLevel=3 (bug 6204)  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Resolving duplicate section names  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Resolving duplicate section names with differing case (bug 10721)  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Template with sections, __NOTOC__  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Link inside a section heading  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * TOC regression (bug 12077)  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Fuzz testing: Parser14  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Fuzz testing: Parser14-table  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Inclusion of !userCanEdit() content  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Out-of-order TOC heading levels  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * -{}- tags within headlines (within html for parserConvert())  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * Morwen/13: Unclosed link followed by heading  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]
      * HHP2.2: Heuristics for headings in preprocessor parenthetical structures  [Fixed between 29-Jul-2008 22:42:06, 1.14alpha (r38207) and 29-Jul-2008 23:54:51, 1.14alpha (r38207)]

includes/Title.php
includes/parser/Parser.php
includes/parser/ParserCache.php
includes/parser/ParserOptions.php

index 825c9ae..448db9b 100644 (file)
@@ -999,12 +999,11 @@ class Title {
         *
         * May provide false positives, but should never provide a false negative.
         *
-        * @param $action String: action that permission needs to be checked for
-        * @param $user User object, optional
+        * @param string $action action that permission needs to be checked for
         * @return boolean
         */
-       public function quickUserCan( $action, $user = null ) {
-               return $this->userCan( $action, false, $user );
+       public function quickUserCan( $action ) {
+               return $this->userCan( $action, false );
        }
 
        /**
@@ -1026,17 +1025,13 @@ class Title {
 
        /**
         * Can $wgUser perform $action on this page?
-        * @param $action String: action that permission needs to be checked for
-        * @param $doExpensiveQueries Bool: set this to false to avoid doing unnecessary queries.
-        * @param $user User object, optional 
+        * @param string $action action that permission needs to be checked for
+        * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries.
         * @return boolean
         */
-       public function userCan( $action, $doExpensiveQueries = true, $user = null ) {
-               if( $user === null ){
-                       global $wgUser;
-                       $user = $wgUser;
-               }
-               return ( $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries ) === array());
+       public function userCan( $action, $doExpensiveQueries = true ) {
+               global $wgUser;
+               return ( $this->getUserPermissionsErrorsInternal( $action, $wgUser, $doExpensiveQueries ) === array());
        }
 
        /**
index 52a61e4..c074717 100644 (file)
@@ -3411,7 +3411,11 @@ class Parser
                global $wgMaxTocLevel, $wgContLang;
 
                $doNumberHeadings = $this->mOptions->getNumberHeadings();
-               $showEditLink = $this->mOptions->getEditSection();
+               if( !$this->mTitle->quickUserCan( 'edit' ) ) {
+                       $showEditLink = 0;
+               } else {
+                       $showEditLink = $this->mOptions->getEditSection();
+               }
 
                # Inhibit editsection links if requested in the page
                if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
@@ -3605,18 +3609,9 @@ class Parser
                                if( $isTemplate ) {
                                        # Put a T flag in the section identifier, to indicate to extractSections()
                                        # that sections inside <includeonly> should be counted.
-                                       $titleObj = Title::newFromText( $titleText );
-                                       $section = "T-$sectionIndex";
-                                       $tooltip = $headlineHint;
+                                       $editlink = $sk->doEditSectionLink(Title::newFromText( $titleText ), "T-$sectionIndex");
                                } else {
-                                       $titleObj = $this->mTitle;
-                                       $section = $sectionIndex;
-                                       $tooltip = '';
-                               }
-                               if( $titleObj->quickUserCan( 'edit', $this->mOptions->getUser() ) ){
-                                       $editlink = $sk->doEditSectionLink( $titleObj, $section, $tooltip );
-                               } else {
-                                       $editlink = '';
+                                       $editlink = $sk->doEditSectionLink($this->mTitle, $sectionIndex, $headlineHint);
                                }
                        } else {
                                $editlink = '';
@@ -4047,6 +4042,7 @@ class Parser
         * $options is a bit field, RLH_FOR_UPDATE to select for update
         */
        function replaceLinkHolders( &$text, $options = 0 ) {
+               global $wgUser;
                global $wgContLang;
 
                $fname = 'Parser::replaceLinkHolders';
@@ -4062,7 +4058,7 @@ class Parser
                        wfProfileIn( $fname.'-check' );
                        $dbr = wfGetDB( DB_SLAVE );
                        $page = $dbr->tableName( 'page' );
-                       $threshold = $this->mOptions->getStubThreshold();
+                       $threshold = $wgUser->getOption('stubthreshold');
 
                        # Sort by namespace
                        asort( $this->mLinkHolders['namespaces'] );
index b2bd2ba..bf11da2 100644 (file)
@@ -29,7 +29,7 @@ class ParserCache {
        function getKey( &$article, &$user ) {
                global $action;
                $hash = $user->getPageRenderingHash();
-               if( !$article->mTitle->quickUserCan( 'edit', $user ) ) {
+               if( !$article->mTitle->quickUserCan( 'edit' ) ) {
                        // section edit links are suppressed even if the user has them on
                        $edit = '!edit=0';
                } else {
index 5b6e8ed..330ec44 100644 (file)
@@ -5,32 +5,32 @@
  * @todo document
  * @ingroup Parser
  */
-class ParserOptions {
+class ParserOptions
+{
        # All variables are supposed to be private in theory, although in practise this is not the case.
-       var $mUseTeX;                    //!< Use texvc to expand <math> tags
-       var $mUseDynamicDates;           //!< Use DateFormatter to format dates
-       var $mInterwikiMagic;            //!< Interlanguage links are removed and returned in an array
-       var $mAllowExternalImages;       //!< Allow external images inline
-       var $mAllowExternalImagesFrom;   //!< If not, any exception?
-       var $mSkin;                      //!< Reference to the preferred skin
-       var $mDateFormat;                //!< Date format index
-       var $mEditSection;               //!< Create "edit section" links
-       var $mNumberHeadings;            //!< Automatically number headings
-       var $mStubThreshold;             //!< Treshold for marking pages as "stub"
-       var $mAllowSpecialInclusion;     //!< Allow inclusion of special pages
-       var $mTidy;                      //!< Ask for tidy cleanup
-       var $mInterfaceMessage;          //!< Which lang to call for PLURAL and GRAMMAR
-       var $mTargetLanguage;            //!< Overrides above setting with arbitrary language
-       var $mMaxIncludeSize;            //!< Maximum size of template expansions, in bytes
-       var $mMaxPPNodeCount;            //!< Maximum number of nodes touched by PPFrame::expand()
-       var $mMaxPPExpandDepth;          //!< Maximum recursion depth in PPFrame::expand()
-       var $mMaxTemplateDepth;          //!< Maximum recursion depth for templates within templates
-       var $mRemoveComments;            //!< Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
-       var $mTemplateCallback;          //!< Callback for template fetching
-       var $mEnableLimitReport;         //!< Enable limit report in an HTML comment on output
-       var $mTimestamp;                 //!< Timestamp used for {{CURRENTDAY}} etc.
-
-       var $mUser;                      //!< Stored user object
+       var $mUseTeX;                    # Use texvc to expand <math> tags
+       var $mUseDynamicDates;           # Use DateFormatter to format dates
+       var $mInterwikiMagic;            # Interlanguage links are removed and returned in an array
+       var $mAllowExternalImages;       # Allow external images inline
+       var $mAllowExternalImagesFrom;   # If not, any exception?
+       var $mSkin;                      # Reference to the preferred skin
+       var $mDateFormat;                # Date format index
+       var $mEditSection;               # Create "edit section" links
+       var $mNumberHeadings;            # Automatically number headings
+       var $mAllowSpecialInclusion;     # Allow inclusion of special pages
+       var $mTidy;                      # Ask for tidy cleanup
+       var $mInterfaceMessage;          # Which lang to call for PLURAL and GRAMMAR
+       var $mTargetLanguage;            # Overrides above setting with arbitrary language
+       var $mMaxIncludeSize;            # Maximum size of template expansions, in bytes
+       var $mMaxPPNodeCount;            # Maximum number of nodes touched by PPFrame::expand()
+       var $mMaxPPExpandDepth;          # Maximum recursion depth in PPFrame::expand()
+       var $mMaxTemplateDepth;          # Maximum recursion depth for templates within templates
+       var $mRemoveComments;            # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
+       var $mTemplateCallback;          # Callback for template fetching
+       var $mEnableLimitReport;         # Enable limit report in an HTML comment on output
+       var $mTimestamp;                 # Timestamp used for {{CURRENTDAY}} etc.
+
+       var $mUser;                      # Stored user object, just used to initialise the skin
 
        function getUseTeX()                        { return $this->mUseTeX; }
        function getUseDynamicDates()               { return $this->mUseDynamicDates; }
@@ -39,7 +39,6 @@ class ParserOptions {
        function getAllowExternalImagesFrom()       { return $this->mAllowExternalImagesFrom; }
        function getEditSection()                   { return $this->mEditSection; }
        function getNumberHeadings()                { return $this->mNumberHeadings; }
-       function getStubThreshold()                 { return $this->mStubThreshold; }
        function getAllowSpecialInclusion()         { return $this->mAllowSpecialInclusion; }
        function getTidy()                          { return $this->mTidy; }
        function getInterfaceMessage()              { return $this->mInterfaceMessage; }
@@ -51,10 +50,6 @@ class ParserOptions {
        function getTemplateCallback()              { return $this->mTemplateCallback; }
        function getEnableLimitReport()             { return $this->mEnableLimitReport; }
 
-       function getUser() {
-               return $this->mUser;    
-       }
-
        function getSkin() {
                if ( !isset( $this->mSkin ) ) {
                        $this->mSkin = $this->mUser->getSkin();
@@ -84,7 +79,6 @@ class ParserOptions {
        function setDateFormat( $x )                { return wfSetVar( $this->mDateFormat, $x ); }
        function setEditSection( $x )               { return wfSetVar( $this->mEditSection, $x ); }
        function setNumberHeadings( $x )            { return wfSetVar( $this->mNumberHeadings, $x ); }
-       function setStubThreshold( $x )             { return wfSetVar( $this->mStubThreshold, $x ); }
        function setAllowSpecialInclusion( $x )     { return wfSetVar( $this->mAllowSpecialInclusion, $x ); }
        function setTidy( $x )                      { return wfSetVar( $this->mTidy, $x); }
        function setSkin( $x )                      { $this->mSkin = $x; }
@@ -104,7 +98,7 @@ class ParserOptions {
 
        /**
         * Get parser options
-        * @param $user User
+        * @static
         */
        static function newFromUser( $user ) {
                return new ParserOptions( $user );
@@ -115,9 +109,8 @@ class ParserOptions {
                global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
                global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
                global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth;
-
-               wfProfileIn( __METHOD__ );
-
+               $fname = 'ParserOptions::initialiseFromUser';
+               wfProfileIn( $fname );
                if ( !$userInput ) {
                        global $wgUser;
                        if ( isset( $wgUser ) ) {
@@ -140,7 +133,6 @@ class ParserOptions {
                $this->mDateFormat = null; # Deferred
                $this->mEditSection = true;
                $this->mNumberHeadings = $user->getOption( 'numberheadings' );
-               $this->mStubThreshold = $user->getOption( 'stubthreshold' );
                $this->mAllowSpecialInclusion = $wgAllowSpecialInclusion;
                $this->mTidy = false;
                $this->mInterfaceMessage = false;
@@ -152,7 +144,6 @@ class ParserOptions {
                $this->mRemoveComments = true;
                $this->mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' );
                $this->mEnableLimitReport = false;
-
-               wfProfileOut( __METHOD__ );
+               wfProfileOut( $fname );
        }
 }