Make WordPress Core

Ticket #36621: 36621.patch

File 36621.patch, 1.4 KB (added by ocean90, 9 years ago)
  • src/wp-includes/functions.php

     
    18541854 * @return array See above for description.
    18551855 */
    18561856function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) {
    1857         static $cache = array();
     1857        static $cache = array(), $tested_paths = array();
    18581858
    18591859        $key = sprintf( '%d-%s', get_current_blog_id(), (string) $time );
    18601860
     
    18741874
    18751875        if ( $create_dir ) {
    18761876                $path = $uploads['path'];
    1877                 $tested_paths = wp_cache_get( 'upload_dir_tested_paths' );
    18781877
    18791878                if ( ! is_array( $tested_paths ) ) {
    18801879                        $tested_paths = array();
    18811880                }
    18821881
    1883                 if ( ! in_array( $path, $tested_paths, true ) ) {
     1882                if ( array_key_exists( $path, $tested_paths ) ) {
     1883                        $uploads['error'] = $tested_paths[ $path ];
     1884                } else {
    18841885                        if ( ! wp_mkdir_p( $path ) ) {
    18851886                                if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) {
    18861887                                        $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
     
    18891890                                }
    18901891
    18911892                                $uploads['error'] = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), esc_html( $error_path ) );
    1892                         } else {
    1893                                 $tested_paths[] = $path;
    1894                                 wp_cache_set( 'upload_dir_tested_paths', $tested_paths );
    18951893                        }
     1894
     1895                        $tested_paths[ $path ] = $uploads['error'];
    18961896                }
    18971897        }
    18981898