Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -3411,7 +3411,11 @@ |
3412 | 3412 | global $wgMaxTocLevel, $wgContLang; |
3413 | 3413 | |
3414 | 3414 | $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 | + } |
3416 | 3420 | |
3417 | 3421 | # Inhibit editsection links if requested in the page |
3418 | 3422 | if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) { |
— | — | @@ -3605,19 +3609,10 @@ |
3606 | 3610 | if( $isTemplate ) { |
3607 | 3611 | # Put a T flag in the section identifier, to indicate to extractSections() |
3608 | 3612 | # 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"); |
3612 | 3614 | } else { |
3613 | | - $titleObj = $this->mTitle; |
3614 | | - $section = $sectionIndex; |
3615 | | - $tooltip = ''; |
| 3615 | + $editlink = $sk->doEditSectionLink($this->mTitle, $sectionIndex, $headlineHint); |
3616 | 3616 | } |
3617 | | - if( $titleObj->quickUserCan( 'edit', $this->mOptions->getUser() ) ){ |
3618 | | - $editlink = $sk->doEditSectionLink( $titleObj, $section, $tooltip ); |
3619 | | - } else { |
3620 | | - $editlink = ''; |
3621 | | - } |
3622 | 3617 | } else { |
3623 | 3618 | $editlink = ''; |
3624 | 3619 | } |
— | — | @@ -4047,6 +4042,7 @@ |
4048 | 4043 | * $options is a bit field, RLH_FOR_UPDATE to select for update |
4049 | 4044 | */ |
4050 | 4045 | function replaceLinkHolders( &$text, $options = 0 ) { |
| 4046 | + global $wgUser; |
4051 | 4047 | global $wgContLang; |
4052 | 4048 | |
4053 | 4049 | $fname = 'Parser::replaceLinkHolders'; |
— | — | @@ -4062,7 +4058,7 @@ |
4063 | 4059 | wfProfileIn( $fname.'-check' ); |
4064 | 4060 | $dbr = wfGetDB( DB_SLAVE ); |
4065 | 4061 | $page = $dbr->tableName( 'page' ); |
4066 | | - $threshold = $this->mOptions->getStubThreshold(); |
| 4062 | + $threshold = $wgUser->getOption('stubthreshold'); |
4067 | 4063 | |
4068 | 4064 | # Sort by namespace |
4069 | 4065 | asort( $this->mLinkHolders['namespaces'] ); |
Index: trunk/phase3/includes/parser/ParserCache.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | function getKey( &$article, &$user ) { |
31 | 31 | global $action; |
32 | 32 | $hash = $user->getPageRenderingHash(); |
33 | | - if( !$article->mTitle->quickUserCan( 'edit', $user ) ) { |
| 33 | + if( !$article->mTitle->quickUserCan( 'edit' ) ) { |
34 | 34 | // section edit links are suppressed even if the user has them on |
35 | 35 | $edit = '!edit=0'; |
36 | 36 | } else { |
Index: trunk/phase3/includes/parser/ParserOptions.php |
— | — | @@ -5,32 +5,32 @@ |
6 | 6 | * @todo document |
7 | 7 | * @ingroup Parser |
8 | 8 | */ |
9 | | -class ParserOptions { |
| 9 | +class ParserOptions |
| 10 | +{ |
10 | 11 | # 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. |
33 | 33 | |
34 | | - var $mUser; //!< Stored user object |
| 34 | + var $mUser; # Stored user object, just used to initialise the skin |
35 | 35 | |
36 | 36 | function getUseTeX() { return $this->mUseTeX; } |
37 | 37 | function getUseDynamicDates() { return $this->mUseDynamicDates; } |
— | — | @@ -39,7 +39,6 @@ |
40 | 40 | function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom; } |
41 | 41 | function getEditSection() { return $this->mEditSection; } |
42 | 42 | function getNumberHeadings() { return $this->mNumberHeadings; } |
43 | | - function getStubThreshold() { return $this->mStubThreshold; } |
44 | 43 | function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; } |
45 | 44 | function getTidy() { return $this->mTidy; } |
46 | 45 | function getInterfaceMessage() { return $this->mInterfaceMessage; } |
— | — | @@ -51,10 +50,6 @@ |
52 | 51 | function getTemplateCallback() { return $this->mTemplateCallback; } |
53 | 52 | function getEnableLimitReport() { return $this->mEnableLimitReport; } |
54 | 53 | |
55 | | - function getUser() { |
56 | | - return $this->mUser; |
57 | | - } |
58 | | - |
59 | 54 | function getSkin() { |
60 | 55 | if ( !isset( $this->mSkin ) ) { |
61 | 56 | $this->mSkin = $this->mUser->getSkin(); |
— | — | @@ -84,7 +79,6 @@ |
85 | 80 | function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat, $x ); } |
86 | 81 | function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); } |
87 | 82 | function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); } |
88 | | - function setStubThreshold( $x ) { return wfSetVar( $this->mStubThreshold, $x ); } |
89 | 83 | function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); } |
90 | 84 | function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); } |
91 | 85 | function setSkin( $x ) { $this->mSkin = $x; } |
— | — | @@ -104,7 +98,7 @@ |
105 | 99 | |
106 | 100 | /** |
107 | 101 | * Get parser options |
108 | | - * @param $user User |
| 102 | + * @static |
109 | 103 | */ |
110 | 104 | static function newFromUser( $user ) { |
111 | 105 | return new ParserOptions( $user ); |
— | — | @@ -115,9 +109,8 @@ |
116 | 110 | global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages; |
117 | 111 | global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize; |
118 | 112 | global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth; |
119 | | - |
120 | | - wfProfileIn( __METHOD__ ); |
121 | | - |
| 113 | + $fname = 'ParserOptions::initialiseFromUser'; |
| 114 | + wfProfileIn( $fname ); |
122 | 115 | if ( !$userInput ) { |
123 | 116 | global $wgUser; |
124 | 117 | if ( isset( $wgUser ) ) { |
— | — | @@ -140,7 +133,6 @@ |
141 | 134 | $this->mDateFormat = null; # Deferred |
142 | 135 | $this->mEditSection = true; |
143 | 136 | $this->mNumberHeadings = $user->getOption( 'numberheadings' ); |
144 | | - $this->mStubThreshold = $user->getOption( 'stubthreshold' ); |
145 | 137 | $this->mAllowSpecialInclusion = $wgAllowSpecialInclusion; |
146 | 138 | $this->mTidy = false; |
147 | 139 | $this->mInterfaceMessage = false; |
— | — | @@ -152,7 +144,6 @@ |
153 | 145 | $this->mRemoveComments = true; |
154 | 146 | $this->mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' ); |
155 | 147 | $this->mEnableLimitReport = false; |
156 | | - |
157 | | - wfProfileOut( __METHOD__ ); |
| 148 | + wfProfileOut( $fname ); |
158 | 149 | } |
159 | 150 | } |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -999,12 +999,11 @@ |
1000 | 1000 | * |
1001 | 1001 | * May provide false positives, but should never provide a false negative. |
1002 | 1002 | * |
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 |
1005 | 1004 | * @return boolean |
1006 | 1005 | */ |
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 ); |
1009 | 1008 | } |
1010 | 1009 | |
1011 | 1010 | /** |
— | — | @@ -1026,17 +1025,13 @@ |
1027 | 1026 | |
1028 | 1027 | /** |
1029 | 1028 | * 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. |
1033 | 1031 | * @return boolean |
1034 | 1032 | */ |
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()); |
1041 | 1036 | } |
1042 | 1037 | |
1043 | 1038 | /** |