wfTempDir try harder to get a tmp dir on Windows
Bug: T44730 Change-Id: If6f93ed50dfd93a1ffe046218058674a2197a626
This commit is contained in:
parent
749f7624d9
commit
96e94d1c90
1 changed files with 18 additions and 0 deletions
|
|
@ -2120,6 +2120,24 @@ function wfTempDir() {
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP on Windows will detect C:\Windows\Temp as not writable even though PHP can write to it
|
||||||
|
* so create a directory within that called 'mwtmp' with a suffix of the user running the
|
||||||
|
* current process.
|
||||||
|
* The user is included as if various scripts are run by different users they will likely
|
||||||
|
* not be able to access each others temporary files.
|
||||||
|
*/
|
||||||
|
if ( wfIsWindows() ) {
|
||||||
|
$tmp = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mwtmp' . '-' . get_current_user();
|
||||||
|
if ( !file_exists( $tmp ) ) {
|
||||||
|
mkdir( $tmp );
|
||||||
|
}
|
||||||
|
if ( file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) {
|
||||||
|
return $tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
throw new MWException( 'No writable temporary directory could be found. ' .
|
throw new MWException( 'No writable temporary directory could be found. ' .
|
||||||
'Please set $wgTmpDirectory to a writable directory.' );
|
'Please set $wgTmpDirectory to a writable directory.' );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue