[wp-trac] [WordPress Trac] #33442: Widgets not displayed if no $instance data is set
WordPress Trac
noreply at wordpress.org
Thu Aug 20 12:12:43 UTC 2015
#33442: Widgets not displayed if no $instance data is set
--------------------------+--------------------
Reporter: johnnyb | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.3.1
Component: Widgets | Version: 4.3
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+--------------------
Comment (by GregRoss):
Replying to [comment:3 westonruter]:
> @johnnyb Nevertheless, I think it is a plugin error to return anything
but an array from the `update` callback. If you look at
`WP_Widget::update_callback()` in core, it calls the `update` method and
is expecting its return value as being an array, which it then passes into
the `widget_update_callback` filter. If there are other plugins filtering
this value, then they would be generating PHP warnings/notices when
encountering a `null` value. The default base `WP_Widget::update()` method
is defined as returning an array as well, so all subclasses should also
have methods that return arrays.
That documentation looks to be incorrect as if you look at the
`WP_Widget::update()` inline documentation it specifically says you can
return false from the call to indicate the settings should not be changed.
So any plugin filtering the value cannot assume it's an array and needs to
handle Boolean as well.
I don't disagree that returning a null value is probably incorrect as per
the intent of the functions, but it obvious does happen (I've already
fixed my plugin to return an empty array instead).
Going back to the old behaviour seems to make the most sense as it doesn't
have any downside by the looks of it.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33442#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list