r64409 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64408‎ | r64409 | r64410 >
Date:21:53, 30 March 2010
Author:happy-melon
Status:ok (Comments)
Tags:
Comment:
Rationalise comment format. Slightly controversial, perhaps, but I've pretty much borked svn blame already :D Also other doc and spacing fixes.
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -17,17 +17,17 @@
1818 * <pre>
1919 * There are five main entry points into the Parser class:
2020 * parse()
21 - * produces HTML output
 21+ * produces HTML output
2222 * preSaveTransform().
23 - * produces altered wiki markup.
 23+ * produces altered wiki markup.
2424 * preprocess()
25 - * removes HTML comments and expands templates
 25+ * removes HTML comments and expands templates
2626 * cleanSig()
27 - * Cleans a signature before saving it to preferences
 27+ * Cleans a signature before saving it to preferences
2828 * extractSections()
29 - * Extracts sections from an article for section editing
 29+ * Extracts sections from an article for section editing
3030 * getPreloadText()
31 - * Removes <noinclude> sections, and <includeonly> tags.
 31+ * Removes <noinclude> sections, and <includeonly> tags.
3232 *
3333 * Globals used:
3434 * objects: $wgLang, $wgContLang
@@ -64,7 +64,7 @@
6565 const EXT_IMAGE_REGEX = '/^(http:\/\/|https:\/\/)([^][<>"\\x00-\\x20\\x7F]+)
6666 \\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg)$/Sx';
6767
68 - // State constants for the definition list colon extraction
 68+ # State constants for the definition list colon extraction
6969 const COLON_STATE_TEXT = 0;
7070 const COLON_STATE_TAG = 1;
7171 const COLON_STATE_TAGSTART = 2;
@@ -74,23 +74,20 @@
7575 const COLON_STATE_COMMENTDASH = 6;
7676 const COLON_STATE_COMMENTDASHDASH = 7;
7777
78 - // Flags for preprocessToDom
 78+ # Flags for preprocessToDom
7979 const PTD_FOR_INCLUSION = 1;
8080
81 - // Allowed values for $this->mOutputType
82 - // Parameter to startExternalParse().
83 - const OT_HTML = 1; // like parse()
84 - const OT_WIKI = 2; // like preSaveTransform()
85 - const OT_PREPROCESS = 3; // like preprocess()
 81+ # Allowed values for $this->mOutputType
 82+ # Parameter to startExternalParse().
 83+ const OT_HTML = 1; # like parse()
 84+ const OT_WIKI = 2; # like preSaveTransform()
 85+ const OT_PREPROCESS = 3; # like preprocess()
8686 const OT_MSG = 3;
87 - const OT_PLAIN = 4; // like extractSections() - portions of the original are returned unchanged.
 87+ const OT_PLAIN = 4; # like extractSections() - portions of the original are returned unchanged.
8888
89 - // Marker Suffix needs to be accessible staticly.
 89+ # Marker Suffix needs to be accessible staticly.
9090 const MARKER_SUFFIX = "-QINU\x7f";
9191
92 - /**#@+
93 - * @private
94 - */
9592 # Persistent:
9693 var $mTagHooks, $mTransparentTagHooks, $mFunctionHooks, $mFunctionSynonyms, $mVariables;
9794 var $mSubstWords, $mImageParams, $mImageParamsMagicArray, $mStripList, $mMarkerIndex;
@@ -103,22 +100,20 @@
104101 var $mIncludeCount, $mArgStack, $mLastSection, $mInPre;
105102 var $mLinkHolders, $mLinkID;
106103 var $mIncludeSizes, $mPPNodeCount, $mDefaultSort;
107 - var $mTplExpandCache; // empty-frame expansion cache
 104+ var $mTplExpandCache; # empty-frame expansion cache
108105 var $mTplRedirCache, $mTplDomCache, $mHeadings, $mDoubleUnderscores;
109 - var $mExpensiveFunctionCount; // number of expensive parser function calls
 106+ var $mExpensiveFunctionCount; # number of expensive parser function calls
110107
111108 # Temporary
112109 # These are variables reset at least once per parse regardless of $clearState
113 - var $mOptions; // ParserOptions object
114 - var $mTitle; // Title context, used for self-link rendering and similar things
115 - var $mOutputType; // Output type, one of the OT_xxx constants
116 - var $ot; // Shortcut alias, see setOutputType()
117 - var $mRevisionId; // ID to display in {{REVISIONID}} tags
118 - var $mRevisionTimestamp; // The timestamp of the specified revision ID
119 - var $mRevIdForTs; // The revision ID which was used to fetch the timestamp
 110+ var $mOptions; # ParserOptions object
 111+ var $mTitle; # Title context, used for self-link rendering and similar things
 112+ var $mOutputType; # Output type, one of the OT_xxx constants
 113+ var $ot; # Shortcut alias, see setOutputType()
 114+ var $mRevisionId; # ID to display in {{REVISIONID}} tags
 115+ var $mRevisionTimestamp; # The timestamp of the specified revision ID
 116+ var $mRevIdForTs; # The revision ID which was used to fetch the timestamp
120117
121 - /**#@-*/
122 -
123118 /**
124119 * Constructor
125120 *
@@ -139,7 +134,7 @@
140135 if ( isset( $conf['preprocessorClass'] ) ) {
141136 $this->mPreprocessorClass = $conf['preprocessorClass'];
142137 } elseif ( extension_loaded( 'domxml' ) ) {
143 - // PECL extension that conflicts with the core DOM extension (bug 13770)
 138+ # PECL extension that conflicts with the core DOM extension (bug 13770)
144139 wfDebug( "Warning: you have the obsolete domxml extension for PHP. Please remove it!\n" );
145140 $this->mPreprocessorClass = 'Preprocessor_Hash';
146141 } elseif ( extension_loaded( 'dom' ) ) {
@@ -246,7 +241,7 @@
247242
248243 function setOutputType( $ot ) {
249244 $this->mOutputType = $ot;
250 - // Shortcut alias
 245+ # Shortcut alias
251246 $this->ot = array(
252247 'html' => $ot == self::OT_HTML,
253248 'wiki' => $ot == self::OT_WIKI,
@@ -279,13 +274,13 @@
280275 */
281276 function uniqPrefix() {
282277 if ( !isset( $this->mUniqPrefix ) ) {
283 - // @todo Fixme: this is probably *horribly wrong*
284 - // LanguageConverter seems to want $wgParser's uniqPrefix, however
285 - // if this is called for a parser cache hit, the parser may not
286 - // have ever been initialized in the first place.
287 - // Not really sure what the heck is supposed to be going on here.
 278+ # @todo Fixme: this is probably *horribly wrong*
 279+ # LanguageConverter seems to want $wgParser's uniqPrefix, however
 280+ # if this is called for a parser cache hit, the parser may not
 281+ # have ever been initialized in the first place.
 282+ # Not really sure what the heck is supposed to be going on here.
288283 return '';
289 - // throw new MWException( "Accessing uninitialized mUniqPrefix" );
 284+ # throw new MWException( "Accessing uninitialized mUniqPrefix" );
290285 }
291286 return $this->mUniqPrefix;
292287 }
@@ -318,7 +313,7 @@
319314 }
320315
321316 $this->mOptions = $options;
322 - $this->setTitle( $title ); // Page title has to be set for the pre-processor
 317+ $this->setTitle( $title ); # Page title has to be set for the pre-processor
323318
324319 $oldRevisionId = $this->mRevisionId;
325320 $oldRevisionTimestamp = $this->mRevisionTimestamp;
@@ -349,9 +344,9 @@
350345
351346 $this->replaceLinkHolders( $text );
352347
353 - // The position of the convert() call should not be changed. it
354 - // assumes that the links are all replaced and the only thing left
355 - // is the <nowiki> mark.
 348+ # The position of the convert() call should not be changed. it
 349+ # assumes that the links are all replaced and the only thing left
 350+ # is the <nowiki> mark.
356351 if ( !( $wgDisableLangConversion
357352 || isset( $this->mDoubleUnderscores['nocontentconvert'] )
358353 || $this->mTitle->isTalkPage()
@@ -359,10 +354,10 @@
360355 $text = $wgContLang->convert( $text );
361356 }
362357
363 - // A title may have been set in a conversion rule.
364 - // Note that if a user tries to set a title in a conversion
365 - // rule but content conversion was not done, then the parser
366 - // won't pick it up. This is probably expected behavior.
 358+ # A title may have been set in a conversion rule.
 359+ # Note that if a user tries to set a title in a conversion
 360+ # rule but content conversion was not done, then the parser
 361+ # won't pick it up. This is probably expected behavior.
367362 if ( $wgContLang->getConvRuleTitle() ) {
368363 $this->mOutput->setTitleText( $wgContLang->getConvRuleTitle() );
369364 }
@@ -497,7 +492,7 @@
498493 * comments, templates, arguments, tags hooks and parser functions are untouched.
499494 */
500495 public function getPreloadText( $text, $title, $options ) {
501 - // Parser (re)initialisation
 496+ # Parser (re)initialisation
502497 $this->clearState();
503498 $this->setOutputType( self::OT_PLAIN );
504499 $this->mOptions = $options;
@@ -579,13 +574,13 @@
580575 break;
581576 }
582577 if ( count( $p ) > 5 ) {
583 - // comment
 578+ # comment
584579 $element = $p[4];
585580 $attributes = '';
586581 $close = '';
587582 $inside = $p[5];
588583 } else {
589 - // tag
 584+ # tag
590585 $element = $p[1];
591586 $attributes = $p[2];
592587 $close = $p[3];
@@ -596,7 +591,7 @@
597592 $stripped .= $marker;
598593
599594 if ( $close === '/>' ) {
600 - // Empty element tag, <tag />
 595+ # Empty element tag, <tag />
601596 $content = null;
602597 $text = $inside;
603598 $tail = null;
@@ -701,17 +696,17 @@
702697
703698 $lines = StringUtils::explode( "\n", $text );
704699 $out = '';
705 - $td_history = array(); // Is currently a td tag open?
706 - $last_tag_history = array(); // Save history of last lag activated (td, th or caption)
707 - $tr_history = array(); // Is currently a tr tag open?
708 - $tr_attributes = array(); // history of tr attributes
709 - $has_opened_tr = array(); // Did this table open a <tr> element?
710 - $indent_level = 0; // indent level of the table
 700+ $td_history = array(); # Is currently a td tag open?
 701+ $last_tag_history = array(); # Save history of last lag activated (td, th or caption)
 702+ $tr_history = array(); # Is currently a tr tag open?
 703+ $tr_attributes = array(); # history of tr attributes
 704+ $has_opened_tr = array(); # Did this table open a <tr> element?
 705+ $indent_level = 0; # indent level of the table
711706
712707 foreach ( $lines as $outLine ) {
713708 $line = trim( $outLine );
714709
715 - if ( $line == '' ) { // empty line, go to next line
 710+ if ( $line == '' ) { # empty line, go to next line
716711 $out .= $outLine."\n";
717712 continue;
718713 }
@@ -719,7 +714,7 @@
720715 $matches = array();
721716
722717 if ( preg_match( '/^(:*)\{\|(.*)$/', $line , $matches ) ) {
723 - // First check if we are starting a new table
 718+ # First check if we are starting a new table
724719 $indent_level = strlen( $matches[1] );
725720
726721 $attributes = $this->mStripState->unstripBoth( $matches[2] );
@@ -732,11 +727,11 @@
733728 array_push( $tr_attributes , '' );
734729 array_push( $has_opened_tr , false );
735730 } elseif ( count( $td_history ) == 0 ) {
736 - // Don't do any of the following
 731+ # Don't do any of the following
737732 $out .= $outLine."\n";
738733 continue;
739734 } elseif ( substr( $line , 0 , 2 ) === '|}' ) {
740 - // We are ending a table
 735+ # We are ending a table
741736 $line = '</table>' . substr( $line , 2 );
742737 $last_tag = array_pop( $last_tag_history );
743738
@@ -754,10 +749,10 @@
755750 array_pop( $tr_attributes );
756751 $outLine = $line . str_repeat( '</dd></dl>' , $indent_level );
757752 } elseif ( substr( $line , 0 , 2 ) === '|-' ) {
758 - // Now we have a table row
 753+ # Now we have a table row
759754 $line = preg_replace( '#^\|-+#', '', $line );
760755
761 - // Whats after the tag is now only attributes
 756+ # Whats after the tag is now only attributes
762757 $attributes = $this->mStripState->unstripBoth( $line );
763758 $attributes = Sanitizer::fixTagAttributes( $attributes, 'tr' );
764759 array_pop( $tr_attributes );
@@ -781,7 +776,7 @@
782777 array_push( $td_history , false );
783778 array_push( $last_tag_history , '' );
784779 } elseif ( $first_character === '|' || $first_character === '!' || substr( $line , 0 , 2 ) === '|+' ) {
785 - // This might be cell elements, td, th or captions
 780+ # This might be cell elements, td, th or captions
786781 if ( substr( $line , 0 , 2 ) === '|+' ) {
787782 $first_character = '+';
788783 $line = substr( $line , 1 );
@@ -793,15 +788,15 @@
794789 $line = str_replace( '!!' , '||' , $line );
795790 }
796791
797 - // Split up multiple cells on the same line.
798 - // FIXME : This can result in improper nesting of tags processed
799 - // by earlier parser steps, but should avoid splitting up eg
800 - // attribute values containing literal "||".
 792+ # Split up multiple cells on the same line.
 793+ # FIXME : This can result in improper nesting of tags processed
 794+ # by earlier parser steps, but should avoid splitting up eg
 795+ # attribute values containing literal "||".
801796 $cells = StringUtils::explodeMarkup( '||' , $line );
802797
803798 $outLine = '';
804799
805 - // Loop through each table cell
 800+ # Loop through each table cell
806801 foreach ( $cells as $cell ) {
807802 $previous = '';
808803 if ( $first_character !== '+' ) {
@@ -833,11 +828,11 @@
834829
835830 array_push( $last_tag_history , $last_tag );
836831
837 - // A cell could contain both parameters and data
 832+ # A cell could contain both parameters and data
838833 $cell_data = explode( '|' , $cell , 2 );
839834
840 - // Bug 553: Note that a '|' inside an invalid link should not
841 - // be mistaken as delimiting cell parameters
 835+ # Bug 553: Note that a '|' inside an invalid link should not
 836+ # be mistaken as delimiting cell parameters
842837 if ( strpos( $cell_data[0], '[[' ) !== false ) {
843838 $cell = "{$previous}<{$last_tag}>{$cell}";
844839 } elseif ( count( $cell_data ) == 1 ) {
@@ -855,7 +850,7 @@
856851 $out .= $outLine . "\n";
857852 }
858853
859 - // Closing open td, tr && table
 854+ # Closing open td, tr && table
860855 while ( count( $td_history ) > 0 ) {
861856 if ( array_pop( $td_history ) ) {
862857 $out .= "</td>\n";
@@ -870,12 +865,12 @@
871866 $out .= "</table>\n";
872867 }
873868
874 - // Remove trailing line-ending (b/c)
 869+ # Remove trailing line-ending (b/c)
875870 if ( substr( $out, -1 ) === "\n" ) {
876871 $out = substr( $out, 0, -1 );
877872 }
878873
879 - // special case: don't return empty table
 874+ # special case: don't return empty table
880875 if ( $out === "<table>\n<tr><td></td></tr>\n</table>" ) {
881876 $out = '';
882877 }
@@ -902,10 +897,10 @@
903898 return $text ;
904899 }
905900
906 - // if $frame is provided, then use $frame for replacing any variables
 901+ # if $frame is provided, then use $frame for replacing any variables
907902 if ( $frame ) {
908 - // use frame depth to infer how include/noinclude tags should be handled
909 - // depth=0 means this is the top-level document; otherwise it's an included document
 903+ # use frame depth to infer how include/noinclude tags should be handled
 904+ # depth=0 means this is the top-level document; otherwise it's an included document
910905 if ( !$frame->depth ) {
911906 $flag = 0;
912907 } else {
@@ -914,17 +909,17 @@
915910 $text = $frame->expand( $dom );
916911 }
917912 } else {
918 - // if $frame is not provided, then use old-style replaceVariables
 913+ # if $frame is not provided, then use old-style replaceVariables
919914 $text = $this->replaceVariables( $text );
920915 }
921916
922917 $text = Sanitizer::removeHTMLtags( $text, array( &$this, 'attributeStripCallback' ), false, array_keys( $this->mTransparentTagHooks ) );
923918 wfRunHooks( 'InternalParseBeforeLinks', array( &$this, &$text, &$this->mStripState ) );
924919
925 - // Tables need to come after variable replacement for things to work
926 - // properly; putting them before other transformations should keep
927 - // exciting things like link expansions from showing up in surprising
928 - // places.
 920+ # Tables need to come after variable replacement for things to work
 921+ # properly; putting them before other transformations should keep
 922+ # exciting things like link expansions from showing up in surprising
 923+ # places.
929924 $text = $this->doTableStuff( $text );
930925
931926 $text = preg_replace( '/(^|\n)-----*/', '\\1<hr />', $text );
@@ -1418,12 +1413,12 @@
14191414 private static function replaceUnusualEscapesCallback( $matches ) {
14201415 $char = urldecode( $matches[0] );
14211416 $ord = ord( $char );
1422 - // Is it an unsafe or HTTP reserved character according to RFC 1738?
 1417+ # Is it an unsafe or HTTP reserved character according to RFC 1738?
14231418 if ( $ord > 32 && $ord < 127 && strpos( '<>"#{}|\^~[]`;/?', $char ) === false ) {
1424 - // No, shouldn't be escaped
 1419+ # No, shouldn't be escaped
14251420 return $char;
14261421 } else {
1427 - // Yes, leave it escaped
 1422+ # Yes, leave it escaped
14281423 return $matches[0];
14291424 }
14301425 }
@@ -1849,7 +1844,7 @@
18501845 function makeKnownLinkHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
18511846 list( $inside, $trail ) = Linker::splitTrail( $trail );
18521847 $sk = $this->mOptions->getSkin();
1853 - // FIXME: use link() instead of deprecated makeKnownLinkObj()
 1848+ # FIXME: use link() instead of deprecated makeKnownLinkObj()
18541849 $link = $sk->makeKnownLinkObj( $nt, $text, $query, $inside, $prefix );
18551850 return $this->armorLinks( $link ) . $trail;
18561851 }
@@ -1893,7 +1888,7 @@
18941889 * Used by doBlockLevels()
18951890 * @private
18961891 */
1897 - /* private */ function closeParagraph() {
 1892+ function closeParagraph() {
18981893 $result = '';
18991894 if ( $this->mLastSection != '' ) {
19001895 $result = '</' . $this->mLastSection . ">\n";
@@ -1945,7 +1940,12 @@
19461941 return $result;
19471942 }
19481943
1949 - /* private */ function nextItem( $char ) {
 1944+ /**
 1945+ * TODO: document
 1946+ * @param $char String
 1947+ * @private
 1948+ */
 1949+ function nextItem( $char ) {
19501950 if ( '*' === $char || '#' === $char ) {
19511951 return '</li><li>';
19521952 } elseif ( ':' === $char || ';' === $char ) {
@@ -1964,7 +1964,12 @@
19651965 return '<!-- ERR 2 -->';
19661966 }
19671967
1968 - /* private */ function closeList( $char ) {
 1968+ /**
 1969+ * TODO: document
 1970+ * @param $char String
 1971+ * @private
 1972+ */
 1973+ function closeList( $char ) {
19691974 if ( '*' === $char ) {
19701975 $text = '</li></ul>';
19711976 } elseif ( '#' === $char ) {
@@ -2011,24 +2016,24 @@
20122017 $linestart = true;
20132018 continue;
20142019 }
2015 - // * = ul
2016 - // # = ol
2017 - // ; = dt
2018 - // : = dd
 2020+ # * = ul
 2021+ # # = ol
 2022+ # ; = dt
 2023+ # : = dd
20192024
20202025 $lastPrefixLength = strlen( $lastPrefix );
20212026 $preCloseMatch = preg_match( '/<\\/pre/i', $oLine );
20222027 $preOpenMatch = preg_match( '/<pre/i', $oLine );
2023 - // If not in a <pre> element, scan for and figure out what prefixes are there.
 2028+ # If not in a <pre> element, scan for and figure out what prefixes are there.
20242029 if ( !$this->mInPre ) {
20252030 # Multiple prefixes may abut each other for nested lists.
20262031 $prefixLength = strspn( $oLine, '*#:;' );
20272032 $prefix = substr( $oLine, 0, $prefixLength );
20282033
20292034 # eh?
2030 - // ; and : are both from definition-lists, so they're equivalent
2031 - // for the purposes of determining whether or not we need to open/close
2032 - // elements.
 2035+ # ; and : are both from definition-lists, so they're equivalent
 2036+ # for the purposes of determining whether or not we need to open/close
 2037+ # elements.
20332038 $prefix2 = str_replace( ';', ':', $prefix );
20342039 $t = substr( $oLine, $prefixLength );
20352040 $this->mInPre = (bool)$preOpenMatch;
@@ -2057,24 +2062,24 @@
20582063 }
20592064 }
20602065 } elseif ( $prefixLength || $lastPrefixLength ) {
2061 - // We need to open or close prefixes, or both.
 2066+ # We need to open or close prefixes, or both.
20622067
20632068 # Either open or close a level...
20642069 $commonPrefixLength = $this->getCommon( $prefix, $lastPrefix );
20652070 $paragraphStack = false;
20662071
2067 - // Close all the prefixes which aren't shared.
 2072+ # Close all the prefixes which aren't shared.
20682073 while ( $commonPrefixLength < $lastPrefixLength ) {
20692074 $output .= $this->closeList( $lastPrefix[$lastPrefixLength-1] );
20702075 --$lastPrefixLength;
20712076 }
20722077
2073 - // Continue the current prefix if appropriate.
 2078+ # Continue the current prefix if appropriate.
20742079 if ( $prefixLength <= $commonPrefixLength && $commonPrefixLength > 0 ) {
20752080 $output .= $this->nextItem( $prefix[$commonPrefixLength-1] );
20762081 }
20772082
2078 - // Open prefixes where appropriate.
 2083+ # Open prefixes where appropriate.
20792084 while ( $prefixLength > $commonPrefixLength ) {
20802085 $char = substr( $prefix, $commonPrefixLength, 1 );
20812086 $output .= $this->openList( $char );
@@ -2091,11 +2096,11 @@
20922097 $lastPrefix = $prefix2;
20932098 }
20942099
2095 - // If we have no prefixes, go to paragraph mode.
 2100+ # If we have no prefixes, go to paragraph mode.
20962101 if ( 0 == $prefixLength ) {
20972102 wfProfileIn( __METHOD__."-paragraph" );
20982103 # No prefix (not in list)--go to paragraph mode
2099 - // XXX: use a stack for nestable elements like span, table and div
 2104+ # XXX: use a stack for nestable elements like span, table and div
21002105 $openmatch = preg_match('/(?:<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<li|<\\/tr|<\\/td|<\\/th)/iS', $t );
21012106 $closematch = preg_match(
21022107 '/(?:<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|'.
@@ -2114,7 +2119,7 @@
21152120 }
21162121 } elseif ( !$inBlockElem && !$this->mInPre ) {
21172122 if ( ' ' == substr( $t, 0, 1 ) and ( $this->mLastSection === 'pre' || trim( $t ) != '' ) ) {
2118 - // pre
 2123+ # pre
21192124 if ( $this->mLastSection !== 'pre' ) {
21202125 $paragraphStack = false;
21212126 $output .= $this->closeParagraph().'<pre>';
@@ -2122,7 +2127,7 @@
21232128 }
21242129 $t = substr( $t, 1 );
21252130 } else {
2126 - // paragraph
 2131+ # paragraph
21272132 if ( trim( $t ) == '' ) {
21282133 if ( $paragraphStack ) {
21292134 $output .= $paragraphStack.'<br />';
@@ -2151,7 +2156,7 @@
21522157 }
21532158 wfProfileOut( __METHOD__."-paragraph" );
21542159 }
2155 - // somewhere above we forget to get out of pre block (bug 785)
 2160+ # somewhere above we forget to get out of pre block (bug 785)
21562161 if ( $preCloseMatch && $this->mInPre ) {
21572162 $this->mInPre = false;
21582163 }
@@ -2185,21 +2190,21 @@
21862191
21872192 $pos = strpos( $str, ':' );
21882193 if ( $pos === false ) {
2189 - // Nothing to find!
 2194+ # Nothing to find!
21902195 wfProfileOut( __METHOD__ );
21912196 return false;
21922197 }
21932198
21942199 $lt = strpos( $str, '<' );
21952200 if ( $lt === false || $lt > $pos ) {
2196 - // Easy; no tag nesting to worry about
 2201+ # Easy; no tag nesting to worry about
21972202 $before = substr( $str, 0, $pos );
21982203 $after = substr( $str, $pos+1 );
21992204 wfProfileOut( __METHOD__ );
22002205 return $pos;
22012206 }
22022207
2203 - // Ugly state machine to walk through avoiding tags.
 2208+ # Ugly state machine to walk through avoiding tags.
22042209 $state = self::COLON_STATE_TEXT;
22052210 $stack = 0;
22062211 $len = strlen( $str );
@@ -2207,35 +2212,35 @@
22082213 $c = $str{$i};
22092214
22102215 switch( $state ) {
2211 - // (Using the number is a performance hack for common cases)
2212 - case 0: // self::COLON_STATE_TEXT:
 2216+ # (Using the number is a performance hack for common cases)
 2217+ case 0: # self::COLON_STATE_TEXT:
22132218 switch( $c ) {
22142219 case "<":
2215 - // Could be either a <start> tag or an </end> tag
 2220+ # Could be either a <start> tag or an </end> tag
22162221 $state = self::COLON_STATE_TAGSTART;
22172222 break;
22182223 case ":":
22192224 if ( $stack == 0 ) {
2220 - // We found it!
 2225+ # We found it!
22212226 $before = substr( $str, 0, $i );
22222227 $after = substr( $str, $i + 1 );
22232228 wfProfileOut( __METHOD__ );
22242229 return $i;
22252230 }
2226 - // Embedded in a tag; don't break it.
 2231+ # Embedded in a tag; don't break it.
22272232 break;
22282233 default:
2229 - // Skip ahead looking for something interesting
 2234+ # Skip ahead looking for something interesting
22302235 $colon = strpos( $str, ':', $i );
22312236 if ( $colon === false ) {
2232 - // Nothing else interesting
 2237+ # Nothing else interesting
22332238 wfProfileOut( __METHOD__ );
22342239 return false;
22352240 }
22362241 $lt = strpos( $str, '<', $i );
22372242 if ( $stack === 0 ) {
22382243 if ( $lt === false || $colon < $lt ) {
2239 - // We found it!
 2244+ # We found it!
22402245 $before = substr( $str, 0, $colon );
22412246 $after = substr( $str, $colon + 1 );
22422247 wfProfileOut( __METHOD__ );
@@ -2243,31 +2248,31 @@
22442249 }
22452250 }
22462251 if ( $lt === false ) {
2247 - // Nothing else interesting to find; abort!
2248 - // We're nested, but there's no close tags left. Abort!
 2252+ # Nothing else interesting to find; abort!
 2253+ # We're nested, but there's no close tags left. Abort!
22492254 break 2;
22502255 }
2251 - // Skip ahead to next tag start
 2256+ # Skip ahead to next tag start
22522257 $i = $lt;
22532258 $state = self::COLON_STATE_TAGSTART;
22542259 }
22552260 break;
2256 - case 1: // self::COLON_STATE_TAG:
2257 - // In a <tag>
 2261+ case 1: # self::COLON_STATE_TAG:
 2262+ # In a <tag>
22582263 switch( $c ) {
22592264 case ">":
22602265 $stack++;
22612266 $state = self::COLON_STATE_TEXT;
22622267 break;
22632268 case "/":
2264 - // Slash may be followed by >?
 2269+ # Slash may be followed by >?
22652270 $state = self::COLON_STATE_TAGSLASH;
22662271 break;
22672272 default:
2268 - // ignore
 2273+ # ignore
22692274 }
22702275 break;
2271 - case 2: // self::COLON_STATE_TAGSTART:
 2276+ case 2: # self::COLON_STATE_TAGSTART:
22722277 switch( $c ) {
22732278 case "/":
22742279 $state = self::COLON_STATE_CLOSETAG;
@@ -2276,15 +2281,15 @@
22772282 $state = self::COLON_STATE_COMMENT;
22782283 break;
22792284 case ">":
2280 - // Illegal early close? This shouldn't happen D:
 2285+ # Illegal early close? This shouldn't happen D:
22812286 $state = self::COLON_STATE_TEXT;
22822287 break;
22832288 default:
22842289 $state = self::COLON_STATE_TAG;
22852290 }
22862291 break;
2287 - case 3: // self::COLON_STATE_CLOSETAG:
2288 - // In a </tag>
 2292+ case 3: # self::COLON_STATE_CLOSETAG:
 2293+ # In a </tag>
22892294 if ( $c === ">" ) {
22902295 $stack--;
22912296 if ( $stack < 0 ) {
@@ -2297,14 +2302,14 @@
22982303 break;
22992304 case self::COLON_STATE_TAGSLASH:
23002305 if ( $c === ">" ) {
2301 - // Yes, a self-closed tag <blah/>
 2306+ # Yes, a self-closed tag <blah/>
23022307 $state = self::COLON_STATE_TEXT;
23032308 } else {
2304 - // Probably we're jumping the gun, and this is an attribute
 2309+ # Probably we're jumping the gun, and this is an attribute
23052310 $state = self::COLON_STATE_TAG;
23062311 }
23072312 break;
2308 - case 5: // self::COLON_STATE_COMMENT:
 2313+ case 5: # self::COLON_STATE_COMMENT:
23092314 if ( $c === "-" ) {
23102315 $state = self::COLON_STATE_COMMENTDASH;
23112316 }
@@ -2470,50 +2475,50 @@
24712476 $value = $subjPage->getPrefixedUrl();
24722477 break;
24732478 case 'revisionid':
2474 - // Let the edit saving system know we should parse the page
2475 - // *after* a revision ID has been assigned.
 2479+ # Let the edit saving system know we should parse the page
 2480+ # *after* a revision ID has been assigned.
24762481 $this->mOutput->setFlag( 'vary-revision' );
24772482 wfDebug( __METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n" );
24782483 $value = $this->mRevisionId;
24792484 break;
24802485 case 'revisionday':
2481 - // Let the edit saving system know we should parse the page
2482 - // *after* a revision ID has been assigned. This is for null edits.
 2486+ # Let the edit saving system know we should parse the page
 2487+ # *after* a revision ID has been assigned. This is for null edits.
24832488 $this->mOutput->setFlag( 'vary-revision' );
24842489 wfDebug( __METHOD__ . ": {{REVISIONDAY}} used, setting vary-revision...\n" );
24852490 $value = intval( substr( $this->getRevisionTimestamp(), 6, 2 ) );
24862491 break;
24872492 case 'revisionday2':
2488 - // Let the edit saving system know we should parse the page
2489 - // *after* a revision ID has been assigned. This is for null edits.
 2493+ # Let the edit saving system know we should parse the page
 2494+ # *after* a revision ID has been assigned. This is for null edits.
24902495 $this->mOutput->setFlag( 'vary-revision' );
24912496 wfDebug( __METHOD__ . ": {{REVISIONDAY2}} used, setting vary-revision...\n" );
24922497 $value = substr( $this->getRevisionTimestamp(), 6, 2 );
24932498 break;
24942499 case 'revisionmonth':
2495 - // Let the edit saving system know we should parse the page
2496 - // *after* a revision ID has been assigned. This is for null edits.
 2500+ # Let the edit saving system know we should parse the page
 2501+ # *after* a revision ID has been assigned. This is for null edits.
24972502 $this->mOutput->setFlag( 'vary-revision' );
24982503 wfDebug( __METHOD__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n" );
24992504 $value = intval( substr( $this->getRevisionTimestamp(), 4, 2 ) );
25002505 break;
25012506 case 'revisionyear':
2502 - // Let the edit saving system know we should parse the page
2503 - // *after* a revision ID has been assigned. This is for null edits.
 2507+ # Let the edit saving system know we should parse the page
 2508+ # *after* a revision ID has been assigned. This is for null edits.
25042509 $this->mOutput->setFlag( 'vary-revision' );
25052510 wfDebug( __METHOD__ . ": {{REVISIONYEAR}} used, setting vary-revision...\n" );
25062511 $value = substr( $this->getRevisionTimestamp(), 0, 4 );
25072512 break;
25082513 case 'revisiontimestamp':
2509 - // Let the edit saving system know we should parse the page
2510 - // *after* a revision ID has been assigned. This is for null edits.
 2514+ # Let the edit saving system know we should parse the page
 2515+ # *after* a revision ID has been assigned. This is for null edits.
25112516 $this->mOutput->setFlag( 'vary-revision' );
25122517 wfDebug( __METHOD__ . ": {{REVISIONTIMESTAMP}} used, setting vary-revision...\n" );
25132518 $value = $this->getRevisionTimestamp();
25142519 break;
25152520 case 'revisionuser':
2516 - // Let the edit saving system know we should parse the page
2517 - // *after* a revision ID has been assigned. This is for null edits.
 2521+ # Let the edit saving system know we should parse the page
 2522+ # *after* a revision ID has been assigned. This is for null edits.
25182523 $this->mOutput->setFlag( 'vary-revision' );
25192524 wfDebug( __METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n" );
25202525 $value = $this->getRevisionUser();
@@ -2549,8 +2554,8 @@
25502555 $value = $wgContLang->formatNum( gmdate( 'H', $ts ), true );
25512556 break;
25522557 case 'currentweek':
2553 - // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
2554 - // int to remove the padding
 2558+ # @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
 2559+ # int to remove the padding
25552560 $value = $wgContLang->formatNum( (int)gmdate( 'W', $ts ) );
25562561 break;
25572562 case 'currentdow':
@@ -2569,8 +2574,8 @@
25702575 $value = $wgContLang->formatNum( $localHour, true );
25712576 break;
25722577 case 'localweek':
2573 - // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
2574 - // int to remove the padding
 2578+ # @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
 2579+ # int to remove the padding
25752580 $value = $wgContLang->formatNum( (int)$localWeek );
25762581 break;
25772582 case 'localdow':
@@ -2681,7 +2686,7 @@
26822687 return $dom;
26832688 }
26842689
2685 - /*
 2690+ /**
26862691 * Return a three-element array: leading whitespace, string contents, trailing whitespace
26872692 */
26882693 public static function splitWhitespace( $s ) {
@@ -2736,7 +2741,7 @@
27372742 return $text;
27382743 }
27392744
2740 - // Clean up argument array - refactored in 1.9 so parserfunctions can use it, too.
 2745+ # Clean up argument array - refactored in 1.9 so parserfunctions can use it, too.
27412746 static function createAssocArgs( $args ) {
27422747 $assocArgs = array();
27432748 $index = 1;
@@ -2777,7 +2782,7 @@
27782783 * exceeded, provide the values (optional)
27792784 */
27802785 function limitationWarn( $limitationType, $current=null, $max=null) {
2781 - // does no harm if $current and $max are present but are unnecessary for the message
 2786+ # does no harm if $current and $max are present but are unnecessary for the message
27822787 $warning = wfMsgExt( "$limitationType-warning", array( 'parsemag', 'escape' ), $current, $max );
27832788 $this->mOutput->addWarning( $warning );
27842789 $this->addTrackingCategory( "$limitationType-category" );
@@ -2940,8 +2945,8 @@
29412946 unset( $result[0] );
29422947 }
29432948
2944 - // Extract flags into the local scope
2945 - // This allows callers to set flags such as nowiki, found, etc.
 2949+ # Extract flags into the local scope
 2950+ # This allows callers to set flags such as nowiki, found, etc.
29462951 extract( $result );
29472952 } else {
29482953 $text = $result;
@@ -2998,7 +3003,7 @@
29993004 $this->disableCache();
30003005 }
30013006 } elseif ( $wgNonincludableNamespaces && in_array( $title->getNamespace(), $wgNonincludableNamespaces ) ) {
3002 - $found = false; // access denied
 3007+ $found = false; # access denied
30033008 wfDebug( __METHOD__.": template inclusion denied for " . $title->getPrefixedDBkey() );
30043009 } else {
30053010 list( $text, $title ) = $this->getTemplateDom( $title );
@@ -3014,13 +3019,13 @@
30153020 $found = true;
30163021 }
30173022 } elseif ( $title->isTrans() ) {
3018 - // Interwiki transclusion
 3023+ # Interwiki transclusion
30193024 if ( $this->ot['html'] && !$forceRawInterwiki ) {
30203025 $text = $this->interwikiTransclude( $title, 'render' );
30213026 $isHTML = true;
30223027 } else {
30233028 $text = $this->interwikiTransclude( $title, 'raw' );
3024 - // Preprocess it like a template
 3029+ # Preprocess it like a template
30253030 $text = $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION );
30263031 $isChildObj = true;
30273032 }
@@ -3122,7 +3127,7 @@
31233128 return array( $this->mTplDomCache[$titleText], $title );
31243129 }
31253130
3126 - // Cache miss, go to the database
 3131+ # Cache miss, go to the database
31273132 list( $text, $title ) = $this->fetchTemplateAndTitle( $title );
31283133
31293134 if ( $text === false ) {
@@ -3171,10 +3176,10 @@
31723177 $finalTitle = $title;
31733178 $deps = array();
31743179
3175 - // Loop to fetch the article, with up to 1 redirect
 3180+ # Loop to fetch the article, with up to 1 redirect
31763181 for ( $i = 0; $i < 2 && is_object( $title ); $i++ ) {
31773182 # Give extensions a chance to select the revision instead
3178 - $id = false; // Assume current
 3183+ $id = false; # Assume current
31793184 wfRunHooks( 'BeforeParserFetchTemplateAndtitle', array( $parser, &$title, &$skip, &$id ) );
31803185
31813186 if ( $skip ) {
@@ -3187,7 +3192,7 @@
31883193 }
31893194 $rev = $id ? Revision::newFromId( $id ) : Revision::newFromTitle( $title );
31903195 $rev_id = $rev ? $rev->getId() : 0;
3191 - // If there is no current revision, there is no page
 3196+ # If there is no current revision, there is no page
31923197 if ( $id === false && !$rev ) {
31933198 $linkCache = LinkCache::singleton();
31943199 $linkCache->addBadLinkObj( $title );
@@ -3214,7 +3219,7 @@
32153220 if ( $text === false ) {
32163221 break;
32173222 }
3218 - // Redirect?
 3223+ # Redirect?
32193224 $finalTitle = $title;
32203225 $title = Title::newFromRedirect( $text );
32213226 }
@@ -3366,7 +3371,7 @@
33673372 }
33683373
33693374 if ( is_array( $output ) ) {
3370 - // Extract flags to local scope (to override $markerType)
 3375+ # Extract flags to local scope (to override $markerType)
33713376 $flags = $output;
33723377 $output = $flags[0];
33733378 unset( $flags[0] );
@@ -3439,20 +3444,20 @@
34403445 function doDoubleUnderscore( $text ) {
34413446 wfProfileIn( __METHOD__ );
34423447
3443 - // The position of __TOC__ needs to be recorded
 3448+ # The position of __TOC__ needs to be recorded
34443449 $mw = MagicWord::get( 'toc' );
34453450 if ( $mw->match( $text ) ) {
34463451 $this->mShowToc = true;
34473452 $this->mForceTocPosition = true;
34483453
3449 - // Set a placeholder. At the end we'll fill it in with the TOC.
 3454+ # Set a placeholder. At the end we'll fill it in with the TOC.
34503455 $text = $mw->replace( '<!--MWTOC-->', $text, 1 );
34513456
3452 - // Only keep the first one.
 3457+ # Only keep the first one.
34533458 $text = $mw->replace( '', $text );
34543459 }
34553460
3456 - // Now match and remove the rest of them
 3461+ # Now match and remove the rest of them
34573462 $mwa = MagicWord::getDoubleUnderscoreArray();
34583463 $this->mDoubleUnderscores = $mwa->matchAndRemove( $text );
34593464
@@ -3528,7 +3533,7 @@
35293534 $doNumberHeadings = $this->mOptions->getNumberHeadings();
35303535 $showEditLink = $this->mOptions->getEditSection();
35313536
3532 - // Do not call quickUserCan unless necessary
 3537+ # Do not call quickUserCan unless necessary
35333538 if ( $showEditLink && !$this->mTitle->quickUserCan( 'edit' ) ) {
35343539 $showEditLink = 0;
35353540 }
@@ -3882,7 +3887,7 @@
38833888 foreach ( $tree1 as $s ) {
38843889 if ( $targetLevel !== false ) {
38853890 if ( $s['level'] <= $targetLevel ) {
3886 - // We've skipped enough
 3891+ # We've skipped enough
38873892 $targetLevel = false;
38883893 } else {
38893894 continue;
@@ -3893,7 +3898,7 @@
38943899 self::incrementNumbering( $numbering,
38953900 $s['toclevel'], $lastLevel );
38963901
3897 - // Rewrite index, byteoffset and number
 3902+ # Rewrite index, byteoffset and number
38983903 if ( $s['fromtitle'] == $titletext ) {
38993904 $s['index'] = $nextIndex++;
39003905 if ( $merged ) {
@@ -3906,11 +3911,11 @@
39073912 $lastLevel = $s['toclevel'];
39083913 $newTree[] = $s;
39093914 } else {
3910 - // We're at $section
3911 - // Insert sections from $tree2 here
 3915+ # We're at $section
 3916+ # Insert sections from $tree2 here
39123917 foreach ( $tree2 as $s2 ) {
3913 - // Rewrite the fields in $s2
3914 - // before inserting it
 3918+ # Rewrite the fields in $s2
 3919+ # before inserting it
39153920 $s2['toclevel'] += $s['toclevel'] - 1;
39163921 $s2['level'] += $s['level'] - 1;
39173922 $s2['index'] = $nextIndex++;
@@ -3924,7 +3929,7 @@
39253930 $lastLevel = $s2['toclevel'];
39263931 $newTree[] = $s2;
39273932 }
3928 - // Skip all descendants of $section in $tree1
 3933+ # Skip all descendants of $section in $tree1
39293934 $targetLevel = $s['level'];
39303935 $merged = true;
39313936 }
@@ -4078,7 +4083,7 @@
40794084
40804085 $username = $user->getName();
40814086
4082 - // If not given, retrieve from the user object.
 4087+ # If not given, retrieve from the user object.
40834088 if ( $nickname === false )
40844089 $nickname = $user->getOption( 'nickname' );
40854090
@@ -4103,7 +4108,7 @@
41044109 }
41054110 }
41064111
4107 - // Make sure nickname doesnt get a sig in a sig
 4112+ # Make sure nickname doesnt get a sig in a sig
41084113 $nickname = $this->cleanSigInSig( $nickname );
41094114
41104115 # If we're still here, make it a link to the user page
@@ -4441,7 +4446,7 @@
44424447 if ( strpos( $matches[0], '%' ) !== false ) {
44434448 $matches[1] = urldecode( $matches[1] );
44444449 }
4445 - $tp = Title::newFromText( $matches[1]/*, NS_FILE*/ );
 4450+ $tp = Title::newFromText( $matches[1] );
44464451 $nt =& $tp;
44474452 if ( is_null( $nt ) ) {
44484453 # Bogus title. Ignore these so we don't bomb out later.
@@ -4472,7 +4477,7 @@
44734478 $handlerClass = '';
44744479 }
44754480 if ( !isset( $this->mImageParams[$handlerClass] ) ) {
4476 - // Initialise static lists
 4481+ # Initialise static lists
44774482 static $internalParamNames = array(
44784483 'horizAlign' => array( 'left', 'right', 'center', 'none' ),
44794484 'vertAlign' => array( 'baseline', 'sub', 'super', 'top', 'text-top', 'middle',
@@ -4491,7 +4496,7 @@
44924497 }
44934498 }
44944499
4495 - // Add handler params
 4500+ # Add handler params
44964501 $paramMap = $internalParamMap;
44974502 if ( $handler ) {
44984503 $handlerParamMap = $handler->getParamMap();
@@ -4567,7 +4572,7 @@
45684573 if ( isset( $paramMap[$magicName] ) ) {
45694574 list( $type, $paramName ) = $paramMap[$magicName];
45704575
4571 - // Special case; width and height come in one variable together
 4576+ # Special case; width and height come in one variable together
45724577 if ( $type === 'handler' && $paramName === 'width' ) {
45734578 $m = array();
45744579 # (bug 13500) In both cases (width/height and width only),
@@ -4589,7 +4594,7 @@
45904595 $params[$type]['width'] = $width;
45914596 $validated = true;
45924597 }
4593 - } // else no validation -- bug 13436
 4598+ } # else no validation -- bug 13436
45944599 } else {
45954600 if ( $type === 'handler' ) {
45964601 # Validate handler parameter
@@ -4599,9 +4604,9 @@
46004605 switch( $paramName ) {
46014606 case 'manualthumb':
46024607 case 'alt':
4603 - // @todo Fixme: possibly check validity here for
4604 - // manualthumb? downstream behavior seems odd with
4605 - // missing manual thumbs.
 4608+ # @todo Fixme: possibly check validity here for
 4609+ # manualthumb? downstream behavior seems odd with
 4610+ # missing manual thumbs.
46064611 $validated = true;
46074612 $value = $this->stripAltText( $value, $holders );
46084613 break;
@@ -4629,7 +4634,7 @@
46304635 }
46314636 break;
46324637 default:
4633 - // Most other things appear to be empty or numeric...
 4638+ # Most other things appear to be empty or numeric...
46344639 $validated = ( $value === false || is_numeric( trim( $value ) ) );
46354640 }
46364641 }
@@ -4801,13 +4806,13 @@
48024807 private function extractSections( $text, $section, $mode, $newText='' ) {
48034808 global $wgTitle;
48044809 $this->clearState();
4805 - $this->setTitle( $wgTitle ); // not generally used but removes an ugly failure mode
 4810+ $this->setTitle( $wgTitle ); # not generally used but removes an ugly failure mode
48064811 $this->mOptions = new ParserOptions;
48074812 $this->setOutputType( self::OT_PLAIN );
48084813 $outText = '';
48094814 $frame = $this->getPreprocessor()->newFrame();
48104815
4811 - // Process section extraction flags
 4816+ # Process section extraction flags
48124817 $flags = 0;
48134818 $sectionParts = explode( '-', $section );
48144819 $sectionIndex = array_pop( $sectionParts );
@@ -4816,16 +4821,16 @@
48174822 $flags |= self::PTD_FOR_INCLUSION;
48184823 }
48194824 }
4820 - // Preprocess the text
 4825+ # Preprocess the text
48214826 $root = $this->preprocessToDom( $text, $flags );
48224827
4823 - // <h> nodes indicate section breaks
4824 - // They can only occur at the top level, so we can find them by iterating the root's children
 4828+ # <h> nodes indicate section breaks
 4829+ # They can only occur at the top level, so we can find them by iterating the root's children
48254830 $node = $root->getFirstChild();
48264831
4827 - // Find the target section
 4832+ # Find the target section
48284833 if ( $sectionIndex == 0 ) {
4829 - // Section zero doesn't nest, level=big
 4834+ # Section zero doesn't nest, level=big
48304835 $targetLevel = 1000;
48314836 } else {
48324837 while ( $node ) {
@@ -4844,7 +4849,7 @@
48454850 }
48464851
48474852 if ( !$node ) {
4848 - // Not found
 4853+ # Not found
48494854 if ( $mode === 'get' ) {
48504855 return $newText;
48514856 } else {
@@ -4852,7 +4857,7 @@
48534858 }
48544859 }
48554860
4856 - // Find the end of the section, including nested sections
 4861+ # Find the end of the section, including nested sections
48574862 do {
48584863 if ( $node->getName() === 'h' ) {
48594864 $bits = $node->splitHeading();
@@ -4867,12 +4872,12 @@
48684873 $node = $node->getNextSibling();
48694874 } while ( $node );
48704875
4871 - // Write out the remainder (in replace mode only)
 4876+ # Write out the remainder (in replace mode only)
48724877 if ( $mode === 'replace' ) {
4873 - // Output the replacement text
4874 - // Add two newlines on -- trailing whitespace in $newText is conventionally
4875 - // stripped by the editor, so we need both newlines to restore the paragraph gap
4876 - // Only add trailing whitespace if there is newText
 4878+ # Output the replacement text
 4879+ # Add two newlines on -- trailing whitespace in $newText is conventionally
 4880+ # stripped by the editor, so we need both newlines to restore the paragraph gap
 4881+ # Only add trailing whitespace if there is newText
48774882 if ( $newText != "" ) {
48784883 $outText .= $newText . "\n\n";
48794884 }
@@ -4884,7 +4889,7 @@
48854890 }
48864891
48874892 if ( is_string( $outText ) ) {
4888 - // Re-insert stripped tags
 4893+ # Re-insert stripped tags
48894894 $outText = rtrim( $this->mStripState->unstripBoth( $outText ) );
48904895 }
48914896
@@ -4923,18 +4928,18 @@
49244929 $timestamp = $dbr->selectField( 'revision', 'rev_timestamp',
49254930 array( 'rev_id' => $this->mRevisionId ), __METHOD__ );
49264931
4927 - // Normalize timestamp to internal MW format for timezone processing.
4928 - // This has the added side-effect of replacing a null value with
4929 - // the current time, which gives us more sensible behavior for
4930 - // previews.
 4932+ # Normalize timestamp to internal MW format for timezone processing.
 4933+ # This has the added side-effect of replacing a null value with
 4934+ # the current time, which gives us more sensible behavior for
 4935+ # previews.
49314936 $timestamp = wfTimestamp( TS_MW, $timestamp );
49324937
4933 - // The cryptic '' timezone parameter tells to use the site-default
4934 - // timezone offset instead of the user settings.
4935 - //
4936 - // Since this value will be saved into the parser cache, served
4937 - // to other users, and potentially even used inside links and such,
4938 - // it needs to be consistent for all visitors.
 4938+ # The cryptic '' timezone parameter tells to use the site-default
 4939+ # timezone offset instead of the user settings.
 4940+ #
 4941+ # Since this value will be saved into the parser cache, served
 4942+ # to other users, and potentially even used inside links and such,
 4943+ # it needs to be consistent for all visitors.
49394944 $this->mRevisionTimestamp = $wgContLang->userAdjust( $timestamp, '' );
49404945
49414946 wfProfileOut( __METHOD__ );
@@ -4946,8 +4951,8 @@
49474952 * Get the name of the user that edited the last revision
49484953 */
49494954 function getRevisionUser() {
4950 - // if this template is subst: the revision id will be blank,
4951 - // so just use the current user's name
 4955+ # if this template is subst: the revision id will be blank,
 4956+ # so just use the current user's name
49524957 if ( $this->mRevisionId ) {
49534958 $revision = Revision::newFromId( $this->mRevisionId );
49544959 $revuser = $revision->getUserText();
@@ -5115,8 +5120,8 @@
51165121 $data = array();
51175122 $data['text'] = $text;
51185123
5119 - // First, find all strip markers, and store their
5120 - // data in an array.
 5124+ # First, find all strip markers, and store their
 5125+ # data in an array.
51215126 $stripState = new StripState;
51225127 $pos = 0;
51235128 while ( ( $start_pos = strpos( $text, $this->mUniqPrefix, $pos ) )
@@ -5140,12 +5145,12 @@
51415146 }
51425147 $data['stripstate'] = $stripState;
51435148
5144 - // Now, find all of our links, and store THEIR
5145 - // data in an array! :)
 5149+ # Now, find all of our links, and store THEIR
 5150+ # data in an array! :)
51465151 $links = array( 'internal' => array(), 'interwiki' => array() );
51475152 $pos = 0;
51485153
5149 - // Internal links
 5154+ # Internal links
51505155 while ( ( $start_pos = strpos( $text, '<!--LINK ', $pos ) ) ) {
51515156 list( $ns, $trail ) = explode( ':', substr( $text, $start_pos + strlen( '<!--LINK ' ) ), 2 );
51525157
@@ -5161,7 +5166,7 @@
51625167
51635168 $pos = 0;
51645169
5165 - // Interwiki links
 5170+ # Interwiki links
51665171 while ( ( $start_pos = strpos( $text, '<!--IWLINK ', $pos ) ) ) {
51675172 $data = substr( $text, $start_pos );
51685173 $key = trim( substr( $data, 0, strpos( $data, '-->' ) ) );
@@ -5174,21 +5179,27 @@
51755180 return $data;
51765181 }
51775182
5178 - function unserialiseHalfParsedText( $data, $intPrefix = null /* Unique identifying prefix */ ) {
 5183+ /**
 5184+ * TODO: document
 5185+ * @param $data Array
 5186+ * @param $intPrefix String unique identifying prefix
 5187+ * @return String
 5188+ */
 5189+ function unserialiseHalfParsedText( $data, $intPrefix = null ) {
51795190 if ( !$intPrefix ) {
51805191 $intPrefix = $this->getRandomString();
51815192 }
51825193
5183 - // First, extract the strip state.
 5194+ # First, extract the strip state.
51845195 $stripState = $data['stripstate'];
51855196 $this->mStripState->general->merge( $stripState->general );
51865197 $this->mStripState->nowiki->merge( $stripState->nowiki );
51875198
5188 - // Now, extract the text, and renumber links
 5199+ # Now, extract the text, and renumber links
51895200 $text = $data['text'];
51905201 $links = $data['linkholder'];
51915202
5192 - // Internal...
 5203+ # Internal...
51935204 foreach ( $links['internal'] as $ns => $nsLinks ) {
51945205 foreach ( $nsLinks as $key => $entry ) {
51955206 $newKey = $intPrefix . '-' . $key;
@@ -5198,7 +5209,7 @@
51995210 }
52005211 }
52015212
5202 - // Interwiki...
 5213+ # Interwiki...
52035214 foreach ( $links['interwiki'] as $key => $entry ) {
52045215 $newKey = "$intPrefix-$key";
52055216 $this->mLinkHolders->interwikis[$newKey] = $entry;
@@ -5206,7 +5217,7 @@
52075218 $text = str_replace( "<!--IWLINK $key-->", "<!--IWLINK $newKey-->", $text );
52085219 }
52095220
5210 - // Should be good to go.
 5221+ # Should be good to go.
52115222 return $text;
52125223 }
52135224 }

Comments

#Comment by Platonides (talk | contribs)   21:09, 17 October 2010

Yeah, pretty borked.

Status & tagging log