Download & Extend

PHP notices and undefined variables oh my!

Project:Coder Tough Love
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:ironic

Issue Summary

When running the Coder Tough Love review, I get the following notices:
# notice: Undefined variable: potentially_inside_a_hook_menu in /home/davereid/Projects/drupal6/sites/all/modules/contrib/coder_tough_love/coder_tough_love.module on line 171.
# notice: Undefined variable: potentially_inside_a_hook_menu in /home/davereid/Projects/drupal6/sites/all/modules/contrib/coder_tough_love/coder_tough_love.module on line 176.
# notice: Undefined variable: potentially_inside_a_hook_menu in /home/davereid/Projects/drupal6/sites/all/modules/contrib/coder_tough_love/coder_tough_love.module on line 183.

<?php
function _coder_tough_love_admin_menu_descriptions(&$coder_args, $review, $rule, $lines, &$results) {
  foreach (
$lines as $line_number => $line) {
   
$line = implode(' ', $line); // concat'd parts.
...
   
// if we're inside, look at the line and check for an admin path.
   
if ($potentially_inside_a_hook_menu && preg_match('/\[[\'"]admin\//', $line)) {
     
$potentially_found_an_admin_path = $line_number; // used in the error.
   
}
?>

Should be changed to:

<?php
function _coder_tough_love_admin_menu_descriptions(&$coder_args, $review, $rule, $lines, &$results) {
  foreach (
$lines as $line_number => $line) {
   
$line = implode(' ', $line); // concat'd parts.
   
$potentially_inside_a_hook_menu = 0;
...
   
// if we're inside, look at the line and check for an admin path.
   
if ($potentially_inside_a_hook_menu && preg_match('/\[[\'"]admin\//', $line)) {
     
$potentially_found_an_admin_path = $line_number; // used in the error.
   
}
?>

Comments

#1

Title:notice: Undefined variable: potentially_inside_a_hook_menu» notice: Undefined variable

Now I'm also getting:
* notice: Undefined variable: potentially_found_an_admin_path in /home/davereid/Projects/drupal6/sites/all/modules/contrib/coder_tough_love/coder_tough_love.module on line 177.
* notice: Undefined variable: potentially_found_an_admin_path in /home/davereid/Projects/drupal6/sites/all/modules/contrib/coder_tough_love/coder_tough_love.module on line 184.

$potentially_found_an_admin_path = 0; should also be added along with $potentially_inside_a_hook_menu = 0;.

#2

Title:notice: Undefined variable» PHP notes and undefined variables oh my!
Status:active» needs review

I think it is ironic that I am filing a patch for undefined variables for the coder tough love review module. :)

AttachmentSize
340tl-tsk-tsk-undefined-variables-D6.patch 1.94 KB

#3

Status:needs review» reviewed & tested by the community

Re-rolled.

AttachmentSize
340617-notices-warnings.patch 1.55 KB

#4

Title:PHP notes and undefined variables oh my!» PHP notices and undefined variables oh my!

#5

Status:reviewed & tested by the community» fixed

Thanks, this seems like the proper way to resolve this to me. Committed to 6.x-1.x-dev:
http://drupal.org/commitlog/commit/7948/78dc17a3be3b5b6ad8d501e0a9e2fd2b...

#6

Status:fixed» closed (fixed)

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

nobody click here