Merge "Include log id in api error response"
[lhc/web/wiklou.git] / includes / parser / MWTidy.php
index ff62e9b..6c62302 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;
@@ -172,7 +173,7 @@ class MWTidy {
                if ( $wgTidyInternal ) {
                        if ( wfIsHHVM() ) {
                                if ( $stderr ) {
-                                       throw new MWException( __METHOD__.": error text return from HHVM tidy is not supported" );
+                                       throw new MWException( __METHOD__ . ": error text return from HHVM tidy is not supported" );
                                }
                                return self::hhvmClean( $text, $retval );
                        } else {
@@ -263,7 +264,9 @@ class MWTidy {
                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;