[wp-trac] [WordPress Trac] #61792: PHP warning `Undefined array key "widget_id"` in legacy widget

WordPress Trac noreply at wordpress.org
Tue Aug 6 07:05:58 UTC 2024


#61792: PHP warning `Undefined array key "widget_id"` in legacy widget
------------------------------+----------------------
 Reporter:  rabmalin          |       Owner:  (none)
     Type:  defect (bug)      |      Status:  closed
 Priority:  normal            |   Milestone:
Component:  Widgets           |     Version:
 Severity:  normal            |  Resolution:  wontfix
 Keywords:  has-testing-info  |     Focuses:
------------------------------+----------------------
Changes (by peterwilsoncc):

 * status:  new => closed
 * resolution:   => wontfix
 * milestone:  Awaiting Review =>


Comment:

 The widget method in plugins doesn't always receive an widget_id and need
 to check if it's defined before use. See the [https://github.com/WordPress
 /wordpress-develop/blob/162fda69c832f36c14b867701b213e16e1d89dbc/src/wp-
 includes/widgets/class-wp-widget-recent-posts.php#L45-L47 recent posts
 widget's code] as an example.

 Based on a quick scan of the code it's due to the widgets not having an
 instance ID when displayed outside of a sidebar on the widgets page.

 As the error is being triggered by a plugin, I've closed this ticket as I
 don't think there is much core can do to defend against the situation.

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


More information about the wp-trac mailing list