Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error editing/creating channels #3200

Open
10on12 opened this issue Apr 3, 2023 · 10 comments · Fixed by #3410
Open

Error editing/creating channels #3200

10on12 opened this issue Apr 3, 2023 · 10 comments · Fixed by #3410

Comments

@10on12
Copy link

10on12 commented Apr 3, 2023

Description of the problem

How To Reproduce
Steps to reproduce the behavior:

Error Messages

Warning

Invalid argument supplied for foreach()

ee/ExpressionEngine/Controller/Channels/Channels.php, line 1627

Severity: E_WARNING
Warning

Cannot modify header information - headers already sent by (output started at ee/legacy/core/Exceptions.php:120)

ee/legacy/core/Input.php, line 268

Severity: E_WARNING
Warning

Cannot modify header information - headers already sent by (output started at ee/legacy/core/Exceptions.php:120)

ee/legacy/libraries/Functions.php, line 458

Severity: E_WARNING



Screenshots / Videos / Template Code

Environment Details:

  • Version: [7.2.12]
  • PHP Version [e.g. 7.4]

Possible Solution

Additional context

@intoeetive
Copy link
Contributor

@10on12 so what are the Steps to reproduce the behavior?

@10on12
Copy link
Author

10on12 commented Apr 3, 2023

  • Clicking on a channel name to edit.
  • Click on "fields"
  • Save

I don't event have to try and add a new field or edit fields - simply hitting 'save' at tis point throws up this error.
All other installs working fine with regard to this – just this one is throwing up the error.

@intoeetive
Copy link
Contributor

@10on12 are you looked in as SuperAdmin user when saving channel, or as user in another role? If yes, what are the role's permissions?

@10on12
Copy link
Author

10on12 commented Apr 3, 2023

Superadmin

@intoeetive
Copy link
Contributor

@10on12 I have an impression that your installation got broken. Can you visit the Roles page in CP and confirm that you have Members role with ID 5?

@10on12
Copy link
Author

10on12 commented Apr 4, 2023

There is no ID5.

@intoeetive
Copy link
Contributor

Thank you, that is good to know.

I assume that is installation that was updated from some older version?

Do you know how that role was deleted? ExpressionEngine does not allow deleting built-in roles currently (and currently here stands for at least several years...)

@10on12
Copy link
Author

10on12 commented Apr 4, 2023

As far as I can recall this was old V1 of Expression Engine of PMachine possibly.

No idea how that was deleted - no idea if it ever existed as it's a feature I haven't used on this site.

What's your advice? Restore and reinstall the update?

S

@intoeetive
Copy link
Contributor

EE expects that you have all built-in roles from 1 to 5.
Reinstalling the update will not help if those were missing.

This is the block in installer that is responsible for creating those:

// Roles
$roles = array(
array(
'name' => 'Super Admin',
'short_name' => 'super_admin',
'role_id' => 1,
'is_locked' => 'y',
'exclude_from_moderation' => 'y',
'include_in_authorlist' => 'y',
'search_flood_control' => '0'
),
array(
'name' => 'Banned',
'short_name' => 'banned',
'role_id' => 2,
'is_locked' => 'n',
'include_in_memberlist' => 'n',
'search_flood_control' => '60'
),
array(
'name' => 'Guests',
'short_name' => 'guests',
'role_id' => 3,
'is_locked' => 'n',
'search_flood_control' => '10'
),
array(
'name' => 'Pending',
'short_name' => 'pending',
'role_id' => 4,
'is_locked' => 'n',
'search_flood_control' => '10'
),
array(
'name' => 'Members',
'short_name' => 'members',
'role_id' => 5,
'is_locked' => 'n',
'search_flood_control' => '10'
)
);
$add_quotes = function ($value) {
return (is_string($value)) ? "'{$value}'" : $value;
};
foreach ($roles as $role) {
$Q[] = "INSERT INTO exp_roles
(role_id, name, short_name, is_locked)
VALUES (" . $role['role_id'] . ", '" . $role['name'] . "', '" . $role['short_name'] . "', '" . $role['is_locked'] . "')";
unset($role['name']);
unset($role['short_name']);
unset($role['is_locked']);
$Q[] = "INSERT INTO exp_role_settings
(" . implode(', ', array_keys($role)) . ")
VALUES (" . implode(', ', array_map($add_quotes, $role)) . ")";
}
$role_permissions = [
1 => [
'can_view_offline_system',
'can_access_cp',
'can_access_dock',
'can_access_footer_report_bug',
'can_access_footer_new_ticket',
'can_access_footer_user_guide',
'can_view_homepage_news',
'can_upload_new_files',
'can_edit_files',
'can_delete_files',
'can_upload_new_toolsets',
'can_edit_toolsets',
'can_delete_toolsets',
'can_create_upload_directories',
'can_edit_upload_directories',
'can_delete_upload_directories',
'can_access_files',
'can_access_design',
'can_access_addons',
'can_access_members',
'can_access_sys_prefs',
'can_access_comm',
'can_access_utilities',
'can_access_data',
'can_access_logs',
'can_admin_channels',
'can_create_channels',
'can_edit_channels',
'can_delete_channels',
'can_create_channel_fields',
'can_edit_channel_fields',
'can_delete_channel_fields',
'can_create_statuses',
'can_delete_statuses',
'can_edit_statuses',
'can_create_categories',
'can_create_roles',
'can_delete_roles',
'can_edit_roles',
'can_admin_design',
'can_create_members',
'can_edit_members',
'can_delete_members',
'can_admin_roles',
'can_admin_mbr_templates',
'can_ban_users',
'can_admin_addons',
'can_create_templates',
'can_edit_templates',
'can_delete_templates',
'can_create_template_groups',
'can_edit_template_groups',
'can_delete_template_groups',
'can_create_template_partials',
'can_edit_template_partials',
'can_delete_template_partials',
'can_create_template_variables',
'can_delete_template_variables',
'can_edit_template_variables',
'can_edit_categories',
'can_delete_categories',
'can_view_other_entries',
'can_edit_other_entries',
'can_assign_post_authors',
'can_delete_self_entries',
'can_delete_all_entries',
'can_view_other_comments',
'can_edit_own_comments',
'can_delete_own_comments',
'can_edit_all_comments',
'can_delete_all_comments',
'can_moderate_comments',
'can_send_cached_email',
'can_email_roles',
'can_email_from_profile',
'can_view_profiles',
'can_edit_html_buttons',
'can_post_comments',
'can_delete_self',
'can_send_private_messages',
'can_attach_in_private_messages',
'can_send_bulletins',
'can_search',
'can_create_entries',
'can_edit_self_entries',
'can_access_security_settings',
'can_access_translate',
'can_access_import',
'can_access_sql_manager',
'can_moderate_spam',
'can_manage_consents',
],
3 => [
'can_view_online_system',
],
4 => [
'can_view_online_system',
],
5 => [
'can_view_online_system',
'can_email_from_profile',
'can_view_profiles',
'can_edit_html_buttons',
'can_delete_self',
'can_send_private_messages',
'can_attach_in_private_messages',
]
];
foreach ($role_permissions as $role_id => $permissions) {
foreach ($permissions as $permission) {
$Q[] = "INSERT INTO exp_permissions (site_id, role_id, permission) VALUES(1, $role_id, '$permission')";
}
}
// default statuses - these are really always needed
$Q[] = "INSERT INTO exp_statuses (status, status_order, highlight) VALUES ('open', '1', '009933')";
$Q[] = "INSERT INTO exp_statuses (status, status_order, highlight) VALUES ('closed', '2', '990000')";
$Q[] = "INSERT INTO exp_statuses_roles (role_id, status_id) VALUES ('5', '1'), ('5', '2')";

ATM I can only suggest that you manually go through the lines, compare with your database and add what is missing

@10on12
Copy link
Author

10on12 commented Apr 4, 2023

I'll look at that.
Appreciate your help.

S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants