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

sun - January 27, 2009 - 03:56
Title:Lots of PHP warnings» $trail_raw undefined PHP notices
Priority:minor» normal
Status:active» needs review

The first one should already be fixed in the latest development snapshot.

The second one should be fixed with attached patch.

AttachmentSize
menutrails-DRUPAL-6--1.notices.patch 1.29 KB

#2

drewish - January 27, 2009 - 04:15

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.

AttachmentSize
menutrails_364717.patch 680 bytes

#3

drewish - January 28, 2009 - 03:21
Status:needs review» needs work

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

drewish - January 30, 2009 - 02:07

Finished this up:

• notice: Undefined index: 105 in /Library/WebServer/Documents/rfy_hacking/sites/all/modules/menutrails/menutrails.module on line 280.

AttachmentSize
menutrails_364717.patch 1.37 KB

#5

drewish - January 30, 2009 - 06:43

Now seeing:

notice: Undefined variable: menu in /Library/WebServer/Documents/rfy_hacking/sites/all/modules/menutrails/menutrails.module on line 96.

#6

sun - February 2, 2009 - 01:26
Status:needs work» needs review

This should hopefully eliminate all PHP notices.

While debugging I found some other bugs for which I'll create separate issues.

AttachmentSize
menutrails-DRUPAL-6--1.notices.patch 2.17 KB

#7

drewish - February 2, 2009 - 09:39
Status:needs review» reviewed & tested by the community

oh, yeah much better.

#8

sun - February 2, 2009 - 15:51
Status:reviewed & tested by the community» fixed

Yay! Pretty long way for a PHP notices issue 8)

As always, it's a pleasure and fun to work with you! :)

#9

sun - February 4, 2009 - 03:52
Title:$trail_raw undefined PHP notices» PHP notices / code clean-up
Status:fixed» needs review

Meh. Found another. And some other scary stuff.

AttachmentSize
menutrails-DRUPAL-6--1.clean-up.patch 4.18 KB

#10

sun - July 24, 2009 - 17:18
Status:needs review» fixed

Committed.

#11

System Message - August 7, 2009 - 17:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.