craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.22k stars 627 forks source link

[4.x]: Live-Preview link generates token, even there is no update #13746

Closed vandres closed 11 months ago

vandres commented 12 months ago

What happened?

Description

I think, this is a weird one. One of our editors complained, that some preview links he can just copy and paste. Others have a token and he has to manually edit them.

This is a CMS page, which works "as expected"

grafik

This is a Blog post, which always adds a token

grafik

Is there any way to configure this? The CMS page entry type was create with an older version of Craft 4.0, if I recall correctly. The Blog post entry type was created with Craft 4.4 or 4.5

Steps to reproduce

  1. I don't kno how to reproduce that

Expected behavior

Links don't add a token, if there is no change

Actual behavior

Links always have a preview token.

Craft CMS version

4.5.5

PHP version

8.2

Operating system and version

CentOS

Database type and version

MariaDB 10.5

Image driver and version

-

Installed plugins and versions

  "require": {
    "carlcs/craft-footnote": "^3.0",
    "craftcms/cms": "^4.3.8",
    "craftcms/commerce": "^4.1.0",
    "craftcms/commerce-paypal-checkout": "dev-develop",
    "craftcms/contact-form": "^3.0",
    "craftcms/contact-form-honeypot": "^2.0",
    "craftcms/redactor": "^3.0",
    "mmikkel/cp-field-inspect": "^1.4",
    "nystudio107/craft-retour": "^4.1",
    "nystudio107/craft-vite": "^4.0",
    "php-http/curl-client": "^2.2",
    "putyourlightson/craft-campaign": "^2.7",
    "putyourlightson/craft-elements-panel": "^2.0",
    "putyourlightson/craft-sprig": "^2.1",
    "sebastianlenz/linkfield": "^2.1",
    "spatie/craft-ray": "^2.0",
    "spicyweb/craft-neo": "^3.2",
    "ttempleton/craft-nocache": "^3.0",
    "typesense/typesense-php": "^4.8",
    "vaersaagod/geomate": "^2.1.0",
    "verbb/expanded-singles": "^2.0",
    "verbb/field-manager": "^3.0",
    "verbb/tablemaker": "^4.0",
    "verbb/wishlist": "^2.0",
    "vlucas/phpdotenv": "^5.4.0",
    "wbrowar/adminbar": "^3.2",
    "webburospring/craft-spring-pixabay": "^1.2"
  },
brandonkelly commented 12 months ago

A token is needed if any of these are true:

Any of those the case here?

vandres commented 12 months ago

No, not really. There might be one thing. This entry type is not allowed/used on the primary site.

grafik

brandonkelly commented 12 months ago

Hm, just tested that same scenario and the “View” button is getting hyperlinked as expected:

Screenshot of an entry edit page, showing that the View button has a hyperlink, and the entry is only enabled for an alternate site.

brandonkelly commented 12 months ago

Your entry’s Post Date is 10.05.23. What formatting locale is that using? Does that mean October 5, 2023, or May 10, 2023?

vandres commented 12 months ago

It's the German format for 10. of May.

vandres commented 12 months ago

Changed it to a date in 2022, just to be sure. No change

vandres commented 12 months ago

@brandonkelly Back to my first theory. I enabled the Blog entry type now for the primary site. Suddenly the preview links are "correct"

grafik

rickmerkelbach commented 11 months ago

Hi there, I've run into the same issue on a project that we're preparing to upgrade to Craft 4. Both 3.9.4 and 4.5.6 seem to be affected by this issue.

After saving and publishing an entry in a section that is only available on a specific site (other than the main site), the "View" link always generates an expiring token link. Enabling that section on the main site seems to fix this, it now shows the correct live URL.

@vandres thank you for sharing this workaround!

brandonkelly commented 11 months ago

@i-just figured out how to reproduce, and it’s now fixed for the next release via #13822 🎉

brandonkelly commented 11 months ago

Craft 4.5.7 is out now with the fix for this. Thanks again for reporting!