r38208 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38207‎ | r38208 | r38209 >
Date:23:56, 29 July 2008
Author:brion
Status:old
Tags:
Comment:
Revert r38196, r38204 -- "(bugs 6089, 13079) Show edit section links for transcluded template if, and only if the user can edit it, made Title::getUserPermissionsErrorsInternal() public so that it can be used in Parser and it can pass the User object from ParserOptions. " & co
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)]
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserCache.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -3411,7 +3411,11 @@
34123412 global $wgMaxTocLevel, $wgContLang;
34133413
34143414 $doNumberHeadings = $this->mOptions->getNumberHeadings();
3415 - $showEditLink = $this->mOptions->getEditSection();
 3415+ if( !$this->mTitle->quickUserCan( 'edit' ) ) {
 3416+ $showEditLink = 0;
 3417+ } else {
 3418+ $showEditLink = $this->mOptions->getEditSection();
 3419+ }
34163420
34173421 # Inhibit editsection links if requested in the page
34183422 if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
@@ -3605,19 +3609,10 @@
36063610 if( $isTemplate ) {
36073611 # Put a T flag in the section identifier, to indicate to extractSections()
36083612 # that sections inside <includeonly> should be counted.
3609 - $titleObj = Title::newFromText( $titleText );
3610 - $section = "T-$sectionIndex";
3611 - $tooltip = $headlineHint;
 3613+ $editlink = $sk->doEditSectionLink(Title::newFromText( $titleText ), "T-$sectionIndex");
36123614 } else {
3613 - $titleObj = $this->mTitle;
3614 - $section = $sectionIndex;
3615 - $tooltip = '';
 3615+ $editlink = $sk->doEditSectionLink($this->mTitle, $sectionIndex, $headlineHint);
36163616 }
3617 - if( $titleObj->quickUserCan( 'edit', $this->mOptions->getUser() ) ){
3618 - $editlink = $sk->doEditSectionLink( $titleObj, $section, $tooltip );
3619 - } else {
3620 - $editlink = '';
3621 - }
36223617 } else {
36233618 $editlink = '';
36243619 }
@@ -4047,6 +4042,7 @@
40484043 * $options is a bit field, RLH_FOR_UPDATE to select for update
40494044 */
40504045 function replaceLinkHolders( &$text, $options = 0 ) {
 4046+ global $wgUser;
40514047 global $wgContLang;
40524048
40534049 $fname = 'Parser::replaceLinkHolders';
@@ -4062,7 +4058,7 @@
40634059 wfProfileIn( $fname.'-check' );
40644060 $dbr = wfGetDB( DB_SLAVE );
40654061 $page = $dbr->tableName( 'page' );
4066 - $threshold = $this->mOptions->getStubThreshold();
 4062+ $threshold = $wgUser->getOption('stubthreshold');
40674063
40684064 # Sort by namespace
40694065 asort( $this->mLinkHolders['namespaces'] );
Index: trunk/phase3/includes/parser/ParserCache.php
@@ -29,7 +29,7 @@
3030 function getKey( &$article, &$user ) {
3131 global $action;
3232 $hash = $user->getPageRenderingHash();
33 - if( !$article->mTitle->quickUserCan( 'edit', $user ) ) {
 33+ if( !$article->mTitle->quickUserCan( 'edit' ) ) {
3434 // section edit links are suppressed even if the user has them on
3535 $edit = '!edit=0';
3636 } else {
Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -5,32 +5,32 @@
66 * @todo document
77 * @ingroup Parser
88 */
9 -class ParserOptions {
 9+class ParserOptions
 10+{
1011 # All variables are supposed to be private in theory, although in practise this is not the case.
11 - var $mUseTeX; //!< Use texvc to expand <math> tags
12 - var $mUseDynamicDates; //!< Use DateFormatter to format dates
13 - var $mInterwikiMagic; //!< Interlanguage links are removed and returned in an array
14 - var $mAllowExternalImages; //!< Allow external images inline
15 - var $mAllowExternalImagesFrom; //!< If not, any exception?
16 - var $mSkin; //!< Reference to the preferred skin
17 - var $mDateFormat; //!< Date format index
18 - var $mEditSection; //!< Create "edit section" links
19 - var $mNumberHeadings; //!< Automatically number headings
20 - var $mStubThreshold; //!< Treshold for marking pages as "stub"
21 - var $mAllowSpecialInclusion; //!< Allow inclusion of special pages
22 - var $mTidy; //!< Ask for tidy cleanup
23 - var $mInterfaceMessage; //!< Which lang to call for PLURAL and GRAMMAR
24 - var $mTargetLanguage; //!< Overrides above setting with arbitrary language
25 - var $mMaxIncludeSize; //!< Maximum size of template expansions, in bytes
26 - var $mMaxPPNodeCount; //!< Maximum number of nodes touched by PPFrame::expand()
27 - var $mMaxPPExpandDepth; //!< Maximum recursion depth in PPFrame::expand()
28 - var $mMaxTemplateDepth; //!< Maximum recursion depth for templates within templates
29 - var $mRemoveComments; //!< Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
30 - var $mTemplateCallback; //!< Callback for template fetching
31 - var $mEnableLimitReport; //!< Enable limit report in an HTML comment on output
32 - var $mTimestamp; //!< Timestamp used for {{CURRENTDAY}} etc.
 12+ var $mUseTeX; # Use texvc to expand <math> tags
 13+ var $mUseDynamicDates; # Use DateFormatter to format dates
 14+ var $mInterwikiMagic; # Interlanguage links are removed and returned in an array
 15+ var $mAllowExternalImages; # Allow external images inline
 16+ var $mAllowExternalImagesFrom; # If not, any exception?
 17+ var $mSkin; # Reference to the preferred skin
 18+ var $mDateFormat; # Date format index
 19+ var $mEditSection; # Create "edit section" links
 20+ var $mNumberHeadings; # Automatically number headings
 21+ var $mAllowSpecialInclusion; # Allow inclusion of special pages
 22+ var $mTidy; # Ask for tidy cleanup
 23+ var $mInterfaceMessage; # Which lang to call for PLURAL and GRAMMAR
 24+ var $mTargetLanguage; # Overrides above setting with arbitrary language
 25+ var $mMaxIncludeSize; # Maximum size of template expansions, in bytes
 26+ var $mMaxPPNodeCount; # Maximum number of nodes touched by PPFrame::expand()
 27+ var $mMaxPPExpandDepth; # Maximum recursion depth in PPFrame::expand()
 28+ var $mMaxTemplateDepth; # Maximum recursion depth for templates within templates
 29+ var $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
 30+ var $mTemplateCallback; # Callback for template fetching
 31+ var $mEnableLimitReport; # Enable limit report in an HTML comment on output
 32+ var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc.
3333
34 - var $mUser; //!< Stored user object
 34+ var $mUser; # Stored user object, just used to initialise the skin
3535
3636 function getUseTeX() { return $this->mUseTeX; }
3737 function getUseDynamicDates() { return $this->mUseDynamicDates; }
@@ -39,7 +39,6 @@
4040 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom; }
4141 function getEditSection() { return $this->mEditSection; }
4242 function getNumberHeadings() { return $this->mNumberHeadings; }
43 - function getStubThreshold() { return $this->mStubThreshold; }
4443 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; }
4544 function getTidy() { return $this->mTidy; }
4645 function getInterfaceMessage() { return $this->mInterfaceMessage; }
@@ -51,10 +50,6 @@
5251 function getTemplateCallback() { return $this->mTemplateCallback; }
5352 function getEnableLimitReport() { return $this->mEnableLimitReport; }
5453
55 - function getUser() {
56 - return $this->mUser;
57 - }
58 -
5954 function getSkin() {
6055 if ( !isset( $this->mSkin ) ) {
6156 $this->mSkin = $this->mUser->getSkin();
@@ -84,7 +79,6 @@
8580 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat, $x ); }
8681 function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); }
8782 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); }
88 - function setStubThreshold( $x ) { return wfSetVar( $this->mStubThreshold, $x ); }
8983 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); }
9084 function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); }
9185 function setSkin( $x ) { $this->mSkin = $x; }
@@ -104,7 +98,7 @@
10599
106100 /**
107101 * Get parser options
108 - * @param $user User
 102+ * @static
109103 */
110104 static function newFromUser( $user ) {
111105 return new ParserOptions( $user );
@@ -115,9 +109,8 @@
116110 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
117111 global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
118112 global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth;
119 -
120 - wfProfileIn( __METHOD__ );
121 -
 113+ $fname = 'ParserOptions::initialiseFromUser';
 114+ wfProfileIn( $fname );
122115 if ( !$userInput ) {
123116 global $wgUser;
124117 if ( isset( $wgUser ) ) {
@@ -140,7 +133,6 @@
141134 $this->mDateFormat = null; # Deferred
142135 $this->mEditSection = true;
143136 $this->mNumberHeadings = $user->getOption( 'numberheadings' );
144 - $this->mStubThreshold = $user->getOption( 'stubthreshold' );
145137 $this->mAllowSpecialInclusion = $wgAllowSpecialInclusion;
146138 $this->mTidy = false;
147139 $this->mInterfaceMessage = false;
@@ -152,7 +144,6 @@
153145 $this->mRemoveComments = true;
154146 $this->mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' );
155147 $this->mEnableLimitReport = false;
156 -
157 - wfProfileOut( __METHOD__ );
 148+ wfProfileOut( $fname );
158149 }
159150 }
Index: trunk/phase3/includes/Title.php
@@ -999,12 +999,11 @@
10001000 *
10011001 * May provide false positives, but should never provide a false negative.
10021002 *
1003 - * @param $action String: action that permission needs to be checked for
1004 - * @param $user User object, optional
 1003+ * @param string $action action that permission needs to be checked for
10051004 * @return boolean
10061005 */
1007 - public function quickUserCan( $action, $user = null ) {
1008 - return $this->userCan( $action, false, $user );
 1006+ public function quickUserCan( $action ) {
 1007+ return $this->userCan( $action, false );
10091008 }
10101009
10111010 /**
@@ -1026,17 +1025,13 @@
10271026
10281027 /**
10291028 * Can $wgUser perform $action on this page?
1030 - * @param $action String: action that permission needs to be checked for
1031 - * @param $doExpensiveQueries Bool: set this to false to avoid doing unnecessary queries.
1032 - * @param $user User object, optional
 1029+ * @param string $action action that permission needs to be checked for
 1030+ * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries.
10331031 * @return boolean
10341032 */
1035 - public function userCan( $action, $doExpensiveQueries = true, $user = null ) {
1036 - if( $user === null ){
1037 - global $wgUser;
1038 - $user = $wgUser;
1039 - }
1040 - return ( $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries ) === array());
 1033+ public function userCan( $action, $doExpensiveQueries = true ) {
 1034+ global $wgUser;
 1035+ return ( $this->getUserPermissionsErrorsInternal( $action, $wgUser, $doExpensiveQueries ) === array());
10411036 }
10421037
10431038 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r53308Fix parser tests for r52213....catrope11:29, 15 July 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r21725* (bug 6204) Fixes for indentation with $wgMaxTocLevel:...brion19:51, 30 April 2007
r21810Add parser test for regression bug 9764brion18:45, 2 May 2007
r21829Revert r21725 (bug 6204) due to regressions (bug 9764). Will leave it to be w...brion17:14, 3 May 2007
r21833Parser test for bug #6204 : TOC not properly rendered when using $wgMaxTocLevelhashar17:49, 3 May 2007
r25291Revert r25260; breaks several parser tests cases, seems to be borking up sect...brion16:01, 29 August 2007
r25303Merged revisions 25215-25302 via svnmerge from...david07:10, 30 August 2007
r29292* Merged comment handling with the main loop of preprocessToDom(). This fixes...tstarling12:39, 5 January 2008
r31931* (bug 10721) Duplicate section anchors with differing case now disambiguated...brion18:30, 13 March 2008
r32387* (bug 12077) Fix HTML nesting for TOC...brion23:33, 24 March 2008
r32998* (bug 12077) Fix HTML nesting for TOC...brion23:48, 8 April 2008
r38196* (bugs 6089, 13079) Show edit section links for transcluded template if, and...ialex17:28, 29 July 2008
r38204Per talk with Simetrical, add a param to Title::quickUserCan and Title::userC...ialex20:35, 29 July 2008
r38207Decapitalising all group-*-member messages in English; these words are neithe...jhsoby21:49, 29 July 2008

Status & tagging log