[wp-trac] [WordPress Trac] #51390: PHP error: Trying to access array offset on value of type bool in /wp-admin/includes/meta-boxes.php on line 482

WordPress Trac noreply at wordpress.org
Fri Oct 2 00:05:00 UTC 2020


#51390: PHP error: Trying to access array offset on value of type bool in /wp-
admin/includes/meta-boxes.php on line 482
--------------------------+-----------------------------
 Reporter:  sproutchris   |       Owner:  SergeyBiryukov
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:  5.6
Component:  Post Formats  |     Version:  5.5.1
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+-----------------------------
Changes (by SergeyBiryukov):

 * keywords:  reporter-feedback => needs-patch
 * owner:  (none) => SergeyBiryukov
 * status:  new => accepted
 * milestone:  Awaiting Review => 5.6


Comment:

 Replying to [comment:4 sproutchris]:
 > Instead of an array, `get_theme_support('post-formats')` on line 480 is
 returning `true`.  Any idea what could cause that to happen?

 As noted in the [https://wordpress.org/support/article/post-formats
 /#adding-theme-support HelpHub] and the
 [https://developer.wordpress.org/themes/functionality/post-formats
 /#adding-theme-support Theme Developer Handbook], adding post formats
 support is supposed to include an array of supported formats:
 {{{
 add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
 }}}
 So this usage is incorrect (previously discussed in #15443 and decided
 against):
 {{{
 add_theme_support( 'post-formats' );
 }}}
 What happens is that the second argument of `add_theme_support()`
 [source:tags/5.5.1/src/wp-includes/theme.php?marks=2491-2493#L2488
 defaults to true] if not specified.

 We should probably add a `_doing_it_wrong()` notice similar to the one
 [source:tags/5.5.1/src/wp-includes/theme.php?marks=2522,2526-2529#L2512
 displayed for 'html5' support]:
 {{{
 _doing_it_wrong( "add_theme_support( 'html5' )", __( 'You need to pass an
 array of types.' ), '3.6.1' );
 }}}

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


More information about the wp-trac mailing list