Skip to content

Commit

Permalink
Merge pull request #51 from venveo/develop-v3
Browse files Browse the repository at this point in the history
Fix php warning from elements without URIs
  • Loading branch information
Mosnar authored Jul 14, 2022
2 parents 566f9ad + 44083a9 commit 73c44bc
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 @@
# Redirect Changelog

## 3.0.12 - 2022-07-14

### Fixed
- Fix warning generated by attempting to auto-create redirects on elements without URIs

## 3.0.11 - 2022-06-21

### 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": "venveo/craft-redirect",
"description": "Craft redirect plugin provides an easy way to enter and maintain 301 and 302 redirects and 404 error pages.",
"type": "craft-plugin",
"version": "3.0.11",
"version": "3.0.12",
"keywords": [
"craft",
"cms",
Expand Down
4 changes: 2 additions & 2 deletions src/services/Redirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function handleBeforeElementSaved(ElementEvent $e): void
static::$elementUrisChanging[$siteId] = [];
}
// Grab the current URI from the database and store it
$oldUri = Craft::$app->elements->getElementById($elementId, null, $siteId)->uri;
$oldUri = Craft::$app->elements->getElementById($elementId, null, $siteId)->uri ?? null;
if ($oldUri) {
static::$elementUrisChanging[$siteId][$elementId] = $oldUri;
}
Expand All @@ -209,7 +209,7 @@ public function handleAfterElementSaved(ElementEvent $e): void
$siteId = $savedElement->siteId;
$elementId = $savedElement->id;
$oldUri = static::$elementUrisChanging[$siteId][$elementId] ?? null;
$newUri = $savedElement->uri;
$newUri = $savedElement->uri ?? null;
// If there were no URI changes, let's bail
if (!$oldUri || !$newUri || $oldUri === $newUri) {
return;
Expand Down

0 comments on commit 73c44bc

Please sign in to comment.