[wp-trac] [WordPress Trac] #42063: Media: Indicate if image is used as a site option

WordPress Trac noreply at wordpress.org
Mon Nov 16 17:53:11 UTC 2020


#42063: Media: Indicate if image is used as a site option
----------------------------------------------+----------------------------
 Reporter:  melchoyce                         |       Owner:  helen
     Type:  enhancement                       |      Status:  closed
 Priority:  normal                            |   Milestone:  5.6
Component:  Media                             |     Version:
 Severity:  normal                            |  Resolution:  fixed
 Keywords:  has-patch has-screenshots commit  |     Focuses:  ui,
                                              |  administration
----------------------------------------------+----------------------------

Comment (by emrikol):

 It looks like this will cause a PHP fatal if
 `wp_prepare_attachment_for_js()` is called early in a theme file.

 A simple test like this should fatal:


 {{{
 diff --git a/themes/twentytwenty/header.php
 b/themes/twentytwenty/header.php
 index dab6b32..f3e25d7 100644
 --- a/themes/twentytwenty/header.php
 +++ b/themes/twentytwenty/header.php
 @@ -26,6 +26,7 @@

         <body <?php body_class(); ?>>

 +               <?php var_dump( wp_prepare_attachment_for_js( '28' ) ); ?>
                 <?php
                 wp_body_open();
                 ?>
 }}}

 {{{
 [16-Nov-2020 17:49:40 UTC] PHP Fatal error:  Uncaught Error: Call to
 undefined function get_media_states() in /var/www/wp-
 includes/media.php:4032
 Stack trace:
 #0 /var/www/wp-content/themes/twentytwenty/header.php(29):
 wp_prepare_attachment_for_js(Object(WP_Post))
 #1 /var/www/wp-includes/template.php(730): require_once('/var/www/wp-
 con...')
 #2 /var/www/wp-includes/template.php(676): load_template('/var/www/wp-
 con...', true, Array)
 #3 /var/www/wp-includes/general-template.php(48): locate_template(Array,
 true, true, Array)
 #4 /var/www/wp-content/themes/twentytwenty/index.php(17): get_header()
 #5 /var/www/wp-includes/template-loader.php(106): include('/var/www/wp-
 con...')
 #6 /var/www/wp-blog-header.php(19): require_once('/var/www/wp-inc...')
 #7 /var/www/index.php(17): require('/var/www/wp-blo...')
 #8 {main}
   thrown in /var/www/wp-includes/media.php on line 4032
 [16-Nov-2020 17:49:40 UTC] Fatal error: Uncaught Error: Call to undefined
 function get_media_states() in /var/www/wp-includes/media.php:4032
 Stack trace:
 #0 /var/www/wp-content/themes/twentytwenty/header.php(29):
 wp_prepare_attachment_for_js(Object(WP_Post))
 #1 /var/www/wp-includes/template.php(730): require_once('/var/www/wp-
 con...')
 #2 /var/www/wp-includes/template.php(676): load_template('/var/www/wp-
 con...', true, Array)
 #3 /var/www/wp-includes/general-template.php(48): locate_template(Array,
 true, true, Array)
 #4 /var/www/wp-content/themes/twentytwenty/index.php(17): get_header()
 #5 /var/www/wp-includes/template-loader.php(106): include('/var/www/wp-
 con...')
 #6 /var/www/wp-blog-header.php(19): require_once('/var/www/wp-inc...')
 #7 /var/www/index.php(17): require('/var/www/wp-blo...')
 #8 {main}
   thrown in /var/www/wp-includes/media.php on line 4032 [www.example.com/]
 []
 }}}


 Version: 5.6-beta4-49608

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/42063#comment:31>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list