Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: Exception 'Attempt to read property "uid" on bool' thrown when using {canonicalUid} in preview target URL #12228

Closed
mmikkel opened this issue Oct 31, 2022 · 2 comments · Fixed by #12229
Assignees

Comments

@mmikkel
Copy link
Contributor

mmikkel commented Oct 31, 2022

What happened?

Description

We've got a headless, multi-site install, with two sites (sites A and B) and a section that has the "Let each entry choose..." propagation setting. This section has one custom preview target, with a {canonicalUid} token in its URL format.

After adding a new site B version for an existing entry in site A (via the "Add a site.." button), if the author switches to that new site entry without first re-saving/applying changes for the existing entry, an exception Attempt to read property "uid" on bool is thrown:

CleanShot 2022-10-31 at 13 22 18

Full stack trace is here.

The site B version remains inaccessible due to this error, until the original site A entry is manually re-saved.

As evident from the stack trace, the culprit seems to be the use of canonicalUid in the section's preview target URL. Indeed, if we remove canonicalUid from the preview target URL, the exception goes away.

Steps to reproduce

  1. Create two sites, and a section enabled for both of them, with the "Let each entry choose..." propagation setting
  2. Add a preview target to the section, that includes a canonicalUid token (e.g. something like https://awesome-web-app.io/entry/{canonicalUid}
  3. Create an entry in the section, and save/publish it.
  4. Click the "Add a site..." button, and create a site version for the second site.
  5. Without manually re-saving the current entry (i.e. it should now display "Showing your unsaved changes"), switch to the newly created site version via the site/revision dropdown at the top of the page.

Expected behavior

It should be possible to use canonicalUid in preview target URLs without having to manually re-save/apply changes to existing entries, after adding new site entries.

Actual behavior

Exception is thrown :(

Craft CMS version

4.3.1 PRO

PHP version

8.1.11

Operating system and version

macOS 12.6

Database type and version

10.8.3-MariaDB

Image driver and version

No response

Installed plugins and versions

None

@brandonkelly
Copy link
Member

Thanks for reporting that! Fixed for the next release via #12229.

@brandonkelly
Copy link
Member

Craft 4.3.2 is out with that fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants