X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FHtmlFormatter.php;h=b2209c358ed3636f68817015f2b2c907f1bf61e2;hb=f0ece08caf99376db8eb089073acbc6e4c29f9c5;hp=83d0530de243c3a5bbc2df992f9d428413b3ff07;hpb=de31b2474e29fe2f2eea6648b83d01ee53a726b7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/HtmlFormatter.php b/includes/HtmlFormatter.php index 83d0530de2..b2209c358e 100644 --- a/includes/HtmlFormatter.php +++ b/includes/HtmlFormatter.php @@ -136,7 +136,13 @@ class HtmlFormatter { wfProfileIn( __METHOD__ ); $removals = $this->parseItemsToRemove(); - if ( !$removals ) { + // Bail out early if nothing to do + if ( array_reduce( $removals, + function( $carry, $item ) { + return $carry && !$item; + }, + true + ) ) { wfProfileOut( __METHOD__ ); return array(); } @@ -253,7 +259,8 @@ class HtmlFormatter { * specify the $element in the method it'll change the underlying dom and you won't be able to get * it back. * - * @param DOMElement|string|null $element ID of element to get HTML from or false to get it from the whole tree + * @param DOMElement|string|null $element ID of element to get HTML from or + * false to get it from the whole tree * @return string Processed HTML */ public function getText( $element = null ) { @@ -287,11 +294,12 @@ class HtmlFormatter { // XML code paths if possible and fix there. $html = str_replace( ' ', '', $html ); } - $html = preg_replace( '/|^.*?|<\/body>.*$/s', '', $html ); wfProfileOut( __METHOD__ . '-fixes' ); } else { $html = $this->html; } + // Remove stuff added by wrapHTML() + $html = preg_replace( '/|^.*?|<\/body>.*$/s', '', $html ); $html = $this->onHtmlReady( $html ); wfProfileIn( __METHOD__ . '-flatten' );