r32486 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32485‎ | r32486 | r32487 >
Date:00:00, 27 March 2008
Author:brion
Status:old
Tags:
Comment:
* (bug 13522) Fix fatal error in Parser::extractTagsAndParams
Patch by MinuteElectron - https://bugzilla.wikimedia.org/attachment.cgi?id=4772 with fixes
Replaces an instance variable with a constant, since it doesn't change, which is safe to access when the function is called statically from an outside class, as some extensions do.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/includes/Preprocessor_DOM.php (modified) (history)
  • /trunk/phase3/includes/Preprocessor_Hash.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Preprocessor_DOM.php
@@ -979,7 +979,7 @@
980980 $titleText = $this->title->getPrefixedDBkey();
981981 $this->parser->mHeadings[] = array( $titleText, $headingIndex );
982982 $serial = count( $this->parser->mHeadings ) - 1;
983 - $marker = "{$this->parser->mUniqPrefix}-h-$serial-{$this->parser->mMarkerSuffix}";
 983+ $marker = "{$this->parser->mUniqPrefix}-h-$serial-" . Parser::MARKER_SUFFIX;
984984 $count = $contextNode->getAttribute( 'level' );
985985 $s = substr( $s, 0, $count ) . $marker . substr( $s, $count );
986986 $this->parser->mStripState->general->setPair( $marker, '' );
Index: trunk/phase3/includes/Parser.php
@@ -82,14 +82,17 @@
8383 const OT_WIKI = 2;
8484 const OT_PREPROCESS = 3;
8585 const OT_MSG = 3;
86 -
 86+
 87+ // Marker Suffix needs to be accessible staticly.
 88+ const MARKER_SUFFIX = "-QINU\x7f";
 89+
8790 /**#@+
8891 * @private
8992 */
9093 # Persistent:
9194 var $mTagHooks, $mTransparentTagHooks, $mFunctionHooks, $mFunctionSynonyms, $mVariables,
92 - $mImageParams, $mImageParamsMagicArray, $mStripList, $mMarkerSuffix, $mMarkerIndex,
93 - $mExtLinkBracketedRegex, $mPreprocessor, $mDefaultStripList, $mVarCache, $mConf;
 95+ $mImageParams, $mImageParamsMagicArray, $mStripList, $mMarkerIndex, $mPreprocessor,
 96+ $mExtLinkBracketedRegex, $mDefaultStripList, $mVarCache, $mConf;
9497
9598
9699 # Cleared with clearState():
@@ -124,7 +127,6 @@
125128 $this->mFunctionHooks = array();
126129 $this->mFunctionSynonyms = array( 0 => array(), 1 => array() );
127130 $this->mDefaultStripList = $this->mStripList = array( 'nowiki', 'gallery' );
128 - $this->mMarkerSuffix = "-QINU\x7f";
129131 $this->mExtLinkBracketedRegex = '/\[(\b(' . wfUrlProtocols() . ')'.
130132 '[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x0a\\x0d]*?)\]/S';
131133 $this->mVarCache = array();
@@ -526,7 +528,7 @@
527529 $inside = $p[4];
528530 }
529531
530 - $marker = "$uniq_prefix-$element-" . sprintf('%08X', $n++) . $this->mMarkerSuffix;
 532+ $marker = "$uniq_prefix-$element-" . sprintf('%08X', $n++) . self::MARKER_SUFFIX;
531533 $stripped .= $marker;
532534
533535 if ( $close === '/>' ) {
@@ -618,7 +620,7 @@
619621 * @private
620622 */
621623 function insertStripItem( $text ) {
622 - $rnd = "{$this->mUniqPrefix}-item-{$this->mMarkerIndex}-{$this->mMarkerSuffix}";
 624+ $rnd = "{$this->mUniqPrefix}-item-{$this->mMarkerIndex}-" . self::MARKER_SUFFIX;
623625 $this->mMarkerIndex++;
624626 $this->mStripState->general->setPair( $rnd, $text );
625627 return $rnd;
@@ -3185,7 +3187,7 @@
31863188 $attrText = !isset( $params['attr'] ) ? null : $frame->expand( $params['attr'] );
31873189 $content = !isset( $params['inner'] ) ? null : $frame->expand( $params['inner'] );
31883190
3189 - $marker = "{$this->mUniqPrefix}-$name-" . sprintf('%08X', $this->mMarkerIndex++) . $this->mMarkerSuffix;
 3191+ $marker = "{$this->mUniqPrefix}-$name-" . sprintf('%08X', $this->mMarkerIndex++) . self::MARKER_SUFFIX;
31903192
31913193 if ( $this->ot['html'] ) {
31923194 $name = strtolower( $name );
@@ -3378,7 +3380,7 @@
33793381 $prevlevel = 0;
33803382 $toclevel = 0;
33813383 $prevtoclevel = 0;
3382 - $markerRegex = "{$this->mUniqPrefix}-h-(\d+)-{$this->mMarkerSuffix}";
 3384+ $markerRegex = "{$this->mUniqPrefix}-h-(\d+)-" . self::MARKER_SUFFIX;
33833385 $baseTitleText = $this->mTitle->getPrefixedDBkey();
33843386 $tocraw = array();
33853387
@@ -4822,12 +4824,12 @@
48234825 break;
48244826 } else {
48254827 $out .= call_user_func( $callback, substr( $s, $i, $markerStart - $i ) );
4826 - $markerEnd = strpos( $s, $this->mMarkerSuffix, $markerStart );
 4828+ $markerEnd = strpos( $s, self::MARKER_SUFFIX, $markerStart );
48274829 if ( $markerEnd === false ) {
48284830 $out .= substr( $s, $markerStart );
48294831 break;
48304832 } else {
4831 - $markerEnd += strlen( $this->mMarkerSuffix );
 4833+ $markerEnd += strlen( self::MARKER_SUFFIX );
48324834 $out .= substr( $s, $markerStart, $markerEnd - $markerStart );
48334835 $i = $markerEnd;
48344836 }
Index: trunk/phase3/includes/Preprocessor_Hash.php
@@ -928,7 +928,7 @@
929929 $titleText = $this->title->getPrefixedDBkey();
930930 $this->parser->mHeadings[] = array( $titleText, $bits['i'] );
931931 $serial = count( $this->parser->mHeadings ) - 1;
932 - $marker = "{$this->parser->mUniqPrefix}-h-$serial-{$this->parser->mMarkerSuffix}";
 932+ $marker = "{$this->parser->mUniqPrefix}-h-$serial-" . Parser::MARKER_SUFFIX;
933933 $s = substr( $s, 0, $bits['level'] ) . $marker . substr( $s, $bits['level'] );
934934 $this->parser->mStripState->general->setPair( $marker, '' );
935935 $out .= $s;
Index: trunk/phase3/RELEASE-NOTES
@@ -136,6 +136,7 @@
137137 * Trackback display formatting fixed
138138 * Don't die when single-element arrays are passed to SQL query constructors
139139 that have an array index other than 0
 140+* (bug 13522) Fix fatal error in Parser::extractTagsAndParams
140141
141142
142143 === API changes in 1.13 ===

Follow-up revisions

RevisionCommit summaryAuthorDate
r32487* (bug 13522) Fix fatal error in Parser::extractTagsAndParamsbrion00:02, 27 March 2008

Status & tagging log