Code cleanup, removed a bunch of parser warnings and some actual undefined variables. Even though some might find this supurflous, I think it's good to keep the core code clean so we can spot those variables that are really undefined in the future.

These 4 are still questionable. I need some input on these:

The local variable $edit may not have been initialized	user.module	Drupal HEAD (Core)/modules/user	line 1161
The local variable $form may not have been initialized	search.module	Drupal HEAD (Core)/modules/search	line 245

The 2 below are still remaining, but I can see they should get set in the while. But the first time it runs through, they are undefined since $tag is FALSE.

The local variable $linknid may not have been initialized	search.module	Drupal HEAD (Core)/modules/search	line 574
The local variable $linktitle may not have been initialized	search.module	Drupal HEAD (Core)/modules/search	line 558

It's not a bad idea to flush these out, and real easy with PHPEclipse. I've caught some worthy mini-bugs just by loading up the project in Eclipse, might be a better solution than vi. :P

CommentFileSizeAuthor
#4 cleanup2.patch9.22 KBRobRoy
cleanup.patch8.1 KBRobRoy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drumm’s picture

Status: Needs review » Needs work

Most of these look okay. Except the $null = NULL. Just use NULL.

I'd like to see these broken up into separate patches and separate issues by file for easier reviewing.

RobRoy’s picture

I thought the $null = NULL; was needed because some of those params are passed by reference.

drumm’s picture

Make a note of that in a comment and use NULL where arguments are not pass by reference.

RobRoy’s picture

FileSize
9.22 KB

Revised patch for HEAD with changes suggested by drumm.

RobRoy’s picture

Status: Needs work » Needs review
Jax’s picture

TRUE, true, FALSE, false, NULL and null is used inconsistently throughout the code. Maybe there should be coding conventions for reserved keywords as well?

Jax’s picture

+1 for false, true, null for php (and NULL for SQL but that is mentioned).

drumm’s picture

NULL, FALSE, and TRUE are preferred.

RobRoy’s picture

Yeah, I've always used TRUE/FALSE as I prefer it and /thought/ that was the standard. That is why my additions are as such.

What is the Drupal coding standard for this? I see the PEAR page at http://pear.php.net/manual/en/standards.funcdef.php has a "true" so you may be right.

If one of the devs lets me know, I'll change the patch to reflect this.

RobRoy’s picture

@drumm: Okay cool.

Anything else needed to get this patch committed then?

RobRoy’s picture

I suppose we should add some info on TRUE/FALSE/NULL to http://drupal.org/node/318 then.

Jax’s picture

Status: Needs review » Reviewed & tested by the community

Verified the code and applied the patch, works.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD.

Please break your patches up into smaller chunks next time.

Anonymous’s picture

Status: Fixed » Closed (fixed)