Opened 6 years ago
Closed 5 years ago
#46542 closed defect (bug) (fixed)
Passing wrong param to do_meta_boxes in dashboard.php
Reported by: | killua99 | Owned by: | felipeelia |
---|---|---|---|
Milestone: | 5.3 | Priority: | normal |
Severity: | normal | Version: | 5.2 |
Component: | Administration | Keywords: | has-patch |
Focuses: | Cc: |
Description
The hook do_meta_boxes
is been calling with wrong params in dashboard.php
The line in dashboard.php are:
<?php /** This action is documented in wp-admin/includes/meta-boxes.php */ do_action( 'do_meta_boxes', $screen->id, 'normal', '' );
The hook do_meta_boxes
require that the third param to be a WP_Post object.
As the hook documentation said here: https://developer.wordpress.org/reference/hooks/do_meta_boxes/
If you write a hook that does require to be a WP_Post the third param and you navigate to dashboard you could get a PHP Fatal error.
Steps to reproduce:
Write in any active plugin these lines:
<?php add_action( 'do_meta_boxes', function ( string $post_type, string $context, \WP_Post $post ) { // Navigate to dashboard you will get an error since the 3rd param is an string. if ( $post instanceof \WP_Post ) { // Your code. } }, 10, 3 );
Navigate to the dashboard.php
Expected result.
Normal dashboard page.
Actual result:
You get an PHP Fatal Error.
Cause:
Description above
Possible solution:
1 - Write a special meta_box for dashboard
2 - Correct documentation that the third param might get an string on it (seems like dashboard.php is the only passing a string)
In 46071: