]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/functions.php
WordPress 4.5.1
[autoinstalls/wordpress.git] / wp-includes / functions.php
index 0e720ee168d85eb0f6a184ee596befb3d4f756f6..a3afddcec473ec0cf20a8b935dbb478810992684 100644 (file)
@@ -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'];
                }
        }