Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
PHP warning when editing a role
I've installed Vanilla 1.0.3, and am in the process of getting everything up.
Whenever I edit a role, I am getting the following PHP warning:
[error] PHP Warning: Variable passed to each() is not an array or object in /home/username/public_html/domain/forum/themes/settings_role_edit.php on line 58
Line 58 of settings_role_edit.php reads:
while (list($PermissionKey, $PermissionValue) = each($this->Role->Permissions)) {
Any ideas for a fix for this problem?
Thanks in advance!
Whenever I edit a role, I am getting the following PHP warning:
[error] PHP Warning: Variable passed to each() is not an array or object in /home/username/public_html/domain/forum/themes/settings_role_edit.php on line 58
Line 58 of settings_role_edit.php reads:
while (list($PermissionKey, $PermissionValue) = each($this->Role->Permissions)) {
Any ideas for a fix for this problem?
Thanks in advance!
0
This discussion has been closed.
Comments
Any ideas on what might be causing the error in version 1.0.3?
Note: I haven't upgraded to the latest version yet, as there have been too many issues. Am waiting for the dust to settle a bit before upgrading.
Whenever a role is deleted, shouldn't it also be deleted from the database table?
Also, could those deleted roles be causing the PHP warning?
I still say you should try re-uploading and installing - even to a different directory and different db - just to see if there was a problem with one of the files getting uploaded or something like that.
Have uploaded a brand new install of 1.1.2 to a new folder and new database, and am still getting this same error:
[Wed Mar 14 10:49:40 2007] [error] PHP Warning: Variable passed to each() is not an array or object in /home/username/public_html/domain/support/themes/settings_role_edit.php on line 58
I have not added any new roles yet, and was editing the admin role to enable features that have been added for new extensions that I am installing.
Any ideas?
Edited roles without any problems.
It's time to get our hands dirty. Open up /home/username/public_html/domain/support/themes/settings_role_edit.php and change this:
while (list($PermissionKey, $PermissionValue) = each($this->Role->Permissions)) { echo '<li> <p> <span>'.GetDynamicCheckBox($PermissionKey, 1, $PermissionValue, '', $this->Context->GetDefinition($PermissionKey)).'</span> </p> </li>'; }
to this
echo 'Printing array of permissions: '; print_r($this->Role->Permissions); die(); while (list($PermissionKey, $PermissionValue) = each($this->Role->Permissions)) { echo '<li> <p> <span>'.GetDynamicCheckBox($PermissionKey, 1, $PermissionValue, '', $this->Context->GetDefinition($PermissionKey)).'</span> </p> </li>'; }
If that prints out something blank, we'll have to go back into the role class to see why it's not being defined properly.
function GetPropertiesFromDataSet($DataSet) { $this->RoleID = ForceInt(@$DataSet['RoleID'], 0); $this->RoleName = ForceString(@$DataSet['Name'],''); $this->Icon = ForceString(@$DataSet['Icon'],''); $this->Description = ForceString(@$DataSet['Description'],''); $this->PERMISSION_SIGN_IN = ForceBool(@$DataSet['PERMISSION_SIGN_IN'], 0); $this->PERMISSION_HTML_ALLOWED = ForceBool(@$DataSet['PERMISSION_HTML_ALLOWED'], 0); $this->PERMISSION_RECEIVE_APPLICATION_NOTIFICATION = ForceBool(@$DataSet['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION'], 0); $this->Unauthenticated = ForceBool(@$DataSet['Unauthenticated'], 0); $TempPermissions = ''; $TempPermissions = ForceString(@$DataSet['Permissions'], ''); $TempPermissions = UnserializeAssociativeArray($TempPermissions); $this->Permissions['PERMISSION_SIGN_IN'] = $this->PERMISSION_SIGN_IN; $this->Permissions['PERMISSION_HTML_ALLOWED'] = $this->PERMISSION_HTML_ALLOWED; $this->Permissions['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION'] = $this->PERMISSION_RECEIVE_APPLICATION_NOTIFICATION; while (list($TempKey, $TempValue) = each($TempPermissions)) { $this->Permissions[$TempKey] = $TempValue; } unset($TempPermissions); }
to this:
function GetPropertiesFromDataSet($DataSet) { $this->RoleID = ForceInt(@$DataSet['RoleID'], 0); $this->RoleName = ForceString(@$DataSet['Name'],''); $this->Icon = ForceString(@$DataSet['Icon'],''); $this->Description = ForceString(@$DataSet['Description'],''); $this->PERMISSION_SIGN_IN = ForceBool(@$DataSet['PERMISSION_SIGN_IN'], 0); $this->PERMISSION_HTML_ALLOWED = ForceBool(@$DataSet['PERMISSION_HTML_ALLOWED'], 0); $this->PERMISSION_RECEIVE_APPLICATION_NOTIFICATION = ForceBool(@$DataSet['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION'], 0); $this->Unauthenticated = ForceBool(@$DataSet['Unauthenticated'], 0); $TempPermissions = ''; $TempPermissions = ForceString(@$DataSet['Permissions'], ''); echo 'Temp Permissions from Database: ".$TempPermissions; $TempPermissions = UnserializeAssociativeArray($TempPermissions); $this->Permissions['PERMISSION_SIGN_IN'] = $this->PERMISSION_SIGN_IN; $this->Permissions['PERMISSION_HTML_ALLOWED'] = $this->PERMISSION_HTML_ALLOWED; $this->Permissions['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION'] = $this->PERMISSION_RECEIVE_APPLICATION_NOTIFICATION; while (list($TempKey, $TempValue) = each($TempPermissions)) { $this->Permissions[$TempKey] = $TempValue; } unset($TempPermissions); }
Then when you run that page you should see exactly what is coming out of the database. I'm hoping this isn't the case, but it might be a database problem.
Printing array of permissions: Array (
[PERMISSION_SIGN_IN] => 1
[PERMISSION_ADD_COMMENTS] => 1
[PERMISSION_START_DISCUSSION] => 1
[PERMISSION_HTML_ALLOWED] => 1
[PERMISSION_SINK_DISCUSSIONS] => 1
[PERMISSION_STICK_DISCUSSIONS] =>
[PERMISSION_HIDE_DISCUSSIONS] =>
[PERMISSION_CLOSE_DISCUSSIONS] =>
[PERMISSION_EDIT_DISCUSSIONS] =>
[PERMISSION_VIEW_HIDDEN_DISCUSSIONS] =>
[PERMISSION_EDIT_COMMENTS] =>
[PERMISSION_HIDE_COMMENTS] =>
[PERMISSION_VIEW_HIDDEN_COMMENTS] =>
[PERMISSION_ADD_COMMENTS_TO_CLOSED_DISCUSSION] =>
[PERMISSION_ADD_CATEGORIES] =>
[PERMISSION_EDIT_CATEGORIES] =>
[PERMISSION_REMOVE_CATEGORIES] =>
[PERMISSION_SORT_CATEGORIES] =>
[PERMISSION_VIEW_ALL_WHISPERS] =>
[PERMISSION_APPROVE_APPLICANTS] =>
[PERMISSION_RECEIVE_APPLICATION_NOTIFICATION] => 0
[PERMISSION_CHANGE_USER_ROLE] =>
[PERMISSION_EDIT_USERS] =>
[PERMISSION_IP_ADDRESSES_VISIBLE] =>
[PERMISSION_MANAGE_REGISTRATION] =>
[PERMISSION_SORT_ROLES] =>
[PERMISSION_ADD_ROLES] =>
[PERMISSION_EDIT_ROLES] =>
[PERMISSION_REMOVE_ROLES] =>
[PERMISSION_CHECK_FOR_UPDATES] =>
[PERMISSION_CHANGE_APPLICATION_SETTINGS] =>
[PERMISSION_MANAGE_EXTENSIONS] =>
[PERMISSION_MANAGE_LANGUAGE] =>
[PERMISSION_MANAGE_THEMES] => 0
[PERMISSION_MANAGE_STYLES] =>
[PERMISSION_ALLOW_DEBUG_INFO] =>
[PERMISSION_ADD_ATTACHMENTS] => 0
[PERMISSION_MANAGE_ATTACHMENTS] => 0
[PERMISSION_REMOVE_COMMENTS] => 0
[PERMISSION_REMOVE_OWN_COMMENTS] => 0
[PERMISSION_USE_OFFLINE_FORUM] => 0
[PERMISSION_DATABASE_CLEANUP] => )
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/username/public_html/domain/support/library/People/People.Class.Role.php on line 78
line 78 is:
$this->Permissions['PERMISSION_SIGN_IN'] = $this->PERMISSION_SIGN_IN;
Edit: Had to change echo 'Temp Permissions from Database: " to echo "Temp Permissions from Database: " to fix parse error.
--------------------------------------
Temp Permissions from Database: a:39:{s:23:"PERMISSION_ADD_COMMENTS";i:1;s:27:"PERMISSION_START_DISCUSSION";i:1;s:27:"PERMISSION_SINK_DISCUSSIONS";i:1;s:28:"PERMISSION_STICK_DISCUSSIONS";i:1;s:27:"PERMISSION_HIDE_DISCUSSIONS";i:1;s:28:"PERMISSION_CLOSE_DISCUSSIONS";i:1;s:27:"PERMISSION_EDIT_DISCUSSIONS";i:1;s:34:"PERMISSION_VIEW_HIDDEN_DISCUSSIONS";i:1;s:24:"PERMISSION_EDIT_COMMENTS";i:1;s:24:"PERMISSION_HIDE_COMMENTS";i:1;s:31:"PERMISSION_VIEW_HIDDEN_COMMENTS";i:1;s:44:"PERMISSION_ADD_COMMENTS_TO_CLOSED_DISCUSSION";i:1;s:25:"PERMISSION_ADD_CATEGORIES";i:1;s:26:"PERMISSION_EDIT_CATEGORIES";i:1;s:28:"PERMISSION_REMOVE_CATEGORIES";i:1;s:26:"PERMISSION_SORT_CATEGORIES";i:1;s:28:"PERMISSION_VIEW_ALL_WHISPERS";i:1;s:29:"PERMISSION_APPROVE_APPLICANTS";i:1;s:27:"PERMISSION_CHANGE_USER_ROLE";i:1;s:21:"PERMISSION_EDIT_USERS";i:1;s:31:"PERMISSION_IP_ADDRESSES_VISIBLE";i:1;s:30:"PERMISSION_MANAGE_REGISTRATION";i:1;s:21:"PERMISSION_SORT_ROLES";i:1;s:20:"PERMISSION_ADD_ROLES";i:1;s:21:"PERMISSION_EDIT_ROLES";i:1;s:23:"PERMISSION_REMOVE_ROLES";i:1;s:28:"PERMISSION_CHECK_FOR_UPDATES";i:1;s:38:"PERMISSION_CHANGE_APPLICATION_SETTINGS";i:1;s:28:"PERMISSION_MANAGE_EXTENSIONS";i:1;s:26:"PERMISSION_MANAGE_LANGUAGE";i:1;s:24:"PERMISSION_MANAGE_THEMES";i:1;s:24:"PERMISSION_MANAGE_STYLES";i:1;s:27:"PERMISSION_ALLOW_DEBUG_INFO";i:1;s:26:"PERMISSION_ADD_ATTACHMENTS";i:1;s:29:"PERMISSION_MANAGE_ATTACHMENTS";i:1;s:26:"PERMISSION_REMOVE_COMMENTS";i:1;s:30:"PERMISSION_REMOVE_OWN_COMMENTS";i:1;s:28:"PERMISSION_USE_OFFLINE_FORUM";i:1;s:27:"PERMISSION_DATABASE_CLEANUP";i:1;}
Administrator
Temp Permissions from Database: a:33:{s:23:"PERMISSION_ADD_COMMENTS";i:1;s:27:"PERMISSION_START_DISCUSSION";i:1;s:27:"PERMISSION_SINK_DISCUSSIONS";i:1;s:28:"PERMISSION_STICK_DISCUSSIONS";N;s:27:"PERMISSION_HIDE_DISCUSSIONS";N;s:28:"PERMISSION_CLOSE_DISCUSSIONS";N;s:27:"PERMISSION_EDIT_DISCUSSIONS";N;s:34:"PERMISSION_VIEW_HIDDEN_DISCUSSIONS";N;s:24:"PERMISSION_EDIT_COMMENTS";N;s:24:"PERMISSION_HIDE_COMMENTS";N;s:31:"PERMISSION_VIEW_HIDDEN_COMMENTS";N;s:44:"PERMISSION_ADD_COMMENTS_TO_CLOSED_DISCUSSION";N;s:25:"PERMISSION_ADD_CATEGORIES";N;s:26:"PERMISSION_EDIT_CATEGORIES";N;s:28:"PERMISSION_REMOVE_CATEGORIES";N;s:26:"PERMISSION_SORT_CATEGORIES";N;s:28:"PERMISSION_VIEW_ALL_WHISPERS";N;s:29:"PERMISSION_APPROVE_APPLICANTS";N;s:27:"PERMISSION_CHANGE_USER_ROLE";N;s:21:"PERMISSION_EDIT_USERS";N;s:31:"PERMISSION_IP_ADDRESSES_VISIBLE";N;s:30:"PERMISSION_MANAGE_REGISTRATION";N;s:21:"PERMISSION_SORT_ROLES";N;s:20:"PERMISSION_ADD_ROLES";N;s:21:"PERMISSION_EDIT_ROLES";N;s:23:"PERMISSION_REMOVE_ROLES";N;s:28:"PERMISSION_CHECK_FOR_UPDATES";N;s:38:"PERMISSION_CHANGE_APPLICATION_SETTINGS";N;s:28:"PERMISSION_MANAGE_EXTENSIONS";N;s:26:"PERMISSION_MANAGE_LANGUAGE";N;s:24:"PERMISSION_MANAGE_STYLES";N;s:27:"PERMISSION_ALLOW_DEBUG_INFO";N;s:27:"PERMISSION_DATABASE_CLEANUP";N;}
Member
Temp Permissions from Database: a:32:{s:23:"PERMISSION_ADD_COMMENTS";N;s:27:"PERMISSION_START_DISCUSSION";N;s:28:"PERMISSION_STICK_DISCUSSIONS";N;s:27:"PERMISSION_HIDE_DISCUSSIONS";N;s:28:"PERMISSION_CLOSE_DISCUSSIONS";N;s:27:"PERMISSION_EDIT_DISCUSSIONS";N;s:34:"PERMISSION_VIEW_HIDDEN_DISCUSSIONS";N;s:24:"PERMISSION_EDIT_COMMENTS";N;s:24:"PERMISSION_HIDE_COMMENTS";N;s:31:"PERMISSION_VIEW_HIDDEN_COMMENTS";N;s:44:"PERMISSION_ADD_COMMENTS_TO_CLOSED_DISCUSSION";N;s:25:"PERMISSION_ADD_CATEGORIES";N;s:26:"PERMISSION_EDIT_CATEGORIES";N;s:28:"PERMISSION_REMOVE_CATEGORIES";N;s:26:"PERMISSION_SORT_CATEGORIES";N;s:28:"PERMISSION_VIEW_ALL_WHISPERS";N;s:29:"PERMISSION_APPROVE_APPLICANTS";N;s:27:"PERMISSION_CHANGE_USER_ROLE";N;s:21:"PERMISSION_EDIT_USERS";N;s:31:"PERMISSION_IP_ADDRESSES_VISIBLE";N;s:30:"PERMISSION_MANAGE_REGISTRATION";N;s:21:"PERMISSION_SORT_ROLES";N;s:20:"PERMISSION_ADD_ROLES";N;s:21:"PERMISSION_EDIT_ROLES";N;s:23:"PERMISSION_REMOVE_ROLES";N;s:28:"PERMISSION_CHECK_FOR_UPDATES";N;s:38:"PERMISSION_CHANGE_APPLICATION_SETTINGS";N;s:28:"PERMISSION_MANAGE_EXTENSIONS";N;s:26:"PERMISSION_MANAGE_LANGUAGE";N;s:24:"PERMISSION_MANAGE_STYLES";N;s:27:"PERMISSION_ALLOW_DEBUG_INFO";N;s:27:"PERMISSION_DATABASE_CLEANUP";N;}
Unauthenticated
Temp Permissions from Database: a:32:{s:23:"PERMISSION_ADD_COMMENTS";N;s:27:"PERMISSION_START_DISCUSSION";N;s:28:"PERMISSION_STICK_DISCUSSIONS";N;s:27:"PERMISSION_HIDE_DISCUSSIONS";N;s:28:"PERMISSION_CLOSE_DISCUSSIONS";N;s:27:"PERMISSION_EDIT_DISCUSSIONS";N;s:34:"PERMISSION_VIEW_HIDDEN_DISCUSSIONS";N;s:24:"PERMISSION_EDIT_COMMENTS";N;s:24:"PERMISSION_HIDE_COMMENTS";N;s:31:"PERMISSION_VIEW_HIDDEN_COMMENTS";N;s:44:"PERMISSION_ADD_COMMENTS_TO_CLOSED_DISCUSSION";N;s:25:"PERMISSION_ADD_CATEGORIES";N;s:26:"PERMISSION_EDIT_CATEGORIES";N;s:28:"PERMISSION_REMOVE_CATEGORIES";N;s:26:"PERMISSION_SORT_CATEGORIES";N;s:28:"PERMISSION_VIEW_ALL_WHISPERS";N;s:29:"PERMISSION_APPROVE_APPLICANTS";N;s:27:"PERMISSION_CHANGE_USER_ROLE";N;s:21:"PERMISSION_EDIT_USERS";N;s:31:"PERMISSION_IP_ADDRESSES_VISIBLE";N;s:30:"PERMISSION_MANAGE_REGISTRATION";N;s:21:"PERMISSION_SORT_ROLES";N;s:20:"PERMISSION_ADD_ROLES";N;s:21:"PERMISSION_EDIT_ROLES";N;s:23:"PERMISSION_REMOVE_ROLES";N;s:28:"PERMISSION_CHECK_FOR_UPDATES";N;s:38:"PERMISSION_CHANGE_APPLICATION_SETTINGS";N;s:28:"PERMISSION_MANAGE_EXTENSIONS";N;s:26:"PERMISSION_MANAGE_LANGUAGE";N;s:24:"PERMISSION_MANAGE_STYLES";N;s:27:"PERMISSION_ALLOW_DEBUG_INFO";N;s:27:"PERMISSION_DATABASE_CLEANUP";N;}
Banned
--------------------------------------
Just on the off-chance, the database collation is latin1_swedish_ci. Would that have anything to do with this error?