Ticket #31066: 31066.diff
File 31066.diff, 2.6 KB (added by , 10 years ago) |
---|
-
src/wp-includes/functions.php
1483 1483 function wp_mkdir_p( $target ) { 1484 1484 $wrapper = null; 1485 1485 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 1486 1491 // Strip the protocol. 1487 1492 if( wp_is_stream( $target ) ) { 1488 1493 list( $wrapper, $target ) = explode( '://', $target, 2 ); … … 1729 1734 * @since 2.0.0 1730 1735 * 1731 1736 * @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 * 1732 1739 * @return array See above for description. 1733 1740 */ 1734 function wp_upload_dir( $time = null ) {1741 function wp_upload_dir( $time = null, $mkdir = true ) { 1735 1742 $siteurl = get_option( 'siteurl' ); 1736 1743 $upload_path = trim( get_option( 'upload_path' ) ); 1737 1744 … … 1839 1846 ) ); 1840 1847 1841 1848 // Make sure we have an uploads directory. 1842 if ( ! wp_mkdir_p( $uploads['path'] ) ) {1849 if ( $mkdir && ! wp_mkdir_p( $uploads['path'] ) ) { 1843 1850 if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) 1844 1851 $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; 1845 1852 else -
src/wp-includes/post.php
186 186 function get_attached_file( $attachment_id, $unfiltered = false ) { 187 187 $file = get_post_meta( $attachment_id, '_wp_attached_file', true ); 188 188 // 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'] ) ) 190 190 $file = $uploads['basedir'] . "/$file"; 191 191 if ( $unfiltered ) 192 192 return $file; … … 5026 5026 // Get attached file. 5027 5027 if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true) ) { 5028 5028 // Get upload directory. 5029 if ( ( $uploads = wp_upload_dir()) && false === $uploads['error'] ) {5029 if ( ( $uploads = wp_upload_dir( null, false ) ) && false === $uploads['error'] ) { 5030 5030 // Check that the upload base exists in the file location. 5031 5031 if ( 0 === strpos( $file, $uploads['basedir'] ) ) { 5032 5032 // Replace file location with url location.