From: Kevin Israel Date: Thu, 21 Jul 2016 12:51:39 +0000 (-0400) Subject: RaggettWrapper: Don't use ReplacementArray X-Git-Tag: 1.31.0-rc.0~4429^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=33f4112a4b9b8c2fa8f5ab6e5e7e54fca91f054f;p=lhc%2Fweb%2Fwiklou.git RaggettWrapper: Don't use ReplacementArray Instead, build the array and call strtr() directly. Also did some other minor cleanup, such as making replaceCallback() private now that we require at least PHP 5.5, and changing &$this to $this. Change-Id: If885df06710c76fdb35d3c7de78df7436ccb7abf --- diff --git a/includes/tidy/RaggettWrapper.php b/includes/tidy/RaggettWrapper.php index 56d5ce76fd..9f6feb8e55 100644 --- a/includes/tidy/RaggettWrapper.php +++ b/includes/tidy/RaggettWrapper.php @@ -1,7 +1,6 @@ mTokens = null; - } - /** * @param string $text * @return string */ public function getWrapped( $text ) { - $this->mTokens = new ReplacementArray; + $this->mTokens = []; $this->mMarkerIndex = 0; // Replace elements with placeholders $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX, - [ &$this, 'replaceCallback' ], $text ); + [ $this, 'replaceCallback' ], $text ); // ...and markers $wrappedtext = preg_replace_callback( '/\<\\/?mw:toc\>/', - [ &$this, 'replaceCallback' ], $wrappedtext ); + [ $this, 'replaceCallback' ], $wrappedtext ); // ... and tags $wrappedtext = preg_replace_callback( '/\/s', - [ &$this, 'replaceCallback' ], $wrappedtext ); + [ $this, 'replaceCallback' ], $wrappedtext ); // Modify inline Microdata and elements so they say and so // we can trick Tidy into not stripping them out by including them in tidy's new-empty-tags config $wrappedtext = preg_replace( '!<(link|meta)([^>]*?)(/{0,1}>)!', 'mMarkerIndex}" . Parser::MARKER_SUFFIX; $this->mMarkerIndex++; - $this->mTokens->setPair( $marker, $m[0] ); + $this->mTokens[$marker] = $m[0]; return $marker; } @@ -88,7 +85,7 @@ class RaggettWrapper { $text = str_replace( '
  • mTokens->replace( $text ); + $text = strtr( $text, $this->mTokens ); return $text; }