PHP Notices in duplicate.module

eosrei - August 16, 2009 - 19:57
Project:Spam
Version:HEAD
Component:Custom Filters
Category:bug report
Priority:minor
Assigned:liberatr
Status:needs review
Description

Working to locate the cause of an error in a separate module, I noticed three notices kept coming up in my error logs: Two "Undefined index: q", and one "Undefined variable: index". All three are in duplicate.module.

function _duplicate_arg() {
  static $arguments, $q;

  if (empty($arguments) || $q != $_GET['q']) {
    $arguments = explode('/', $_GET['q']);
    $q = $_GET['q'];
  }

  if (isset($arguments[$index])) {
    return $arguments[$index];
  }
}

The first two notices would easily be fixed by first checking isset($_GET['q']). I am not sure about the undefined "$index". Should it be "'index'" instead?

I am under a deadline right now, or I would create a patch for the first two notices. I will have time in a couple weeks, if the problem hasn't already been resolved.

#1

liberatr - September 15, 2009 - 14:59
Assigned to:Anonymous» liberatr
Status:active» needs review

The comment above the _duplicate_arg() function says it is copied from the source of the arg() function in core.

The core function has the fingerprint:
<?php function arg($index = NULL, $path = NULL) { ... } ?>

However, the function in duplicate.module takes no arguments.

Patch attached. The notice went away for me.

AttachmentSize
missing_argument_d5.patch 313 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.