PHP notices / code clean-up
drewish - January 27, 2009 - 00:00
| Project: | Menu Trails |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Running this module with Drupal 6.x-dev you see a lot of these PHP warnings:
# notice: Undefined index: attributes in sites/all/modules/menutrails/menutrails.module on line 453.
# notice: Undefined variable: trail_raw in sites/all/modules/menutrails/menutrails.module on line 347.
#1
The first one should already be fixed in the latest development snapshot.
The second one should be fixed with attached patch.
#2
Still seeing:
# notice: Undefined variable: trail_raw in /Users/amorton/Sites/rfy/sites/all/modules/menutrails/menutrails.module on line 344.I'd go for something even simpler like this.
#3
found another one:
# notice: Undefined variable: menu in /sites/all/modules/menutrails/menutrails.module on line 89.That one is kind of puzzling:
<?php
/**
* Set Breadcrumbs based on active menu trail.
*/
function menutrails_get_breadcrumbs() {
$item = menu_get_item();
if (!$menu) {
// Give first priority to the selected menu.
$menu = variable_get('menutrails_menu', FALSE);
if (!$menu) {
$menu = db_result(db_query("SELECT menu_name FROM {menu_links} WHERE link_path = '%s' AND module = 'menu'", $item['href']));
}
}
$tree = menu_tree_page_data($menu);
$crumbs = array(l(t('Home'), '<front>'));
_menutrails_recurse_crumbs($tree, $item, $crumbs);
return $crumbs;
}
?>
I guess that should be if (!$item)...?
#4
Finished this up:
• notice: Undefined index: 105 in /Library/WebServer/Documents/rfy_hacking/sites/all/modules/menutrails/menutrails.module on line 280.#5
Now seeing:
notice: Undefined variable: menu in /Library/WebServer/Documents/rfy_hacking/sites/all/modules/menutrails/menutrails.module on line 96.#6
This should hopefully eliminate all PHP notices.
While debugging I found some other bugs for which I'll create separate issues.
#7
oh, yeah much better.
#8
Yay! Pretty long way for a PHP notices issue 8)
As always, it's a pleasure and fun to work with you! :)
#9
Meh. Found another. And some other scary stuff.
#10
Committed.
#11
Automatically closed -- issue fixed for 2 weeks with no activity.