X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FMath.php;h=ef6c603f6d17e9a8ba51c16a94a896de97c7ce61;hb=09da7fb96c45255899fa0f4c62412d14b8575b3e;hp=49701d76a0900ca726f51ad920d75d5f5ff51c6a;hpb=abcffab3c0d81eb8d0fa699a81d7c64f9cadb900;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Math.php b/includes/Math.php index 49701d76a0..ef6c603f6d 100644 --- a/includes/Math.php +++ b/includes/Math.php @@ -42,15 +42,6 @@ class MathRenderer { if( !$this->_recall() ) { # Ensure that the temp and output directories are available before continuing... - $hashpath = $this->_getHashPath(); - - if( !file_exists( $hashpath ) ) { - if( !@wfMkdirParents( $hashpath, 0755 ) ) { - return $this->_error( 'math_bad_output' ); - } - } elseif( !is_dir( $hashpath ) || !is_writable( $hashpath ) ) { - return $this->_error( 'math_bad_output' ); - } if( !file_exists( $wgTmpDirectory ) ) { if( !@mkdir( $wgTmpDirectory ) ) { return $this->_error( 'math_bad_tmpdir' ); @@ -64,7 +55,7 @@ class MathRenderer { } $cmd = $wgTexvc . ' ' . escapeshellarg( $wgTmpDirectory ).' '. - escapeshellarg( $hashpath ).' '. + escapeshellarg( $wgTmpDirectory ).' '. escapeshellarg( $this->tex ).' '. escapeshellarg( $wgInputEncoding ); @@ -127,10 +118,23 @@ class MathRenderer { return $this->_error( 'math_unknown_error' ); } - if( !file_exists( "$hashpath/{$this->hash}.png" ) ) { + if( !file_exists( "$wgTmpDirectory/{$this->hash}.png" ) ) { return $this->_error( 'math_image_error' ); } + $hashpath = $this->_getHashPath(); + if( !file_exists( $hashpath ) ) { + if( !@wfMkdirParents( $hashpath, 0755 ) ) { + return $this->_error( 'math_bad_output' ); + } + } elseif( !is_dir( $hashpath ) || !is_writable( $hashpath ) ) { + return $this->_error( 'math_bad_output' ); + } + + if( !rename( "$wgTmpDirectory/{$this->hash}.png", "$hashpath/{$this->hash}.png" ) ) { + return $this->_error( 'math_output_error' ); + } + # Now save it back to the DB: if ( !wfReadOnly() ) { $outmd5_sql = pack('H32', $this->hash); @@ -239,9 +243,11 @@ class MathRenderer { function _getHashPath() { global $wgMathDirectory; - return $wgMathDirectory .'/'. substr($this->hash, 0, 1) + $path = $wgMathDirectory .'/'. substr($this->hash, 0, 1) .'/'. substr($this->hash, 1, 1) .'/'. substr($this->hash, 2, 1); + wfDebug( "TeX: getHashPath, hash is: $this->hash, path is: $path\n" ); + return $path; }