http://www.mediawiki.org/wiki/Special:Code/MediaWiki/56343
Revision: 56343
Author: brion
Date: 2009-09-14 21:58:41 +0000 (Mon, 14 Sep 2009)
Log Message:
-----------
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;
Modified Paths:
--------------
trunk/phase3/includes/DefaultSettings.php
trunk/phase3/includes/Math.php
Modified: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php 2009-09-14 21:50:12 UTC (rev
56342)
+++ trunk/phase3/includes/DefaultSettings.php 2009-09-14 21:58:41 UTC (rev
56343)
@@ -1864,6 +1864,19 @@
/** 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
#
Modified: trunk/phase3/includes/Math.php
===================================================================
--- trunk/phase3/includes/Math.php 2009-09-14 21:50:12 UTC (rev 56342)
+++ trunk/phase3/includes/Math.php 2009-09-14 21:58:41 UTC (rev 56343)
@@ -33,7 +33,7 @@
function render() {
global $wgTmpDirectory, $wgInputEncoding;
- global $wgTexvc;
+ global $wgTexvc, $wgMathCheckFiles;
$fname = 'MathRenderer::render';
if( $this->mode == MW_MATH_SOURCE ) {
@@ -45,13 +45,15 @@
}
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 @@
}
function _recall() {
- global $wgMathDirectory;
+ global $wgMathDirectory, $wgMathCheckFiles;
$fname = 'MathRenderer::_recall';
$this->md5 = md5( $this->tex );
@@ -221,6 +223,12 @@
$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
:(
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs