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.
This commit is contained in:
Alexander Guth 2017-12-31 18:03:07 +01:00 committed by Luke Towers
parent 69e56b0b5b
commit 1389f77390
1 changed files with 1 additions and 1 deletions

View File

@ -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;