More wfMkdirParents() __METHOD__ additions

This commit is contained in:
Sam Reed 2011-07-25 22:09:05 +00:00
parent db20e016f9
commit 16b234384a

View file

@ -53,7 +53,7 @@ class MathRenderer {
if( $wgMathCheckFiles ) { if( $wgMathCheckFiles ) {
# Ensure that the temp and output directories are available before continuing... # Ensure that the temp and output directories are available before continuing...
if( !file_exists( $wgTmpDirectory ) ) { if( !file_exists( $wgTmpDirectory ) ) {
if( !wfMkdirParents( $wgTmpDirectory ) ) { if( !wfMkdirParents( $wgTmpDirectory, null, __METHOD__ ) ) {
return $this->_error( 'math_bad_tmpdir' ); return $this->_error( 'math_bad_tmpdir' );
} }
} elseif( !is_dir( $wgTmpDirectory ) || !is_writable( $wgTmpDirectory ) ) { } elseif( !is_dir( $wgTmpDirectory ) || !is_writable( $wgTmpDirectory ) ) {
@ -160,7 +160,7 @@ class MathRenderer {
$hashpath = $this->_getHashPath(); $hashpath = $this->_getHashPath();
if( !file_exists( $hashpath ) ) { if( !file_exists( $hashpath ) ) {
wfSuppressWarnings(); wfSuppressWarnings();
$ret = wfMkdirParents( $hashpath, 0755 ); $ret = wfMkdirParents( $hashpath, 0755, __METHOD__ );
wfRestoreWarnings(); wfRestoreWarnings();
if( !$ret ) { if( !$ret ) {
return $this->_error( 'math_bad_output' ); return $this->_error( 'math_bad_output' );
@ -193,7 +193,7 @@ class MathRenderer {
__METHOD__ __METHOD__
); );
} }
// If we're replacing an older version of the image, make sure it's current. // If we're replacing an older version of the image, make sure it's current.
global $wgUseSquid; global $wgUseSquid;
if ( $wgUseSquid ) { if ( $wgUseSquid ) {
@ -240,12 +240,12 @@ class MathRenderer {
$this->mathml = $rpage->math_mathml; $this->mathml = $rpage->math_mathml;
$filename = $this->_getHashPath() . "/{$this->hash}.png"; $filename = $this->_getHashPath() . "/{$this->hash}.png";
if( !$wgMathCheckFiles ) { if( !$wgMathCheckFiles ) {
// Short-circuit the file existence & migration checks // Short-circuit the file existence & migration checks
return true; return true;
} }
if( file_exists( $filename ) ) { if( file_exists( $filename ) ) {
if( filesize( $filename ) == 0 ) { if( filesize( $filename ) == 0 ) {
// Some horrible error corrupted stuff :( // Some horrible error corrupted stuff :(
@ -262,7 +262,7 @@ class MathRenderer {
if( !file_exists( $hashpath ) ) { if( !file_exists( $hashpath ) ) {
wfSuppressWarnings(); wfSuppressWarnings();
$ret = wfMkdirParents( $hashpath, 0755 ); $ret = wfMkdirParents( $hashpath, 0755, __METHOD__ );
wfRestoreWarnings(); wfRestoreWarnings();
if( !$ret ) { if( !$ret ) {
return false; return false;
@ -341,14 +341,14 @@ class MathRenderer {
$dir = $this->_getHashSubPath(); $dir = $this->_getHashSubPath();
return "$wgMathPath/$dir/{$this->hash}.png"; return "$wgMathPath/$dir/{$this->hash}.png";
} }
function _getHashPath() { function _getHashPath() {
global $wgMathDirectory; global $wgMathDirectory;
$path = $wgMathDirectory . '/' . $this->_getHashSubPath(); $path = $wgMathDirectory . '/' . $this->_getHashSubPath();
wfDebug( "TeX: getHashPath, hash is: $this->hash, path is: $path\n" ); wfDebug( "TeX: getHashPath, hash is: $this->hash, path is: $path\n" );
return $path; return $path;
} }
function _getHashSubPath() { function _getHashSubPath() {
return substr( $this->hash, 0, 1) return substr( $this->hash, 0, 1)
. '/' . substr( $this->hash, 1, 1 ) . '/' . substr( $this->hash, 1, 1 )