~canonical-sysadmins/wordpress/4.7.2

« back to all changes in this revision

Viewing changes to wp-includes/functions.php

  • Committer: Barry Price
  • Date: 2016-04-27 04:42:45 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: barry.price@canonical.com-20160427044245-ob1jzpeq2ex7jv07
Merge WP 4.5.1 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1854
1854
 * @return array See above for description.
1855
1855
 */
1856
1856
function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false ) {
1857
 
        static $cache = array();
 
1857
        static $cache = array(), $tested_paths = array();
1858
1858
 
1859
1859
        $key = sprintf( '%d-%s', get_current_blog_id(), (string) $time );
1860
1860
 
1874
1874
 
1875
1875
        if ( $create_dir ) {
1876
1876
                $path = $uploads['path'];
1877
 
                $tested_paths = wp_cache_get( 'upload_dir_tested_paths' );
1878
 
 
1879
 
                if ( ! is_array( $tested_paths ) ) {
1880
 
                        $tested_paths = array();
1881
 
                }
1882
 
 
1883
 
                if ( ! in_array( $path, $tested_paths, true ) ) {
 
1877
 
 
1878
                if ( array_key_exists( $path, $tested_paths ) ) {
 
1879
                        $uploads['error'] = $tested_paths[ $path ];
 
1880
                } else {
1884
1881
                        if ( ! wp_mkdir_p( $path ) ) {
1885
1882
                                if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) {
1886
1883
                                        $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
1889
1886
                                }
1890
1887
 
1891
1888
                                $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 );
1895
1889
                        }
 
1890
 
 
1891
                        $tested_paths[ $path ] = $uploads['error'];
1896
1892
                }
1897
1893
        }
1898
1894