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: https://develop.svn.wordpress.org/trunk@23255 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b558464d2d
commit
80bc158edd
@ -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
|
// Force some settings if we are streaming to a file and check for existence and perms of destination directory
|
||||||
if ( $r['stream'] ) {
|
if ( $r['stream'] ) {
|
||||||
$r['blocking'] = true;
|
$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.' ) );
|
return new WP_Error( 'http_request_failed', __( 'Destination directory for file streaming does not exist or is not writable.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1401,27 +1401,44 @@ function get_temp_dir() {
|
|||||||
if ( $temp )
|
if ( $temp )
|
||||||
return trailingslashit( rtrim( $temp, '\\' ) );
|
return trailingslashit( rtrim( $temp, '\\' ) );
|
||||||
|
|
||||||
$is_win = ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) );
|
|
||||||
|
|
||||||
if ( function_exists('sys_get_temp_dir') ) {
|
if ( function_exists('sys_get_temp_dir') ) {
|
||||||
$temp = 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, '\\' ) );
|
return trailingslashit( rtrim( $temp, '\\' ) );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$temp = ini_get('upload_tmp_dir');
|
$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, '\\' ) );
|
return trailingslashit( rtrim( $temp, '\\' ) );
|
||||||
|
|
||||||
$temp = WP_CONTENT_DIR . '/';
|
$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;
|
return $temp;
|
||||||
|
|
||||||
$temp = '/tmp/';
|
$temp = '/tmp/';
|
||||||
return $temp;
|
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
|
* Workaround for Windows bug in is_writable() function
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user