Clean up a live hack from wmf-deployment r53208: option to short-circuit math path...
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 14 Sep 2009 21:58:41 +0000 (21:58 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 14 Sep 2009 21:58:41 +0000 (21:58 +0000)
Adds $wgMathCheckFiles setting:

/**
 * Normally when generating math images, we double-check that the
 * directories we want to write to exist, and that files that have
 * been generated still exist when we need to bring them up again.
 *
 * This lets us give useful error messages in case of permission
 * problems, and automatically rebuild images that have been lost.
 *
 * On a big site with heavy NFS traffic this can be slow and flaky,
 * so sometimes we want to short-circuit it by setting this to false.
 */
$wgMathCheckFiles = true;

includes/DefaultSettings.php
includes/Math.php

index a327956..50417ff 100644 (file)
@@ -1864,6 +1864,19 @@ $wgUseTeX = false;
 /** Location of the texvc binary */
 $wgTexvc = './math/texvc';
 
+/**
+ * Normally when generating math images, we double-check that the
+ * directories we want to write to exist, and that files that have
+ * been generated still exist when we need to bring them up again.
+ *
+ * This lets us give useful error messages in case of permission
+ * problems, and automatically rebuild images that have been lost.
+ *
+ * On a big site with heavy NFS traffic this can be slow and flaky,
+ * so sometimes we want to short-circuit it by setting this to false.
+ */
+$wgMathCheckFiles = true;
+
 #
 # Profiling / debugging
 #
index 2ed1603..2e61494 100644 (file)
@@ -33,7 +33,7 @@ class MathRenderer {
 
        function render() {
                global $wgTmpDirectory, $wgInputEncoding;
-               global $wgTexvc;
+               global $wgTexvc, $wgMathCheckFiles;
                $fname = 'MathRenderer::render';
 
                if( $this->mode == MW_MATH_SOURCE ) {
@@ -45,13 +45,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 ) ) {
@@ -200,7 +202,7 @@ class MathRenderer {
        }
 
        function _recall() {
-               global $wgMathDirectory;
+               global $wgMathDirectory, $wgMathCheckFiles;
                $fname = 'MathRenderer::_recall';
 
                $this->md5 = md5( $this->tex );
@@ -221,6 +223,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 :(