* @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;
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 {
*/
private static function externalClean( $text, $stderr = false, &$retval = null ) {
global $wgTidyConf, $wgTidyBin, $wgTidyOpts;
- wfProfileIn( __METHOD__ );
$cleansource = '';
$opts = ' -utf8';
$cleansource = null;
}
- wfProfileOut( __METHOD__ );
return $cleansource;
}
*/
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;
}
if ( $stderr ) {
$retval = $tidy->getStatus();
-
- wfProfileOut( __METHOD__ );
return $tidy->errorBuffer;
}
}
}
- wfProfileOut( __METHOD__ );
return $cleansource;
}
*/
private static function hhvmClean( $text, &$retval ) {
global $wgTidyConf;
- wfProfileIn( __METHOD__ );
+
$cleansource = tidy_repair_string( $text, $wgTidyConf, 'utf8' );
if ( $cleansource === false ) {
$cleansource = null;
} else {
$retval = 0;
}
- wfProfileOut( __METHOD__ );
+
return $cleansource;
}
}