From 222b01f5169f1c7e69762e0e8904c24f78f71882 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 28 Jul 2010 11:52:48 +0200 Subject: update to MediaWiki 1.16.0 --- includes/Math.php | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'includes/Math.php') diff --git a/includes/Math.php b/includes/Math.php index 2ed16033..8cf9b8d8 100644 --- a/includes/Math.php +++ b/includes/Math.php @@ -33,8 +33,7 @@ class MathRenderer { function render() { global $wgTmpDirectory, $wgInputEncoding; - global $wgTexvc; - $fname = 'MathRenderer::render'; + global $wgTexvc, $wgMathCheckFiles, $wgTexvcBackgroundColor; if( $this->mode == MW_MATH_SOURCE ) { # No need to render or parse anything more! @@ -45,13 +44,15 @@ class MathRenderer { } if( !$this->_recall() ) { - # Ensure that the temp and output directories are available before continuing... - if( !file_exists( $wgTmpDirectory ) ) { - if( !wfMkdirParents( $wgTmpDirectory ) ) { + if( $wgMathCheckFiles ) { + # Ensure that the temp and output directories are available before continuing... + if( !file_exists( $wgTmpDirectory ) ) { + if( !wfMkdirParents( $wgTmpDirectory ) ) { + return $this->_error( 'math_bad_tmpdir' ); + } + } elseif( !is_dir( $wgTmpDirectory ) || !is_writable( $wgTmpDirectory ) ) { return $this->_error( 'math_bad_tmpdir' ); } - } elseif( !is_dir( $wgTmpDirectory ) || !is_writable( $wgTmpDirectory ) ) { - return $this->_error( 'math_bad_tmpdir' ); } if( function_exists( 'is_executable' ) && !is_executable( $wgTexvc ) ) { @@ -61,7 +62,8 @@ class MathRenderer { escapeshellarg( $wgTmpDirectory ).' '. escapeshellarg( $wgTmpDirectory ).' '. escapeshellarg( $this->tex ).' '. - escapeshellarg( $wgInputEncoding ); + escapeshellarg( $wgInputEncoding ).' '. + escapeshellarg( $wgTexvcBackgroundColor ); if ( wfIsWindows() ) { # Invoke it within cygwin sh, because texvc expects sh features in its default shell @@ -101,14 +103,14 @@ class MathRenderer { } else { $this->conservativeness = 0; } - $this->mathml = NULL; + $this->mathml = null; } else if ($retval == 'X') { - $this->html = NULL; + $this->html = null; $this->mathml = substr ($contents, 33); $this->conservativeness = 0; } else if ($retval == '+') { - $this->html = NULL; - $this->mathml = NULL; + $this->html = null; + $this->mathml = null; $this->conservativeness = 0; } else { $errbit = htmlspecialchars( substr($contents, 1) ); @@ -176,7 +178,7 @@ class MathRenderer { 'math_html_conservativeness' => $this->conservativeness, 'math_html' => $this->html, 'math_mathml' => $this->mathml, - ), $fname + ), __METHOD__ ); } @@ -200,15 +202,14 @@ class MathRenderer { } function _recall() { - global $wgMathDirectory; - $fname = 'MathRenderer::_recall'; + global $wgMathDirectory, $wgMathCheckFiles; $this->md5 = md5( $this->tex ); $dbr = wfGetDB( DB_SLAVE ); $rpage = $dbr->selectRow( 'math', array( 'math_outputhash','math_html_conservativeness','math_html','math_mathml' ), array( 'math_inputhash' => $dbr->encodeBlob(pack("H32", $this->md5))), # Binary packed, not hex - $fname + __METHOD__ ); if( $rpage !== false ) { @@ -221,6 +222,12 @@ class MathRenderer { $this->mathml = $rpage->math_mathml; $filename = $this->_getHashPath() . "/{$this->hash}.png"; + + if( !$wgMathCheckFiles ) { + // Short-circuit the file existence & migration checks + return true; + } + if( file_exists( $filename ) ) { if( filesize( $filename ) == 0 ) { // Some horrible error corrupted stuff :( -- cgit v1.2.3-54-g00ecf