From 9db190c7e736ec8d063187d4241b59feaf7dc2d1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 22 Jun 2011 11:28:20 +0200 Subject: update to MediaWiki 1.17.0 --- includes/Math.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'includes/Math.php') diff --git a/includes/Math.php b/includes/Math.php index 8cf9b8d8..0e136d5f 100644 --- a/includes/Math.php +++ b/includes/Math.php @@ -37,7 +37,8 @@ class MathRenderer { if( $this->mode == MW_MATH_SOURCE ) { # No need to render or parse anything more! - return ('$ '.htmlspecialchars( $this->tex ).' $'); + # New lines are replaced with spaces, which avoids confusing our parser (bugs 23190, 22818) + return ('$ ' . str_replace( "\n", " ", htmlspecialchars( $this->tex ) ) . ' $'); } if( $this->tex == '' ) { return; # bug 8372 @@ -55,7 +56,7 @@ class MathRenderer { } } - if( function_exists( 'is_executable' ) && !is_executable( $wgTexvc ) ) { + if( !is_executable( $wgTexvc ) ) { return $this->_error( 'math_notexvc' ); } $cmd = $wgTexvc . ' ' . @@ -71,7 +72,7 @@ class MathRenderer { } wfDebug( "TeX: $cmd\n" ); - $contents = `$cmd`; + $contents = wfShellExec( $cmd ); wfDebug( "TeX output:\n $contents\n---\n" ); if (strlen($contents) == 0) { @@ -153,7 +154,10 @@ class MathRenderer { $hashpath = $this->_getHashPath(); if( !file_exists( $hashpath ) ) { - if( !@wfMkdirParents( $hashpath, 0755 ) ) { + wfSuppressWarnings(); + $ret = wfMkdirParents( $hashpath, 0755 ); + wfRestoreWarnings(); + if( !$ret ) { return $this->_error( 'math_bad_output' ); } } elseif( !is_dir( $hashpath ) || !is_writable( $hashpath ) ) { @@ -231,7 +235,9 @@ class MathRenderer { if( file_exists( $filename ) ) { if( filesize( $filename ) == 0 ) { // Some horrible error corrupted stuff :( - @unlink( $filename ); + wfSuppressWarnings(); + unlink( $filename ); + wfRestoreWarnings(); } else { return true; } @@ -241,7 +247,10 @@ class MathRenderer { $hashpath = $this->_getHashPath(); if( !file_exists( $hashpath ) ) { - if( !@wfMkdirParents( $hashpath, 0755 ) ) { + wfSuppressWarnings(); + $ret = wfMkdirParents( $hashpath, 0755 ); + wfRestoreWarnings(); + if( !$ret ) { return false; } } elseif( !is_dir( $hashpath ) || !is_writable( $hashpath ) ) { @@ -323,10 +332,10 @@ class MathRenderer { .'/'. substr($this->hash, 2, 1); } - public static function renderMath( $tex, $params=array() ) { - global $wgUser; + public static function renderMath( $tex, $params=array(), ParserOptions $parserOptions = null ) { $math = new MathRenderer( $tex, $params ); - $math->setOutputMode( $wgUser->getOption('math')); + if ( $parserOptions ) + $math->setOutputMode( $parserOptions->getMath() ); return $math->render(); } } -- cgit v1.2.3-54-g00ecf