r56343 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56342‎ | r56343 | r56344 >
Date:21:58, 14 September 2009
Author:brion
Status:ok
Tags:
Comment:
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 (modified) (history)
  • /trunk/phase3/includes/Math.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
@@ -1864,6 +1864,19 @@
18651865 /** Location of the texvc binary */
18661866 $wgTexvc = './math/texvc';
18671867
 1868+/**
 1869+ * Normally when generating math images, we double-check that the
 1870+ * directories we want to write to exist, and that files that have
 1871+ * been generated still exist when we need to bring them up again.
 1872+ *
 1873+ * This lets us give useful error messages in case of permission
 1874+ * problems, and automatically rebuild images that have been lost.
 1875+ *
 1876+ * On a big site with heavy NFS traffic this can be slow and flaky,
 1877+ * so sometimes we want to short-circuit it by setting this to false.
 1878+ */
 1879+$wgMathCheckFiles = true;
 1880+
18681881 #
18691882 # Profiling / debugging
18701883 #
Index: trunk/phase3/includes/Math.php
@@ -33,7 +33,7 @@
3434
3535 function render() {
3636 global $wgTmpDirectory, $wgInputEncoding;
37 - global $wgTexvc;
 37+ global $wgTexvc, $wgMathCheckFiles;
3838 $fname = 'MathRenderer::render';
3939
4040 if( $this->mode == MW_MATH_SOURCE ) {
@@ -45,13 +45,15 @@
4646 }
4747
4848 if( !$this->_recall() ) {
49 - # Ensure that the temp and output directories are available before continuing...
50 - if( !file_exists( $wgTmpDirectory ) ) {
51 - if( !wfMkdirParents( $wgTmpDirectory ) ) {
 49+ if( $wgMathCheckFiles ) {
 50+ # Ensure that the temp and output directories are available before continuing...
 51+ if( !file_exists( $wgTmpDirectory ) ) {
 52+ if( !wfMkdirParents( $wgTmpDirectory ) ) {
 53+ return $this->_error( 'math_bad_tmpdir' );
 54+ }
 55+ } elseif( !is_dir( $wgTmpDirectory ) || !is_writable( $wgTmpDirectory ) ) {
5256 return $this->_error( 'math_bad_tmpdir' );
5357 }
54 - } elseif( !is_dir( $wgTmpDirectory ) || !is_writable( $wgTmpDirectory ) ) {
55 - return $this->_error( 'math_bad_tmpdir' );
5658 }
5759
5860 if( function_exists( 'is_executable' ) && !is_executable( $wgTexvc ) ) {
@@ -200,7 +202,7 @@
201203 }
202204
203205 function _recall() {
204 - global $wgMathDirectory;
 206+ global $wgMathDirectory, $wgMathCheckFiles;
205207 $fname = 'MathRenderer::_recall';
206208
207209 $this->md5 = md5( $this->tex );
@@ -221,6 +223,12 @@
222224 $this->mathml = $rpage->math_mathml;
223225
224226 $filename = $this->_getHashPath() . "/{$this->hash}.png";
 227+
 228+ if( !$wgMathCheckFiles ) {
 229+ // Short-circuit the file existence & migration checks
 230+ return true;
 231+ }
 232+
225233 if( file_exists( $filename ) ) {
226234 if( filesize( $filename ) == 0 ) {
227235 // Some horrible error corrupted stuff :(

Follow-up revisions

RevisionCommit summaryAuthorDate
r56374Merge post-branch trunk updates replacing old live hacks:...brion17:25, 15 September 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53208Apply live hacks, local merges, and removal of SVN externals -- all copied fr...brion23:50, 13 July 2009

Status & tagging log