Merge "Fix and make PHPDoc tags in FileBackend more specific"
[lhc/web/wiklou.git] / includes / parser / MWTidy.php
index 3cb35f7..d446ccf 100644 (file)
@@ -164,7 +164,8 @@ class MWTidy {
         * @param string $text HTML to check
         * @param bool $stderr Whether to read result from STDERR rather than STDOUT
         * @param int &$retval Exit code (-1 on internal error)
-        * @return string|null
+        * @return null|string
+        * @throws MWException
         */
        private static function clean( $text, $stderr = false, &$retval = null ) {
                global $wgTidyInternal;
@@ -194,7 +195,6 @@ class MWTidy {
         */
        private static function externalClean( $text, $stderr = false, &$retval = null ) {
                global $wgTidyConf, $wgTidyBin, $wgTidyOpts;
-               wfProfileIn( __METHOD__ );
 
                $cleansource = '';
                $opts = ' -utf8';
@@ -246,7 +246,6 @@ class MWTidy {
                        $cleansource = null;
                }
 
-               wfProfileOut( __METHOD__ );
                return $cleansource;
        }
 
@@ -261,13 +260,13 @@ class MWTidy {
         */
        private static function phpClean( $text, $stderr = false, &$retval = null ) {
                global $wgTidyConf, $wgDebugTidy;
-               wfProfileIn( __METHOD__ );
 
-               if ( !class_exists( 'tidy' ) ) {
+               if ( ( !wfIsHHVM() && !class_exists( 'tidy' ) ) ||
+                       ( wfIsHHVM() && !function_exists( 'tidy_repair_string' ) )
+               ) {
                        wfWarn( "Unable to load internal tidy class." );
                        $retval = -1;
 
-                       wfProfileOut( __METHOD__ );
                        return null;
                }
 
@@ -276,8 +275,6 @@ class MWTidy {
 
                if ( $stderr ) {
                        $retval = $tidy->getStatus();
-
-                       wfProfileOut( __METHOD__ );
                        return $tidy->errorBuffer;
                }
 
@@ -296,7 +293,6 @@ class MWTidy {
                        }
                }
 
-               wfProfileOut( __METHOD__ );
                return $cleansource;
        }
 
@@ -313,7 +309,7 @@ class MWTidy {
         */
        private static function hhvmClean( $text, &$retval ) {
                global $wgTidyConf;
-               wfProfileIn( __METHOD__ );
+
                $cleansource = tidy_repair_string( $text, $wgTidyConf, 'utf8' );
                if ( $cleansource === false ) {
                        $cleansource = null;
@@ -321,7 +317,7 @@ class MWTidy {
                } else {
                        $retval = 0;
                }
-               wfProfileOut( __METHOD__ );
+
                return $cleansource;
        }
 }