/** 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
#
function render() {
global $wgTmpDirectory, $wgInputEncoding;
- global $wgTexvc;
+ global $wgTexvc, $wgMathCheckFiles;
$fname = 'MathRenderer::render';
if( $this->mode == MW_MATH_SOURCE ) {
}
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 ) ) {
}
function _recall() {
- global $wgMathDirectory;
+ global $wgMathDirectory, $wgMathCheckFiles;
$fname = 'MathRenderer::_recall';
$this->md5 = md5( $this->tex );
$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 :(