[wp-trac] [WordPress Trac] #52728: Widgets: Uncaught TypeError in PHP 8 when using objects for settings

WordPress Trac noreply at wordpress.org
Fri Mar 5 20:52:18 UTC 2021


#52728: Widgets: Uncaught TypeError in PHP 8 when using objects for settings
--------------------------+-----------------------------
 Reporter:  dlh           |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Widgets       |    Version:  4.3
 Severity:  normal        |   Keywords:  has-patch php8
  Focuses:                |
--------------------------+-----------------------------
 Support for returning  `ArrayIterator` and `ArrayObject` objects from
 `WP_Widget::get_settings()` was added in [32602]. In PHP 8, a fatal error
 now occurs when one of these objects is passed to `array_key_exists()` in
 `WP_Widget::display_callback()`.

 The attached patch would add a private method to `WP_Widget` for getting
 the settings as an array for use with `array_key_exists()` and other
 array-only functions, moving some logic already in
 `WP_Widget::_register()`.

 Related: [33696] for #33442. At the time, `array_key_exists()` supported
 objects, and it was used deliberately in this location.

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


More information about the wp-trac mailing list