Skip to content

Commit

Permalink
Fix bug when array is empty (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronbushnell authored Oct 28, 2020
1 parent 7fa4f95 commit 7a60106
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes for Isolate

## 1.4.2 - 2020-10-28

### Fixed
- 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))

## 1.4.1 - 2020-10-26

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "trendyminds/isolate",
"description": "Restrict your Craft CMS users on a per-entry basis",
"type": "craft-plugin",
"version": "1.4.1",
"version": "1.4.2",
"keywords": [
"permissions",
"entry permission",
Expand Down
4 changes: 2 additions & 2 deletions src/services/IsolateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public function verifyIsolatedUserAccess(int $userId, string $path)
$segments = Craft::$app->request->getSegments();

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

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

Expand Down

0 comments on commit 7a60106

Please sign in to comment.