diff --git a/system/src/Grav/Framework/Acl/Access.php b/system/src/Grav/Framework/Acl/Access.php index 771d58e2f..0a6bb4102 100644 --- a/system/src/Grav/Framework/Acl/Access.php +++ b/system/src/Grav/Framework/Acl/Access.php @@ -14,7 +14,6 @@ use Countable; use Grav\Common\Utils; use IteratorAggregate; use JsonSerializable; -use RuntimeException; use Traversable; use function count; use function is_array; @@ -79,12 +78,7 @@ class Access implements JsonSerializable, IteratorAggregate, Countable $inherited = array_diff_key($parent->getAllActions(), $acl); $this->inherited += $parent->inherited + array_fill_keys(array_keys($inherited), $name ?? $parent->getName()); - $acl = array_replace($acl, $inherited); - if (null === $acl) { - throw new RuntimeException('Internal error'); - } - - $this->acl = $acl; + $this->acl = array_replace($acl, $inherited); } /** diff --git a/system/src/Grav/Framework/Acl/Action.php b/system/src/Grav/Framework/Acl/Action.php index 704f61e0d..ee46f55f9 100644 --- a/system/src/Grav/Framework/Acl/Action.php +++ b/system/src/Grav/Framework/Acl/Action.php @@ -16,7 +16,6 @@ use IteratorAggregate; use RuntimeException; use Traversable; use function count; -use function strlen; /** * Class Action @@ -49,8 +48,8 @@ class Action implements IteratorAggregate, Countable { $label = $action['label'] ?? null; if (!$label) { - if ($pos = strrpos($name, '.')) { - $label = substr($name, $pos + 1); + if ($pos = mb_strrpos($name, '.')) { + $label = mb_substr($name, $pos + 1); } else { $label = $name; } @@ -115,9 +114,9 @@ class Action implements IteratorAggregate, Countable */ public function getScope(): string { - $pos = strpos($this->name, '.'); + $pos = mb_strpos($this->name, '.'); if ($pos) { - return substr($this->name, 0, $pos); + return mb_substr($this->name, 0, $pos); } return $this->name; @@ -128,7 +127,7 @@ class Action implements IteratorAggregate, Countable */ public function getLevels(): int { - return substr_count($this->name, '.'); + return mb_substr_count($this->name, '.'); } /** @@ -162,12 +161,12 @@ class Action implements IteratorAggregate, Countable */ public function addChild(Action $child): void { - if (strpos($child->name, "{$this->name}.") !== 0) { + if (mb_strpos($child->name, "{$this->name}.") !== 0) { throw new RuntimeException('Bad child'); } $child->setParent($this); - $name = substr($child->name, strlen($this->name) + 1); + $name = mb_substr($child->name, mb_strlen($this->name) + 1); $this->children[$name] = $child; } diff --git a/system/src/Grav/Framework/Acl/Permissions.php b/system/src/Grav/Framework/Acl/Permissions.php index 1494b10e1..83c6179ea 100644 --- a/system/src/Grav/Framework/Acl/Permissions.php +++ b/system/src/Grav/Framework/Acl/Permissions.php @@ -148,9 +148,6 @@ class Permissions implements ArrayAccess, Countable, IteratorAggregate public function addTypes(array $types): void { $types = array_replace($this->types, $types); - if (null === $types) { - throw new RuntimeException('Internal error'); - } $this->types = $types; } diff --git a/system/src/Grav/Framework/Acl/PermissionsReader.php b/system/src/Grav/Framework/Acl/PermissionsReader.php index 882050216..5e8e892bb 100644 --- a/system/src/Grav/Framework/Acl/PermissionsReader.php +++ b/system/src/Grav/Framework/Acl/PermissionsReader.php @@ -174,9 +174,6 @@ class PermissionsReader $scopes[] = $action; $action = array_replace_recursive(...$scopes); - if (null === $action) { - throw new RuntimeException('Internal error'); - } $newType = $defaults['type'] ?? null; if ($newType && $newType !== $type) {