WordPress.org

Make WordPress Core

Ticket #31066: 31066.diff

File 31066.diff, 2.6 KB (added by kovshenin, 5 years ago)
  • src/wp-includes/functions.php

     
    14831483function wp_mkdir_p( $target ) {
    14841484        $wrapper = null;
    14851485
     1486        // Allow plugins to override dir creation.
     1487        $override = apply_filters( 'wp_mkdir_p_override', null, $target );
     1488        if ( $override !== null )
     1489                return $override;
     1490
    14861491        // Strip the protocol.
    14871492        if( wp_is_stream( $target ) ) {
    14881493                list( $wrapper, $target ) = explode( '://', $target, 2 );
     
    17291734 * @since 2.0.0
    17301735 *
    17311736 * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null.
     1737 * @param bool $mkdir Optional. Attempt to create uploads directory if it doesn't exist.
     1738 *
    17321739 * @return array See above for description.
    17331740 */
    1734 function wp_upload_dir( $time = null ) {
     1741function wp_upload_dir( $time = null, $mkdir = true ) {
    17351742        $siteurl = get_option( 'siteurl' );
    17361743        $upload_path = trim( get_option( 'upload_path' ) );
    17371744
     
    18391846                ) );
    18401847
    18411848        // Make sure we have an uploads directory.
    1842         if ( ! wp_mkdir_p( $uploads['path'] ) ) {
     1849        if ( $mkdir && ! wp_mkdir_p( $uploads['path'] ) ) {
    18431850                if ( 0 === strpos( $uploads['basedir'], ABSPATH ) )
    18441851                        $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
    18451852                else
  • src/wp-includes/post.php

     
    186186function get_attached_file( $attachment_id, $unfiltered = false ) {
    187187        $file = get_post_meta( $attachment_id, '_wp_attached_file', true );
    188188        // If the file is relative, prepend upload dir.
    189         if ( $file && 0 !== strpos($file, '/') && !preg_match('|^.:\\\|', $file) && ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) )
     189        if ( $file && 0 !== strpos( $file, '/' ) && !preg_match( '|^.:\\\|', $file ) && ( ( $uploads = wp_upload_dir( null, false ) ) && false === $uploads['error'] ) )
    190190                $file = $uploads['basedir'] . "/$file";
    191191        if ( $unfiltered )
    192192                return $file;
     
    50265026        // Get attached file.
    50275027        if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true) ) {
    50285028                // Get upload directory.
    5029                 if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) {
     5029                if ( ( $uploads = wp_upload_dir( null, false ) ) && false === $uploads['error'] ) {
    50305030                        // Check that the upload base exists in the file location.
    50315031                        if ( 0 === strpos( $file, $uploads['basedir'] ) ) {
    50325032                                // Replace file location with url location.