Skip to content

Commit

Permalink
Backport a48f008
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jan 3, 2024
1 parent dec1a8f commit 1f31166
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Craft CMS 3.x

## Unreleased

- Fixed a bug where `craft\web\Request::getIsPreview()` was returning `true` for requests with expired tokens. ([#14066](https://github.com/craftcms/cms/discussions/14066))

## 3.9.10 - 2024-01-02

- Fixed a bug where meta fields weren’t immediately showing change indicators when entries were autosaved.
Expand Down
6 changes: 5 additions & 1 deletion src/web/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,11 @@ public function getActionSegments()
*/
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)
);
}

/**
Expand Down

0 comments on commit 1f31166

Please sign in to comment.