craftcms / craftcms/cms

If multi-site has a different domain per site, live preview crashes the system when used on a new, unsaved entry

Open
#7,782 10 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

Description

Our site has a different domain for each site:
https://www.thewriter.com/ - en-US
https://www.thewriter.co.uk/ - en-GB

Our admin is only accessible via https://www.thewriter.com/admin

We've discovered that if you create a brand new entry, with the site set to en-GB, and then click live preview, we get an internal server error. The admin then continues to bug out such as logging the user out regularly after that.

Steps to reproduce
  1. assign a different domain to two multi-sites
  2. access the admin from one multi-site but switch the site drop down the other inside the CMS.
  3. create a new entry assigned to that other site (whose domain is not the CMS domain), and click live preview without saving
Additional info
  • Craft version:Craft Pro 3.6.5.1
  • PHP version:8.0.2
  • Database driver & version:MySQL 8.0.20
  • Plugins & versions:
Logs

These are the two logs that seem relevant:

apache_access  108.162.229.250 - - [09/Apr/2021:13:06:28 +0000] "POST /index.php?p=admin/actions/preview/create-token HTTP/1.1" 403 1676 "https://www.thewriter.com/admin/entries/whitepapers/19097?site=default&draftId=201&fresh=1" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
apache_access  108.162.229.250 - - [09/Apr/2021:13:06:27 +0000] "POST /index.php?p=admin/actions/entry-revisions/save-draft HTTP/1.1" 200 1702 "https://www.thewriter.com/admin/entries/whitepapers/19097?site=default&draftId=201&fresh=1" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
apache_access  108.162.229.250 - - [09/Apr/2021:13:06:28 +0000] "POST /index.php?p=admin/actions/preview/create-token HTTP/1.1" 403 1676 "https://www.thewriter.com/admin/entries/whitepapers/19097?site=default&draftId=201&fresh=1" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"

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 failure with two multi-sites using different domains, switching the admin site, and opening live preview on a new unsaved entry. Start by tracing the admin/actions/preview/create-token and admin/actions/entry-revisions/save-draft requests against the supplied Apache logs. Done means live preview works for the unsaved entry without a 403, internal server error, or subsequent admin logout.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.