X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=618fa4cab524933354081a2abd1a2a5cdefbce3f;hb=92e3d2f1a39c7048119efe9d1690b72480e84799;hp=537bdefe13748c62bdd0abafb2c29b2e87a7c981;hpb=88f1f3408495d6447256ad2f9b6febc4b02a0388;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 537bdefe13..618fa4cab5 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2134,6 +2134,24 @@ function wfTempDir() { 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. ' . 'Please set $wgTmpDirectory to a writable directory.' ); }