From 33f4112a4b9b8c2fa8f5ab6e5e7e54fca91f054f Mon Sep 17 00:00:00 2001 From: Kevin Israel Date: Thu, 21 Jul 2016 08:51:39 -0400 Subject: [PATCH] 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 --- includes/tidy/RaggettWrapper.php | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) 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; } -- 2.20.1