Skip to content

Commit 75963e9

Browse files
committed
Fixed #196
1 parent 3fbcff8 commit 75963e9

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes for Element API
22

3+
## Unreleased
4+
5+
- Fixed an error that occurred if no cache tags were registered by an endpoint’s element query. ([#196](https://github.com/craftcms/element-api/issues/196))
6+
37
## 4.1.0 - 2024-03-14
48

59
- Element API now requires Craft 4.3.0+ or 5.0.0+.

src/controllers/DefaultController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use ReflectionFunction;
2626
use yii\base\InvalidConfigException;
2727
use yii\base\UserException;
28+
use yii\caching\TagDependency;
2829
use yii\web\HttpException;
2930
use yii\web\JsonResponseFormatter;
3031
use yii\web\Response;
@@ -234,6 +235,7 @@ public function actionIndex(string $pattern): Response
234235

235236
/** @phpstan-ignore-next-line */
236237
[$dep, $maxDuration] = $elementsService->stopCollectingCacheInfo();
238+
$dep ??= new TagDependency();
237239
$dep->tags[] = 'element-api';
238240

239241
if ($maxDuration) {

0 commit comments

Comments
 (0)