Description
If x-craft-live-preview parameter is present in request and cache is present in element-api config for endpoint, the element api request results in an server error with the following log message:
[error][craft\elementapi\controllers\DefaultController::actionIndex] Error resolving Element API endpoint: Setting unknown property: craft\elementapi\resources\ElementResource::cache
This in src/DefaultController.php seems to be the problem:
// Before anything else, check the cache
if (!($this->request->getIsPreview() || $this->request->getIsLivePreview())) {
$cache = ArrayHelper::remove($config, 'cache', true);
} else {
$cache = false;
}
cache should probably always be removed from $config. The error was introduced in commit fb92fef
Steps to reproduce
cache must be present in element-api config for endpoint
- Call element api endpoint with
x-craft-live-preview parameter present in url
Additional info
- Craft CMS version: 3.7.20
- Element API version: 2.8.3
- PHP version: 8.0.10
- Database driver & version: 8.0.27
- Plugins & versions:
- Amazon S3 1.3.0
- Control Panel CSS 2.4.0
- Element API 2.8.3
- Enforce password 1.0.4.2
- Logs 3.0.4
- Neo 2.11.17
- Redactor 2.8.8
- Redactor Anchors 1.1.0
- Restrict 2.0.3
- Sentry Logger 1.1.7
- Typed link field 1.0.25
Description
If
x-craft-live-previewparameter is present in request andcacheis present inelement-api config for endpoint, the element api request results in an server error with the following log message:[error][craft\elementapi\controllers\DefaultController::actionIndex] Error resolving Element API endpoint: Setting unknown property: craft\elementapi\resources\ElementResource::cacheThis in
src/DefaultController.phpseems to be the problem:cacheshould probably always be removed from$config. The error was introduced in commitfb92fefSteps to reproduce
cachemust be present inelement-api configfor endpointx-craft-live-previewparameter present in urlAdditional info