r66462 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66461‎ | r66462 | r66463 >
Date:10:35, 15 May 2010
Author:ashley
Status:ok (Comments)
Tags:
Comment:
Parser.php: trim trailing spaces
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -516,7 +516,7 @@
517517 /**
518518 * Process the wikitext for the ?preload= feature. (bug 5210)
519519 *
520 - * <noinclude>, <includeonly> etc. are parsed as for template transclusion,
 520+ * <noinclude>, <includeonly> etc. are parsed as for template transclusion,
521521 * comments, templates, arguments, tags hooks and parser functions are untouched.
522522 */
523523 public function getPreloadText( $text, $title, $options ) {
@@ -524,7 +524,7 @@
525525 $this->clearState();
526526 $this->setOutputType( self::OT_PLAIN );
527527 $this->mOptions = $options;
528 - $this->setTitle( $title );
 528+ $this->setTitle( $title );
529529
530530 $flags = PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES;
531531 $dom = $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION );
@@ -1163,12 +1163,12 @@
11641164 }
11651165 # Count the number of occurrences of bold and italics mark-ups.
11661166 # We are not counting sequences of five apostrophes.
1167 - if ( strlen( $arr[$i] ) == 2 ) {
 1167+ if ( strlen( $arr[$i] ) == 2 ) {
11681168 $numitalics++;
1169 - } elseif ( strlen( $arr[$i] ) == 3 ) {
 1169+ } elseif ( strlen( $arr[$i] ) == 3 ) {
11701170 $numbold++;
1171 - } elseif ( strlen( $arr[$i] ) == 5 ) {
1172 - $numitalics++;
 1171+ } elseif ( strlen( $arr[$i] ) == 5 ) {
 1172+ $numitalics++;
11731173 $numbold++;
11741174 }
11751175 }
@@ -1193,7 +1193,7 @@
11941194 $firstspace = $i;
11951195 }
11961196 } elseif ( $x2 === ' ') {
1197 - if ( $firstsingleletterword == -1 ) {
 1197+ if ( $firstsingleletterword == -1 ) {
11981198 $firstsingleletterword = $i;
11991199 }
12001200 } else {
@@ -1613,10 +1613,10 @@
16141614 # [[Image:Foo.jpg|[http://example.com desc]]] <- having three ] in a row fucks up,
16151615 # the real problem is with the $e1 regex
16161616 # See bug 1300.
1617 - #
 1617+ #
16181618 # Still some problems for cases where the ] is meant to be outside punctuation,
16191619 # and no image is in sight. See bug 2095.
1620 - #
 1620+ #
16211621 if ( $text !== '' &&
16221622 substr( $m[3], 0, 1 ) === ']' &&
16231623 strpos( $text, '[' ) !== false
@@ -1827,7 +1827,7 @@
18281828 wfProfileIn( __METHOD__."-always_known" );
18291829 # Some titles, such as valid special pages or files in foreign repos, should
18301830 # be shown as bluelinks even though they're not included in the page table
1831 - #
 1831+ #
18321832 # FIXME: isAlwaysKnown() can be expensive for file links; we should really do
18331833 # batch file existence checks for NS_FILE and NS_MEDIA
18341834 if ( $iw == '' && $nt->isAlwaysKnown() ) {
@@ -1928,18 +1928,18 @@
19291929 /**
19301930 * getCommon() returns the length of the longest common substring
19311931 * of both arguments, starting at the beginning of both.
1932 - * @private
1933 - */
 1932+ * @private
 1933+ */
19341934 function getCommon( $st1, $st2 ) {
19351935 $fl = strlen( $st1 );
19361936 $shorter = strlen( $st2 );
1937 - if ( $fl < $shorter ) {
1938 - $shorter = $fl;
 1937+ if ( $fl < $shorter ) {
 1938+ $shorter = $fl;
19391939 }
19401940
19411941 for ( $i = 0; $i < $shorter; ++$i ) {
1942 - if ( $st1{$i} != $st2{$i} ) {
1943 - break;
 1942+ if ( $st1{$i} != $st2{$i} ) {
 1943+ break;
19441944 }
19451945 }
19461946 return $i;
@@ -1947,22 +1947,22 @@
19481948 /**
19491949 * These next three functions open, continue, and close the list
19501950 * element appropriate to the prefix character passed into them.
1951 - * @private
 1951+ * @private
19521952 */
19531953 function openList( $char ) {
19541954 $result = $this->closeParagraph();
19551955
1956 - if ( '*' === $char ) {
1957 - $result .= '<ul><li>';
1958 - } elseif ( '#' === $char ) {
1959 - $result .= '<ol><li>';
1960 - } elseif ( ':' === $char ) {
1961 - $result .= '<dl><dd>';
 1956+ if ( '*' === $char ) {
 1957+ $result .= '<ul><li>';
 1958+ } elseif ( '#' === $char ) {
 1959+ $result .= '<ol><li>';
 1960+ } elseif ( ':' === $char ) {
 1961+ $result .= '<dl><dd>';
19621962 } elseif ( ';' === $char ) {
19631963 $result .= '<dl><dt>';
19641964 $this->mDTopen = true;
1965 - } else {
1966 - $result = '<!-- ERR 1 -->';
 1965+ } else {
 1966+ $result = '<!-- ERR 1 -->';
19671967 }
19681968
19691969 return $result;
@@ -1974,12 +1974,12 @@
19751975 * @private
19761976 */
19771977 function nextItem( $char ) {
1978 - if ( '*' === $char || '#' === $char ) {
1979 - return '</li><li>';
 1978+ if ( '*' === $char || '#' === $char ) {
 1979+ return '</li><li>';
19801980 } elseif ( ':' === $char || ';' === $char ) {
19811981 $close = '</dd>';
1982 - if ( $this->mDTopen ) {
1983 - $close = '</dt>';
 1982+ if ( $this->mDTopen ) {
 1983+ $close = '</dt>';
19841984 }
19851985 if ( ';' === $char ) {
19861986 $this->mDTopen = true;
@@ -1998,10 +1998,10 @@
19991999 * @private
20002000 */
20012001 function closeList( $char ) {
2002 - if ( '*' === $char ) {
2003 - $text = '</li></ul>';
2004 - } elseif ( '#' === $char ) {
2005 - $text = '</li></ol>';
 2002+ if ( '*' === $char ) {
 2003+ $text = '</li></ul>';
 2004+ } elseif ( '#' === $char ) {
 2005+ $text = '</li></ol>';
20062006 } elseif ( ':' === $char ) {
20072007 if ( $this->mDTopen ) {
20082008 $this->mDTopen = false;
@@ -2009,8 +2009,8 @@
20102010 } else {
20112011 $text = '</dd></dl>';
20122012 }
2013 - } else {
2014 - return '<!-- ERR 3 -->';
 2013+ } else {
 2014+ return '<!-- ERR 3 -->';
20152015 }
20162016 return $text."\n";
20172017 }
@@ -2029,7 +2029,7 @@
20302030 # Parsing through the text line by line. The main thing
20312031 # happening here is handling of block-level elements p, pre,
20322032 # and making lists from lines starting with * # : etc.
2033 - #
 2033+ #
20342034 $textLines = StringUtils::explode( "\n", $text );
20352035
20362036 $lastPrefix = $output = '';
@@ -2680,7 +2680,7 @@
26812681 }
26822682
26832683 /**
2684 - * initialise the magic variables (like CURRENTMONTHNAME) and substitution modifiers
 2684+ * initialise the magic variables (like CURRENTMONTHNAME) and substitution modifiers
26852685 *
26862686 * @private
26872687 */
@@ -2804,14 +2804,14 @@
28052805 * Will warn at most once the user per limitation type
28062806 *
28072807 * @param string $limitationType, should be one of:
2808 - * 'expensive-parserfunction' (corresponding messages:
2809 - * 'expensive-parserfunction-warning',
 2808+ * 'expensive-parserfunction' (corresponding messages:
 2809+ * 'expensive-parserfunction-warning',
28102810 * 'expensive-parserfunction-category')
2811 - * 'post-expand-template-argument' (corresponding messages:
2812 - * 'post-expand-template-argument-warning',
 2811+ * 'post-expand-template-argument' (corresponding messages:
 2812+ * 'post-expand-template-argument-warning',
28132813 * 'post-expand-template-argument-category')
2814 - * 'post-expand-template-inclusion' (corresponding messages:
2815 - * 'post-expand-template-inclusion-warning',
 2814+ * 'post-expand-template-inclusion' (corresponding messages:
 2815+ * 'post-expand-template-inclusion-warning',
28162816 * 'post-expand-template-inclusion-category')
28172817 * @params int $current, $max When an explicit limit has been
28182818 * exceeded, provide the values (optional)
@@ -3016,8 +3016,8 @@
30173017 $limit = $this->mOptions->getMaxTemplateDepth();
30183018 if ( $frame->depth >= $limit ) {
30193019 $found = true;
3020 - $text = '<span class="error">'
3021 - . wfMsgForContent( 'parser-template-recursion-depth-warning', $limit )
 3020+ $text = '<span class="error">'
 3021+ . wfMsgForContent( 'parser-template-recursion-depth-warning', $limit )
30223022 . '</span>';
30233023 }
30243024 }
@@ -3027,9 +3027,9 @@
30283028 if ( !$found && $title ) {
30293029 wfProfileIn( __METHOD__ . '-loadtpl' );
30303030 if ( !$title->isExternal() ) {
3031 - if ( $title->getNamespace() == NS_SPECIAL
3032 - && $this->mOptions->getAllowSpecialInclusion()
3033 - && $this->ot['html'] )
 3031+ if ( $title->getNamespace() == NS_SPECIAL
 3032+ && $this->mOptions->getAllowSpecialInclusion()
 3033+ && $this->ot['html'] )
30343034 {
30353035 $text = SpecialPage::capturePath( $title );
30363036 if ( is_string( $text ) ) {
@@ -3119,7 +3119,7 @@
31203120 # Escape nowiki-style return values
31213121 $text = wfEscapeWikiText( $text );
31223122 } elseif ( is_string( $text )
3123 - && !$piece['lineStart']
 3123+ && !$piece['lineStart']
31243124 && preg_match( '/^(?:{\\||:|;|#|\*)/', $text ) )
31253125 {
31263126 # Bug 529: if the template begins with a table or block-level
@@ -3507,7 +3507,7 @@
35083508 $this->addTrackingCategory( 'hidden-category-category' );
35093509 }
35103510 # (bug 8068) Allow control over whether robots index a page.
3511 - #
 3511+ #
35123512 # FIXME (bug 14899): __INDEX__ always overrides __NOINDEX__ here! This
35133513 # is not desirable, the last one on the page should win.
35143514 if ( isset( $this->mDoubleUnderscores['noindex'] ) && $this->mTitle->canUseNoindex() ) {
@@ -3741,7 +3741,7 @@
37423742 if ( $wgHtml5 && $wgExperimentalHtmlIds ) {
37433743 # For reverse compatibility, provide an id that's
37443744 # HTML4-compatible, like we used to.
3745 - #
 3745+ #
37463746 # It may be worth noting, academically, that it's possible for
37473747 # the legacy anchor to conflict with a non-legacy headline
37483748 # anchor on the page. In this case likely the "correct" thing
@@ -4704,13 +4704,13 @@
47054705 # came to also set the caption, ordinary text after the image -- which
47064706 # makes no sense, because that just repeats the text multiple times in
47074707 # screen readers. It *also* came to set the title attribute.
4708 - #
 4708+ #
47094709 # Now that we have an alt attribute, we should not set the alt text to
47104710 # equal the caption: that's worse than useless, it just repeats the
47114711 # text. This is the framed/thumbnail case. If there's no caption, we
47124712 # use the unnamed parameter for alt text as well, just for the time be-
47134713 # ing, if the unnamed param is set and the alt param is not.
4714 - #
 4714+ #
47154715 # For the future, we need to figure out if we want to tweak this more,
47164716 # e.g., introducing a title= parameter for the title; ignoring the un-
47174717 # named parameter entirely for images without a caption; adding an ex-
@@ -4807,8 +4807,8 @@
48084808 /**#@+
48094809 * Accessor
48104810 */
4811 - function getTags() {
4812 - return array_merge( array_keys( $this->mTransparentTagHooks ), array_keys( $this->mTagHooks ) );
 4811+ function getTags() {
 4812+ return array_merge( array_keys( $this->mTransparentTagHooks ), array_keys( $this->mTagHooks ) );
48134813 }
48144814 /**#@-*/
48154815
@@ -4971,7 +4971,7 @@
49724972
49734973 # The cryptic '' timezone parameter tells to use the site-default
49744974 # timezone offset instead of the user settings.
4975 - #
 4975+ #
49764976 # Since this value will be saved into the parser cache, served
49774977 # to other users, and potentially even used inside links and such,
49784978 # it needs to be consistent for all visitors.
@@ -5018,7 +5018,7 @@
50195019 if ( $this->mDefaultSort !== false ) {
50205020 return $this->mDefaultSort;
50215021 } elseif ( $this->mTitle->getNamespace() == NS_CATEGORY ||
5022 - !$wgCategoryPrefixedDefaultSortkey )
 5022+ !$wgCategoryPrefixedDefaultSortkey )
50235023 {
50245024 return $this->mTitle->getText();
50255025 } else {
@@ -5159,8 +5159,8 @@
51605160 # data in an array.
51615161 $stripState = new StripState;
51625162 $pos = 0;
5163 - while ( ( $start_pos = strpos( $text, $this->mUniqPrefix, $pos ) )
5164 - && ( $end_pos = strpos( $text, self::MARKER_SUFFIX, $pos ) ) )
 5163+ while ( ( $start_pos = strpos( $text, $this->mUniqPrefix, $pos ) )
 5164+ && ( $end_pos = strpos( $text, self::MARKER_SUFFIX, $pos ) ) )
51655165 {
51665166 $end_pos += strlen( self::MARKER_SUFFIX );
51675167 $marker = substr( $text, $start_pos, $end_pos-$start_pos );

Comments

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

Ok, this trims trailing whitespaces in the php file, it's not the parser trailing anything :)

Status & tagging log