[wp-trac] [WordPress Trac] #51791: When wp_prepare_attachment_for_js() is called too early, a fatal occurs "Call to undefined function get_media_states()"

WordPress Trac noreply at wordpress.org
Mon Nov 16 21:02:54 UTC 2020


#51791: When wp_prepare_attachment_for_js() is called too early, a fatal occurs
"Call to undefined function get_media_states()"
------------------------------+---------------------
 Reporter:  rebasaurus        |       Owner:  helen
     Type:  defect (bug)      |      Status:  closed
 Priority:  normal            |   Milestone:  5.6
Component:  Media             |     Version:  trunk
 Severity:  major             |  Resolution:  fixed
 Keywords:  has-patch commit  |     Focuses:
------------------------------+---------------------
Description changed by SergeyBiryukov:

Old description:

> When we call `wp_prepare_attachment_for_js()` too early, we see the
> fatal:
>
> `Call to undefined function get_media_states()`
>
> Introduced in https://core.trac.wordpress.org/changeset/49223 from
> #42063.
>
> To test in twentytwenty:
>
> {{{#!php
> --- 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();
>                 ?>
> }}}
>

> You will see it fatal.

New description:

 When we call `wp_prepare_attachment_for_js()` too early, we see the fatal:

 `Call to undefined function get_media_states()`

 Introduced in [49223] from #42063.

 To test in twentytwenty:

 {{{#!php
 --- 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();
                 ?>
 }}}


 You will see it fatal.

--

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


More information about the wp-trac mailing list