From 3a70821dab8b4e2d684e34c701ae0184afb14059 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 14 Sep 2009 21:58:41 +0000 Subject: [PATCH] Clean up a live hack from wmf-deployment r53208: option to short-circuit math path and file existence checks. 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 | 13 +++++++++++++ includes/Math.php | 22 +++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index a32795605d..50417ffa45 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 # diff --git a/includes/Math.php b/includes/Math.php index 2ed1603376..2e61494486 100644 --- a/includes/Math.php +++ b/includes/Math.php @@ -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 :( -- 2.20.1