Coder review - undefined index if module does not have hook_menu()

Dave Reid - November 29, 2008 - 21:15
Project:Translation template extractor
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

If I'm running the potx coder review on a module that does not implement hook_menu, I get the following PHP notice error:
notice: Undefined index: statistics_advanced_menu in /home/davereid/Projects/drupal6/sites/all/modules/contrib/potx/potx.inc on line 894.

<?php
function _potx_find_menu_hook($file, $filebase, $save_callback) {
  global
$_potx_tokens, $_potx_lookup;
 
  if (
is_array($_potx_lookup[$filebase .'_menu'])) {
?>

Needs to be changed to:

<?php
function _potx_find_menu_hook($file, $filebase, $save_callback) {
  global
$_potx_tokens, $_potx_lookup;
 
  if (isset(
$_potx_lookup[$filebase .'_menu']) && is_array($_potx_lookup[$filebase .'_menu'])) {
?>

and it fixes all the notice errors!

#1

Gábor Hojtsy - December 1, 2008 - 13:13
Status:active» reviewed & tested by the community

Yes, looks like a great fix.

#2

Gábor Hojtsy - March 12, 2009 - 14:59
Version:6.x-2.x-dev» 5.x-2.x-dev
Status:reviewed & tested by the community» patch (to be ported)

Committed this fix, thanks! Also target for 5.x-2.x backport, if that ever happens. Not high on priority.

#3

Gábor Hojtsy - August 24, 2009 - 13:02
Version:5.x-2.x-dev» 6.x-2.x-dev
Status:patch (to be ported)» fixed

Since 5.x is not maintained, moving back to fixed.

#4

System Message - September 7, 2009 - 13:10
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.