$items passed to theme('item_list',...) may contain subarrays from menu_navigation_links's $menu_tree
| Project: | RootCandy |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
RootCandy assumes the elements of the array retrieved from menu_navigation_links() are valid to pass to theme('item_list', ...). However, when RootCandy is set to display a tree of links other than the default, this array may contain subarrays of a type not expected by this function.
theme_item_list declares $items as "An array of items to be displayed in the list. If an item is a string, then it is used as is. If an item is an array, then the "data" element of the array is used as the contents of the list item. If an item is an array with a "children" element, those children are displayed in a nested list. All other elements are treated as attributes of the list item element.":
http://api.drupal.org/api/function/theme_item_list/6
The function treats the subarray as an attribute, i.e. a string, leading to the warning:
preg_match() expects parameter 2 to be string, array given in [...]/includes/bootstrap.inc on line 777
This may be the cause of problems reported at http://drupal.org/node/320145 and http://drupal.org/node/628902
Here is an example array (from primary links) that may cause the problem:
<?php
Array
(
[menu-232] => Array
(
[attributes] => Array
(
[title] =>
)
[href] => <front>
[title] => Front
)
...
?>The backtrace was:
bootstrap.inc: drupal_validate_utf8 line 741
common.inc: check_plain line 1526
theme.inc: drupal_attributes line 1499
theme.inc: call_user_func_array line 617
template.php: theme line 135
theme.inc: call_user_func_array line 617
template.php: theme line 128
page.tpl.php: _rootcandy_admin_navigation line 52
theme.inc: include line 1020
theme.inc: theme_render_template line 686
index.php: theme line 3

#1
Same probleme for me
In my case that was coming from the line 134, in the function root_candy_navigation()
That's to say from the function theme_item_list as said in the previous post.
Probably not a clean solution but i rewrite function in that way to remove the warning :
<?phpfunction rootcandy_admin_navigation($items, $class) {
// remove sub array attributes
foreach($items as $key => $item){
unset($items[$key]['attributes']);
}
return theme('item_list', $items, NULL, 'ul', array('class' => $class));
}
?>
#2
I'm having the same problem when using a custom menu for certain roles.
#3
thanks guys for your reports
finaly got some time to fix this annoying issue.
added 3 lines to template.php
<?phpif (!empty($item['attributes'])) {
unset($item['attributes']);
}
?>
committed to dev version, thank you
#4
Automatically closed -- issue fixed for 2 weeks with no activity.