r79568 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79567‎ | r79568 | r79569 >
Date:11:31, 4 January 2011
Author:platonides
Status:resolved (Comments)
Tags:
Comment:
Partial revert of r79520, follow up to r79558. Unconditionally use the new format.
For environments post r70783, they will need to rerender pages with __NOEDITSECTION__ or no headings (hopefully those will be simple pages).
There will be no extra parser cache misses for environments pre r70783.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -3697,10 +3697,7 @@
36983698 $showEditLink = $this->mOptions->getEditSection();
36993699 }
37003700 if ( $showEditLink ) {
3701 - $editLinkAsToken = $this->mOptions->getEditSectionTokens();
3702 - if ( $editLinkAsToken ) {
3703 - $this->mOutput->setEditSectionTokens( true );
3704 - }
 3701+ $this->mOutput->setEditSectionTokens( true );
37053702 }
37063703
37073704 # Get all headlines for numbering them and adding funky stuff like [edit]
@@ -3955,39 +3952,28 @@
39563953
39573954 # give headline the correct <h#> tag
39583955 if ( $showEditLink && $sectionIndex !== false ) {
3959 - if ( $editLinkAsToken ) {
3960 - // Output edit section links as markers with styles that can be customized by skins
3961 - if ( $isTemplate ) {
3962 - # Put a T flag in the section identifier, to indicate to extractSections()
3963 - # that sections inside <includeonly> should be counted.
3964 - $editlinkArgs = array( $titleText, "T-$sectionIndex"/*, null */ );
3965 - } else {
3966 - $editlinkArgs = array( $this->mTitle->getPrefixedText(), $sectionIndex, $headlineHint );
3967 - }
3968 - // We use a bit of pesudo-xml for editsection markers. The language converter is run later on
3969 - // Using a UNIQ style marker leads to the converter screwing up the tokens when it converts stuff
3970 - // And trying to insert strip tags fails too. At this point all real inputted tags have already been escaped
3971 - // so we don't have to worry about a user trying to input one of these markers directly.
3972 - // We use a page and section attribute to stop the language converter from converting these important bits
3973 - // of data, but put the headline hint inside a content block because the language converter is supposed to
3974 - // be able to convert that piece of data.
3975 - $editlink = '<editsection page="' . htmlspecialchars($editlinkArgs[0]);
3976 - $editlink .= '" section="' . htmlspecialchars($editlinkArgs[1]) .'"';
3977 - if ( isset($editlinkArgs[2]) ) {
3978 - $editlink .= '>' . $editlinkArgs[2] . '</editsection>';
3979 - } else {
3980 - $editlink .= '/>';
3981 - }
 3956+ // Output edit section links as markers with styles that can be customized by skins
 3957+ if ( $isTemplate ) {
 3958+ # Put a T flag in the section identifier, to indicate to extractSections()
 3959+ # that sections inside <includeonly> should be counted.
 3960+ $editlinkArgs = array( $titleText, "T-$sectionIndex"/*, null */ );
39823961 } else {
3983 - // Output edit section links directly as markup like we used to
3984 - if ( $isTemplate ) {
3985 - # Put a T flag in the section identifier, to indicate to extractSections()
3986 - # that sections inside <includeonly> should be counted.
3987 - $editlink = $sk->doEditSectionLink( Title::newFromText( $titleText ), "T-$sectionIndex", null, $this->mOptions->getUserLang() );
3988 - } else {
3989 - $editlink = $sk->doEditSectionLink( $this->mTitle, $sectionIndex, $headlineHint, $this->mOptions->getUserLang() );
3990 - }
 3962+ $editlinkArgs = array( $this->mTitle->getPrefixedText(), $sectionIndex, $headlineHint );
39913963 }
 3964+ // We use a bit of pesudo-xml for editsection markers. The language converter is run later on
 3965+ // Using a UNIQ style marker leads to the converter screwing up the tokens when it converts stuff
 3966+ // And trying to insert strip tags fails too. At this point all real inputted tags have already been escaped
 3967+ // so we don't have to worry about a user trying to input one of these markers directly.
 3968+ // We use a page and section attribute to stop the language converter from converting these important bits
 3969+ // of data, but put the headline hint inside a content block because the language converter is supposed to
 3970+ // be able to convert that piece of data.
 3971+ $editlink = '<editsection page="' . htmlspecialchars($editlinkArgs[0]);
 3972+ $editlink .= '" section="' . htmlspecialchars($editlinkArgs[1]) .'"';
 3973+ if ( isset($editlinkArgs[2]) ) {
 3974+ $editlink .= '>' . $editlinkArgs[2] . '</editsection>';
 3975+ } else {
 3976+ $editlink .= '/>';
 3977+ }
39923978 } else {
39933979 $editlink = '';
39943980 }
Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -21,7 +21,6 @@
2222 var $mSkin = null; # Reference to the preferred skin
2323 var $mDateFormat = null; # Date format index
2424 var $mEditSection = true; # Create "edit section" links
25 - var $mEditSectionTokens = false; # Output replaceable tokens for editsections instead of markup
2625 var $mAllowSpecialInclusion; # Allow inclusion of special pages
2726 var $mTidy = false; # Ask for tidy cleanup
2827 var $mInterfaceMessage = false; # Which lang to call for PLURAL and GRAMMAR
@@ -57,10 +56,7 @@
5857 function getAllowExternalImages() { return $this->mAllowExternalImages; }
5958 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom; }
6059 function getEnableImageWhitelist() { return $this->mEnableImageWhitelist; }
61 - function getEditSection() { $this->optionUsed('editsection');
62 - return $this->mEditSection; }
63 - function getEditSectionTokens() { $this->optionUsed('editsectiontokens');
64 - return $this->mEditSectionTokens; }
 60+ function getEditSection() { return $this->mEditSection; }
6561 function getNumberHeadings() { $this->optionUsed('numberheadings');
6662 return $this->mNumberHeadings; }
6763 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; }
@@ -126,7 +122,6 @@
127123 function setEnableImageWhitelist( $x ) { return wfSetVar( $this->mEnableImageWhitelist, $x ); }
128124 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat, $x ); }
129125 function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); }
130 - function setEditSectionTokens( $x ) { return wfSetVar( $this->mEditSectionTokens, $x ); }
131126 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); }
132127 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); }
133128 function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); }
@@ -175,7 +170,7 @@
176171 function initialiseFromUser( $userInput ) {
177172 global $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
178173 global $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, $wgMaxArticleSize;
179 - global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures, $wgUseEditSectionTokens;
 174+ global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures;
180175 global $wgExternalLinkTarget, $wgLang;
181176
182177 wfProfileIn( __METHOD__ );
@@ -205,7 +200,6 @@
206201 $this->mMaxTemplateDepth = $wgMaxTemplateDepth;
207202 $this->mCleanSignatures = $wgCleanSignatures;
208203 $this->mExternalLinkTarget = $wgExternalLinkTarget;
209 - $this->mEditSectionTokens = $wgUseEditSectionTokens;
210204
211205 $this->mNumberHeadings = $user->getOption( 'numberheadings' );
212206 $this->mMath = $user->getOption( 'math' );
@@ -310,10 +304,12 @@
311305
312306 $confstr .= $wgRenderHashAppend;
313307
314 - if ( !$this->mEditSection && in_array( 'editsection', $forOptions ) )
 308+ if ( !in_array( 'editsection', $forOptions ) ) {
 309+ $confstr .= '!*';
 310+ } elseif ( !$this->mEditSection ) {
315311 $confstr .= '!edit=0';
316 - if ( $this->mEditSectionTokens && in_array( 'editsectiontokens', $forOptions ) )
317 - $confstr .= '!estok=1';
 312+ }
 313+
318314 if ( $this->mIsPrintable && in_array( 'printable', $forOptions ) )
319315 $confstr .= '!printable=1';
320316
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2846,18 +2846,6 @@
28472847 */
28482848 $wgTranscludeCacheExpiry = 3600;
28492849
2850 -/**
2851 - * Output edit section links as tokens in the parser output for articles instead
2852 - * of directly as markup.
2853 - * This feature changes the default parser cache key so it's presented with a
2854 - * configuration option so that large installations with a large number of already
2855 - * existing parser cache keys can retain them.
2856 - * The purpose of this feature is to allow skins to customize the editsection
2857 - * links, however it has the side effect of also removing the most common use of
2858 - * the getUserLang parser option which causes cache fragmentation by user lang.
2859 - */
2860 -$wgUseEditSectionTokens = true;
2861 -
28622850 /** @} */ # end of parser settings }
28632851
28642852 /************************************************************************//**

Follow-up revisions

RevisionCommit summaryAuthorDate
r79714Prepare for r79568. This uses a different hash key for pages without edit links,...platonides10:51, 6 January 2011
r88988bug 29123: record use of the "editsection" option so that users who can't edi...vyznev18:51, 27 May 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r70783Use only the page relevant pieces in the parser cache key. Eg. two users with...platonides21:53, 9 August 2010
r79520Try to output editsection markers instead of rendered editsection links and d...dantman20:17, 3 January 2011
r79558Followup r79520 and r79528, one of the args was missing when calling doEditSe...dantman04:20, 4 January 2011

Comments

#Comment by Catrope (talk | contribs)   22:28, 5 January 2011

Untagging 1.17, depends on the edit section tokens stuff that we've decided not to merge.

#Comment by Hashar (talk | contribs)   13:11, 2 June 2011

Manually added r88988 as a follow up

#Comment by Hashar (talk | contribs)   13:24, 2 June 2011

Platonides : can you have a look at my comment on r88988 and at bug 29123 ? Thanks!

Status & tagging log