[5.x]: Live preview not working with disabled site
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
What happened?
Description
When a site is globally disabled in the settings → sites
the live preview function in the CP produces an error when previewing an entry from the disabled site with a twig template that uses
.language(craft.app.language)
full query is {% set entryQuery = craft.entries().site('*').language(craft.app.language).section('section') %}
The error is "Invalid Argument Invalid site: 5"
Steps to reproduce
- disable a site
- live preview an entry from this site that uses a entry query with
.language(craft.app.language)
Expected behavior
- previewing an entry of an unpublished site should be possible
Actual behavior
- not possible to see the preview
Craft CMS version
5.7.6
PHP version
8.4
Operating system and version
No response
Database type and version
Mysql 8.0
Image driver and version
No response
Installed plugins and versions
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue by disabling a site and opening live preview for an entry whose Twig template queries entries with site('*').language(craft.app.language). Trace the live-preview handling of the disabled site's ID and the resulting “Invalid site: 5” error. Done means the entry preview renders successfully while the site remains disabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100