Opened 12 years ago
Closed 10 years ago
#19945 closed defect (bug) (wontfix)
Bug in ../wp-includes/widgets.php
Reported by: | Barti112 | Owned by: | Barti112 |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.3.1 |
Component: | Widgets | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description (last modified by )
in this file there are at some places the following code:
$widget = array_merge($widget, $options);
it is possible that $options is not an array and i become a php-warning.
i think better is to check the arrays before you use this function:
if(is_array($widget) && is_array($options)){ $widget = array_merge($widget, $options); }
Change History (5)
#2
@
12 years ago
Here you see a var_dump before the Line 777 of the file "widgets.php":
array(1) { ["id_base"]=> string(5) "pages" }[[BR]] array(1) { ["id_base"]=> string(8) "calendar" }[[BR]] array(1) { ["id_base"]=> string(8) "archives" }[[BR]] array(1) { ["id_base"]=> string(5) "links" }[[BR]] array(1) { ["id_base"]=> string(4) "meta" }[[BR]] array(3) { ["id_base"]=> string(4) "text" ["width"]=> int(400) ["height"]=> int(350) }[[BR]] array(1) { ["id_base"]=> string(10) "categories" }[[BR]] array(1) { ["id_base"]=> string(12) "recent-posts" }[[BR]] array(1) { ["id_base"]=> string(15) "recent-comments" }[[BR]] array(3) { ["id_base"]=> string(3) "rss" ["width"]=> int(400) ["height"]=> int(200) }[[BR]] array(1) { ["id_base"]=> string(8) "nav_menu" }[[BR]] array(1) { ["id_base"]=> string(20) "arras_tabbed_sidebar" }[[BR]] array(1) { ["id_base"]=> string(22) "arras_featured_stories" }[[BR]] Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /homepages/16/d266165857/htdocs/wsb5144855001/akademie/wp- includes/widgets.php on line 781[[BR]] array(1) { ["id_base"]=> string(6) "search" }[[BR]] array(1) { ["id_base"]=> string(17) "wpcalendargrouped" }[[BR]] array(1) { ["id_base"]=> string(16) "wpcalendarsimple" }[[BR]]
Perhaps it is a widget of a Plugin, but the general code does not break with an error/warning if there is a bug.
#3
@
12 years ago
- Cc kpayne@… added
- Keywords dev-feedback added
I can reproduce this by modfying the control_options
member after construction. This is a no-no, but because control_options
is public, it's not enforced by design.
<?php class Foo_Widget extends WP_Widget { function __construct() { parent::WP_Widget( 'foo_widget', 'Foo_Widget', array( 'description' => 'A Foo Widget' ) ); $this->control_options = null; } /** snip **/ }
Results:
PHP Warning: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #2 is not an array in ...\wp-includes\widgets.php on line 777
Note: See
TracTickets for help on using
tickets.
As far as I can see,
$options
in those places is the result ofwp_parse_args()
, which always returns an array.Could you describe the circumstances when
$options
is not an array?