craftcms / craftcms/cms

[5.x]: Live preview not working with disabled site

Open
#17,308 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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
  1. disable a site
  2. live preview an entry from this site that uses a entry query with .language(craft.app.language)
Expected behavior
  1. previewing an entry of an unpublished site should be possible
Actual behavior
  1. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.