$error variable undefine (notice)

Issue #14 resolved
Former user created an issue

Originally reported on Google Code with ID 14 ``` the attached screenshot shows that the undefined $error variable is on line 1458 but I think it is actually on line 1457. when there is no error after a user action, the $error variable is not set so the check "if ($error)" throws a notice. (php version 5.3.3, with xdebug) It is fixed by setting the variable to false before the switch statement (switch($_GET['action'])" on line 1166. or in the if statement on the line of the error: if (isset($error) && $error)

```

Reported by `scieck` on 2011-04-23 00:12:01

<hr>

Comments (5)

  1. Former user Account Deleted

    ``` If you browse from svn version 1.8.3, the undefined $error variable is on line: 1491 while on version 1.8.2 is on line: 1485. And on the code i downloaded from here the 23 or 22 of April (which should be version 1.8.2) is on line: 1457.

    You can't have: if ($error) without $error not initialized in php; In the big switch statement above the if ($error) line, (where you switch on user actions) if there is no error then the $error variable is never set to true or false. so PHP throws an E_NOTICE.

    I am attaching 2 screen-shots, 02 is a screen-shot of the code i downloaded from here, screen-shot 03 is a screen-shot of version 1.8.3 from browsing your svn, and also i am attaching the code i have download from here.

    hope the above helps cheers _andrea

    ```

    Reported by `scieck` on 2011-04-23 20:50:48

    <hr>

  2. Dane Iracleous

    ``` This should now be fixed. I changed the line to simply:

    if(isset($error)) ```

    Reported by `diracleo` on 2011-04-23 22:43:14

  3. Former user Account Deleted

    ``` Hi,

    sorry i don't mean to be pedantic but: the reason for doing if (isset($error) && $error) rather then simply if (isset($error)), is that if someone decides to initialize the $error variable at the top of the block, then your if (isset($error)) will return true even if $error is false, so your fix, fixes a bug but introduces the possibility for another. While with the double check you fix it and forget about it, unless the logic changes.

    cheers _andrea

    ```

    Reported by `scieck` on 2011-04-23 23:59:55

  4. Dane Iracleous

    ``` Good catch. $error isn't being initialized until an error actually happens, so as of the current version, $error will never be false. That might change though, so I think your idea is the way to go. I just fixed it. ```

    Reported by `diracleo` on 2011-04-24 01:01:07

  5. Log in to comment