[wp-trac] [WordPress Trac] #60652: font_dir filter enters an infinite loop if wp_get_upload_dir() is used in the filter callback

WordPress Trac noreply at wordpress.org
Wed Feb 28 13:20:40 UTC 2024


#60652: font_dir filter enters an infinite loop if wp_get_upload_dir() is used in
the filter callback
--------------------------+-----------------------------
 Reporter:  mmaattiiaass  |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Calling wp_get_upload_dir() inside a font_dir filter callback produces an
 infinite loop.

 Use this snippet and try to install a font using the font library to
 reproduce the issue:


 {{{#!php
 <?php
 function alter_wp_fonts_dir( $defaults ) {
         $wp_upload_dir = wp_get_upload_dir();
         $uploads_basedir = $wp_upload_dir['basedir'];
         $uploads_baseurl = $wp_upload_dir['baseurl'];

         $fonts_dir = $uploads_basedir . '/fonts';
         // Generate the URL for the fonts directory from the font dir.
         $fonts_url = str_replace( $uploads_basedir, $uploads_baseurl,
 $fonts_dir );

         $defaults['path'] = $fonts_dir;
         $defaults['url']  = $fonts_url;

         return $defaults;
 }
 add_filter( 'font_dir', 'alter_wp_fonts_dir' );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60652>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list