Closed (fixed)
Project:
Station
Version:
5.x-1.2
Component:
Schedule
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
14 Nov 2007 at 08:40 UTC
Updated:
2 Dec 2007 at 00:51 UTC
My log had several entries like this:
Invalid argument supplied for foreach() in /home/seasider/public_html/sites/all/modules/station/schedule/station_schedule.module on line 285.
These appear to be caused by a non-admin user editing a program.
He has the right to, because I set him as author of the node.
However, the node has no DJs set yet, because I've not got all the presenters set up with user accounts.
The problem is in the hook_nodeapi implementation:
// validate the users
foreach ($node->djs as $key => $dj) {
if ($dj['username']) {
$user = user_load(array('name' => $dj['username']));
if (!$user->uid) {
form_set_error("djs][$key][username", t('You need to specify a valid user name.'));
}
if (!isset($user->roles[$dj_role])) {
form_set_error("djs][$key][username", t('%username is not a member of the %rolename role.',
array('%username' => $user->name, '%rolename' => $roles[$dj_role])));
}
}
}
Looks like we need a test for $node->djs at the top of that case.
Comments
Comment #1
drewish commentedwhat about just casting to an array?
would that do the trick?
Comment #2
joachim commentedYup, that works.
Comment #3
drewish commentedcool, committed that to DRUPAL-5.
Comment #4
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.