X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/d3947bc013df7edd54b46deed8230d2eeafc5ecb..a9fa37e08fa731c7bd108a175c24876823bc071b:/wp-includes/functions.php diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 0e720ee1..a3afddce 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1854,7 +1854,7 @@ function wp_get_upload_dir() { * @return array See above for description. */ function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) { - static $cache = array(); + static $cache = array(), $tested_paths = array(); $key = sprintf( '%d-%s', get_current_blog_id(), (string) $time ); @@ -1874,13 +1874,10 @@ function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false if ( $create_dir ) { $path = $uploads['path']; - $tested_paths = wp_cache_get( 'upload_dir_tested_paths' ); - if ( ! is_array( $tested_paths ) ) { - $tested_paths = array(); - } - - if ( ! in_array( $path, $tested_paths, true ) ) { + if ( array_key_exists( $path, $tested_paths ) ) { + $uploads['error'] = $tested_paths[ $path ]; + } else { if ( ! wp_mkdir_p( $path ) ) { if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) { $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; @@ -1889,10 +1886,9 @@ function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false } $uploads['error'] = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), esc_html( $error_path ) ); - } else { - $tested_paths[] = $path; - wp_cache_set( 'upload_dir_tested_paths', $tested_paths ); } + + $tested_paths[ $path ] = $uploads['error']; } }