Invalid Argument
kernphilip - June 23, 2008 - 20:48
| Project: | Signup Status |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | jrbeeman |
| Status: | won't fix |
Description
* warning: Invalid argument supplied for foreach() in .../modules/signup_status/signup_status.module on line 374.
* warning: Invalid argument supplied for foreach() in .../modules/signup_status/signup_status.module on line 425.
This notice occurs when viewing a signup form and no status codes are set to "Modify the total signup count"

#1
Attached patch checks that $codes really is an array before calling foreach on it, thus removing the warnings. It doesn't change the behavior.
#2
#3
In fact, the following patch moves the fix to the signup_status_codes function, making sure that it always return an array even if no status matched the given conditions. It should be more generic and remove the need to check if the result was an array or not from every caller. (patch made against the 5.x-1.1 release)
#4
I just tested this in D6 in two configurations:
A) new site with _no_ status codes defined at all.
B) new site with some status codes defined, but none of them are configured to "Show on form".
In both cases, there are no PHP notices or warnings. I think this is a D5-only bug at this point.
I'm not maintaining the D5 version of signup_status at all. The D6 version has been a nearly complete re-write to make this code properly integrate with the main signup.module. I think "won't fix" is the appropriate status here, since I don't know if any of the signup_status maintainers are still working with the D5 version...