Skip to content

Commit

Permalink
When caching was enabled but the relation fetching is not finished ye…
Browse files Browse the repository at this point in the history
…t, an exception got thrown. #31
  • Loading branch information
internetztube committed Jan 26, 2024
1 parent f6b7dc3 commit ba97b92
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.0.3 - 2024-01-26
### Fixed
When caching is enabled but the relation fetching is not finished yet, an exception got thrown. [#31](https://github.com/internetztube/craft-element-relations/issues/31)

## 2.0.2 - 2022-09-01
### Fixed
Fix error, if entry doesn't exist in primary site. Thank you, [@sfsmfc](https://github.com/sfsmfc)! [#28](https://github.com/internetztube/craft-element-relations/pull/28)
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": "internetztube/craft-element-relations",
"description": "Shows all relations of an element.",
"type": "craft-plugin",
"version": "2.0.2",
"version": "2.0.3",
"keywords": [
"craft",
"cms",
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/ElementRelationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function actionGetByElementId(): string
$markup = MarkupService::getMarkupFromElementRelations($elementRelations, $elementId, $siteId);
$result = $markup;
if (CacheService::useCache()) {
$dateUpdated = CacheService::getDateUpdatedFromElementRelations($elementId);
$dateUpdated = CacheService::getDateUpdatedFromElementRelations($elementId) ?? time();
$dateUpdated = DateTimeHelper::toDateTime($dateUpdated)
->setTimezone(new \DateTimeZone(Craft::$app->getTimeZone()))
->format(Craft::$app->getFormattingLocale()->getDateTimeFormat(Locale::LENGTH_LONG, Locale::FORMAT_PHP));
Expand Down

0 comments on commit ba97b92

Please sign in to comment.