[wp-trac] Re: [WordPress Trac] #8428: wp_mkdir_p function endless recursion

WordPress Trac wp-trac at lists.automattic.com
Sat Nov 29 19:45:33 GMT 2008


#8428: wp_mkdir_p function endless recursion
-------------------------------------+--------------------------------------
 Reporter:  st_falcon                |        Owner:  anonymous
     Type:  defect                   |       Status:  new      
 Priority:  high                     |    Milestone:  2.8      
Component:  General                  |      Version:  2.6.1    
 Severity:  critical                 |   Resolution:           
 Keywords:  wp_mkdir_p, upload_path  |  
-------------------------------------+--------------------------------------
Comment (by st_falcon):

 this function should just stop creating directories once /  is reached.

 Currently it is:

 {{{
 function wp_mkdir_p( $target ) {
         // from php.net/mkdir user contributed notes
         $target = str_replace( '//', '/', $target );
         if ( file_exists( $target ) )
                 return @is_dir( $target );

         // Attempting to create the directory may clutter up our display.
         if ( @mkdir( $target ) ) {
                 $stat = @stat( dirname( $target ) );
                 $dir_perms = $stat['mode'] & 0007777;  // Get the
 permission bits.
                 @chmod( $target, $dir_perms );
                 return true;
         } elseif ( is_dir( dirname( $target ) ) ) {
                         return false;
         }

         // If the above failed, attempt to create the parent node, then
 try again.
         if ( wp_mkdir_p( dirname( $target ) ) )
                 return wp_mkdir_p( $target );

         return false;
 }
 }}}

 It should probably be:

 {{{
         if ( wp_mkdir_p( dirname( $target ) ) && $target != '/')
                 return wp_mkdir_p( $target );
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/8428#comment:2>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list