Remove user id from Special:Preferences
[lhc/web/wiklou.git] / includes / HtmlFormatter.php
index 83d0530..b2209c3 100644 (file)
@@ -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>|<\/body>.*$/s', '', $html );
                        wfProfileOut( __METHOD__ . '-fixes' );
                } else {
                        $html = $this->html;
                }
+               // Remove stuff added by wrapHTML()
+               $html = preg_replace( '/<!--.*?-->|^.*?<body>|<\/body>.*$/s', '', $html );
                $html = $this->onHtmlReady( $html );
 
                wfProfileIn( __METHOD__ . '-flatten' );