[wp-trac] [WordPress Trac] #29803: Silent failure when wp_embed_register_handler() has a non-public callback

WordPress Trac noreply at wordpress.org
Mon Sep 29 19:56:40 UTC 2014


#29803: Silent failure when wp_embed_register_handler() has a non-public callback
---------------------------+-----------------------------
 Reporter:  paulschreiber  |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  General        |    Version:
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 WordPress fails silently when wp_embed_register_handler() has a non-public
 callback

 If you have a class like this:

 {{{
 class Stuff {
    public static function hooks() {
      wp_embed_register_handler( 'foobar', $regex, array( __CLASS__,
 'embed_handler' ) );
    }

   private static function embed_handler( $matches, $attr, $url, $rawattr )
 {
     //.... do stuff
   }
 }
 }}}

 And you run
 {{{
 Stuff::hooks();
 }}}

 Your handler is never registered and no error is shown or logged.

 By contrast, `add_action()` checks for this condition and logs an error:

 {{{
 PHP Warning:  call_user_func_array() expects parameter 1 to be a valid
 callback, cannot access private method Stuff::enqueue_scripts() in
 /srv/www/wp/wp-includes/plugin.php on line 505
 }}}

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


More information about the wp-trac mailing list