HTTP API: Introduce wp_is_writable() to wrap win_is_writable() and is_writable() to work around PHP Windows ACL issues. See #22900 for trunk

git-svn-id: http://core.svn.wordpress.org/trunk@23255 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2013-01-03 08:04:11 +00:00
parent a7bb4ac774
commit 50da2d8a9f
2 changed files with 24 additions and 7 deletions

View File

@ -141,7 +141,7 @@ class WP_Http {
// Force some settings if we are streaming to a file and check for existence and perms of destination directory
if ( $r['stream'] ) {
$r['blocking'] = true;
if ( ! is_writable( dirname( $r['filename'] ) ) )
if ( ! wp_is_writable( dirname( $r['filename'] ) ) )
return new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
}

View File

@ -1401,27 +1401,44 @@ function get_temp_dir() {
if ( $temp )
return trailingslashit( rtrim( $temp, '\\' ) );
$is_win = ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) );
if ( function_exists('sys_get_temp_dir') ) {
$temp = sys_get_temp_dir();
if ( @is_dir( $temp ) && ( $is_win ? win_is_writable( $temp ) : @is_writable( $temp ) ) ) {
if ( @is_dir( $temp ) && wp_is_writable( $temp ) )
return trailingslashit( rtrim( $temp, '\\' ) );
}
}
$temp = ini_get('upload_tmp_dir');
if ( is_dir( $temp ) && ( $is_win ? win_is_writable( $temp ) : @is_writable( $temp ) ) )
if ( is_dir( $temp ) && wp_is_writable( $temp ) )
return trailingslashit( rtrim( $temp, '\\' ) );
$temp = WP_CONTENT_DIR . '/';
if ( is_dir( $temp ) && ( $is_win ? win_is_writable( $temp ) : @is_writable( $temp ) ) )
if ( is_dir( $temp ) && wp_is_writable( $temp ) )
return $temp;
$temp = '/tmp/';
return $temp;
}
/**
* Determine if a directory is writable.
*
* This function is used to work around certain ACL issues
* in PHP primarily affecting Windows Servers.
*
* @see win_is_writable()
*
* @since 3.6.0
*
* @param string $path
* @return bool
*/
function wp_is_writable( $path ) {
if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
return win_is_writable( $path );
else
return @is_writable( $path );
}
/**
* Workaround for Windows bug in is_writable() function
*