Skip to content

Commit 7a60106

Browse files
Fix bug when array is empty (#25)
1 parent 7fa4f95 commit 7a60106

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes for Isolate
22

3+
## 1.4.2 - 2020-10-28
4+
5+
### Fixed
6+
- Fix error that occurred if an Isolated user is accessing the control panel homepage and `$segments` contains no array items. ([#24](https://github.com/trendyminds/isolate/pull/24))
7+
38
## 1.4.1 - 2020-10-26
49

510
### Fixed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "trendyminds/isolate",
33
"description": "Restrict your Craft CMS users on a per-entry basis",
44
"type": "craft-plugin",
5-
"version": "1.4.1",
5+
"version": "1.4.2",
66
"keywords": [
77
"permissions",
88
"entry permission",

src/services/IsolateService.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public function verifyIsolatedUserAccess(int $userId, string $path)
380380
$segments = Craft::$app->request->getSegments();
381381

382382
// If a user is attempting to edit a specific entry (but not create a new one)
383-
if ($segments[0] === "entries" && isset($segments[2]) && (!Craft::$app->request->getParam('fresh') && $segments[2] !== "new"))
383+
if (count($segments) && $segments[0] === "entries" && isset($segments[2]) && (!Craft::$app->request->getParam('fresh') && $segments[2] !== "new"))
384384
{
385385
// Get the ID of the entry a user is accessing
386386
preg_match("/^\d*/", $segments[2], $matches);
@@ -397,7 +397,7 @@ public function verifyIsolatedUserAccess(int $userId, string $path)
397397

398398
// Deny isolated user access to the entries area by redirecting back to dashboard
399399
// Redirecting because saving an entry often takes a user back to the entries listing
400-
if ($segments[0] === "entries" && !isset($segments[2]))
400+
if (count($segments) && $segments[0] === "entries" && !isset($segments[2]))
401401
{
402402
$url = "isolate";
403403

0 commit comments

Comments
 (0)