From 1389f7739099d8d579efacef7fa894778b4098b8 Mon Sep 17 00:00:00 2001 From: Alexander Guth Date: Sun, 31 Dec 2017 18:03:07 +0100 Subject: [PATCH] Fix 'illegal string offset' warning (#3331) Credit to @alxy In case a new administrator is created by a non-superuser and no permission is set directly on creation, `permissions` is not initialized correctly. Thus, when the non-superuser tries to acceess `$this->model->permissions` it is not populated with an empty array as expected. I have actually no clue why it does work for superusers however, as they should certainly experience the same issue, but this is not the case. --- modules/backend/formwidgets/PermissionEditor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/backend/formwidgets/PermissionEditor.php b/modules/backend/formwidgets/PermissionEditor.php index de2d75c6a..014e523b3 100644 --- a/modules/backend/formwidgets/PermissionEditor.php +++ b/modules/backend/formwidgets/PermissionEditor.php @@ -96,7 +96,7 @@ class PermissionEditor extends FormWidgetBase $newPermissions = is_array($value) ? array_map('intval', $value) : []; if (!empty($newPermissions)) { - $existingPermissions = $this->model->permissions; + $existingPermissions = $this->model->permissions ?: []; $allowedPermissions = array_map(function ($permissionObject) { return $permissionObject->code;