diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b3d917bdca..c63a955a8d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - `craft\services\Security::$sensitiveKeywords` is no longer case-sensitive. ([#14064](https://github.com/craftcms/cms/discussions/14064)) - Fixed a bug where the `index-assets/cleanup` command accepted `--cache-remote-images`, `--create-missing-assets`, and `--delete-missing-assets` options, even though they didn’t do anything. - Fixed a bug where automatically-created relations could be lost when a new site was added to an entry. ([#14065](https://github.com/craftcms/cms/issues/14065)) +- Fixed a bug where `craft\web\Request::getIsPreview()` was returning `true` for requests with expired tokens. ([#14066](https://github.com/craftcms/cms/discussions/14066)) ## 4.5.13 - 2023-12-15 diff --git a/src/web/Request.php b/src/web/Request.php index 1e8dba0145a..7ecf672b05b 100644 --- a/src/web/Request.php +++ b/src/web/Request.php @@ -697,7 +697,11 @@ public function getActionSegments(): ?array */ public function getIsPreview(): bool { - return $this->getQueryParam('x-craft-preview') !== null || $this->getQueryParam('x-craft-live-preview') !== null; + return ( + ($this->getQueryParam('x-craft-preview') ?? $this->getQueryParam('x-craft-live-preview')) !== null && + // If there's a token but it expired, they're looking at the live site + (!$this->getHadToken() || $this->getToken() !== null) + ); } /**