[wp-trac] [WordPress Trac] #45192: WP_DEBUG notice when classic editor is forced and static methods used causes fatal errors.

WordPress Trac noreply at wordpress.org
Thu Oct 25 17:44:29 UTC 2018


#45192: WP_DEBUG notice when classic editor is forced and static methods used
causes fatal errors.
--------------------------+-----------------------------
 Reporter:  claudiulodro  |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.0
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Hi folks,

 I've tested this bug with the latest version of the Classic Editor and the
 WP 5.0 beta released yesterday. The ReflectionFunction class does not seem
 to properly handle static functions of the form 'ClassName::method_name'.
 Here are the details and how to reproduce:

 1. Start with the latest version of the Classic Editor, WP 5.0 beta, and
 the following mvp code snippet:
 {{{
 class ClassicBoxTest {
   public static function init() {
     add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_box' ) );
   }

   public static function add_meta_box() {
       add_meta_box(
           'classic-box',
           'Classic Box',
           'ClassicBoxTest::classic_box_render',
           null, 'normal', 'high',
           array(
             '__block_editor_compatible_meta_box' => false,
         )
       );
   }

   public static function classic_box_render() {
     echo "Testing";
   }
 }
 ClassicBoxTest::init();
 }}}

 2. When WP_DEBUG is false the box will render properly.

 3. When WP_DEBUG is true, you will get the following fatal error:
 {{{
 Fatal error: Uncaught ReflectionException: Function
 ClassicBoxTest::classic_box_render() does not exist in /srv/www/woodev/wp-
 admin/includes/template.php:1100
 Stack trace:
 #0 /srv/www/woodev/wp-admin/includes/template.php(1100):
 ReflectionFunction->__construct('ClassicBoxTest:...')
 #1 /srv/www/woodev/wp-admin/edit-form-advanced.php(714):
 do_meta_boxes(Object(WP_Screen), 'normal', Object(WP_Post))
 #2 /srv/www/woodev/wp-admin/post.php(179): include('/srv/www/woodev...')
 #3 {main} thrown in /srv/www/woodev/wp-admin/includes/template.php on line
 1100
 }}}

 In previous versions of WP the box would always render properly.

 The error seems to be coming from the code block in wp-
 admin/includes/template.php lines 1096-1129 that only gets processed when
 WP_DEBUG is true and seems to be related to the ReflectionFunction class.

 Let me know if you need any more info. Thanks!

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


More information about the wp-trac mailing list