|Issue tags:||needs backport to D7|
Menu rebuild causes:
Object of class stdClass could not be converted to int in _menu_router_build() - line 3370
error when using some contrib modules such as nodequeue.
This is due to a bug in the behavior of
array_multisort(), which is used in _menu_navigation_links_rebuild().
array_multisort() keeps sorting by all dimensions of the array, and if any of the (sub)-children are objects it will trigger a notice that it cannot compare them to other types.
Here is a generic PHP script that will trigger this error:
$sort['A'] = 2;
$sort['B'] = 1;
$sort['C'] = 1;
$menu['A'] = 0;
$menu['B'] = (object) array(0);
$menu['C'] = 0;
array_multisort($sort, SORT_NUMERIC, $menu);
Fix the sorting of menu items to not use
array_multisort() but just a normal
asort(). A patch implementing this change is in #972536-63: Object of class stdClass could not be converted to int in _menu_router_build() - line 3370. A test that reproduces the bug is included in the patch.
A workaround for modules that trigger this error is to change the order of arguments in
hook_menu() declarations. See the the commit to fix this bug in the nodequeue module.
- Adjust patch for changes from #1010480: Optimize _menu_navigation_links_rebuild() in
- Evaluate the impact this change could have on performance, as
array_multisort()may have been chosen for performance reasons.
- For the related issue of the side effects of passing cached objects to the menu system, see #997918: Menu gets rebuilt continually during install and update (and menu system stores entire, out-of-date theme objects).
User interface changes
Original report by tekante
When doing a minimal install with Drupal 7 Beta2, the above error is observed after enabling the nodequeue module when using the head revision and patches http://drupal.org/files/issues/nodequeue-d7-db-insert-errors-fix.patch and http://drupal.org/files/issues/nodequeue-941558-16.patch.
Why am I not filing this in the nodequeue queue? I don't believe the error is due to anything nodequeue is doing wrong based on the variety of things that resolve the error. Comparing its info to that of another item (admin/structure/types does not show any obvious errors). There is an issue filed related to this but I wanted to bring it to the attention of the menu system maintainer 
Attached is a file containing a serialized dump of the $sort and $menu states along with comments about various manipulations to the data that result in the error disappearing.
The error disappears in the following conditions:
1. Unsetting arbitrary admin/structure/nodequeue menu entry sub keys
2. Adding a SORT_STRING parameter as the 4th argument to the array_multisort call on line 3370
3. Unsetting an arbitrary subkey of another menu entry (admin/structure/types in the attached file)
My PHP versions are
PHP 5.2.13 (cli) (built: Mar 7 2010 09:15:25)
PHP 5.3.2 (cli) (built: Aug 7 2010 00:04:41)
|multisort.php_.gz||12.27 KB||Ignored: Check issue status.||None||None|