diff --git a/wp-includes/class-http.php b/wp-includes/class-http.php index 75d835205e..a9738ee1d2 100644 --- a/wp-includes/class-http.php +++ b/wp-includes/class-http.php @@ -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.' ) ); } diff --git a/wp-includes/functions.php b/wp-includes/functions.php index cf8fc532dd..fb1d70feee 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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 *