[wp-trac] [WordPress Trac] #17864: Small bug when using "wp_delete_file" filter

WordPress Trac wp-trac at lists.automattic.com
Tue Jun 21 20:40:36 UTC 2011


#17864: Small bug when using "wp_delete_file" filter
--------------------------+-------------------------------------
 Reporter:  DuGi_dk       |      Owner:  Morten Rugaard
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  3.1.3
 Severity:  minor         |   Keywords:  needs-patch 2nd-opinion
--------------------------+-------------------------------------
 Hi,

 I came acrossed this little annoying bugger, when I was playing around
 with upload filters.

 When I added the "wp_delete_file", I kept getting this error:

 {{{
 #!php
 Notice: Undefined index: path in /volume1/web/dev/favola_dk/wp-
 includes/post.php on line 3757
 }}}

 I then digged down in the line, where the error was occuring and I find
 this little bugger (the bold line is line 3757):

 {{{
 #!php
 // remove intermediate and backup images if there are any
 foreach ( get_intermediate_image_sizes() as $size ) {
         if ( $intermediate = image_get_intermediate_size($post_id, $size)
 ) {
                 $intermediate_file = apply_filters('wp_delete_file',
 $intermediate['path']);
                 @ unlink( path_join($uploadpath['basedir'],
 $intermediate_file) );
         }
 }
 }}}

 I noticed when I var_dump() the $size, that "path" is not within the array
 at any time. And the funny thing is, if you go down the next block in the
 code you'll see this:


 {{{
 #!php
 if ( is_array($backup_sizes) ) {
         foreach ( $backup_sizes as $size ) {
                 $del_file = path_join( dirname($meta['file']),
 $size['file'] );
                 $del_file = apply_filters('wp_delete_file', $del_file);
                 @ unlink( path_join($uploadpath['basedir'], $del_file) );
         }
 }
 }}}

 Here it uses the index "file", which is the one I was expecting to recieve
 in the former block.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17864>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list