statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.07k stars 530 forks source link

Breaking change in preview targets #9613

Closed aerni closed 5 months ago

aerni commented 8 months ago

Bug description

Turns out PR https://github.com/statamic/cms/pull/8742 was a breaking change for me. I've got a preview target that relies on data being augmented in the resolvePreviewTargetUrl method. Augmentation has been removed in that PR.

The seo_social_images_theme is a custom fieldtype wrapper that derives its default value from a subfield.

{site:permalink}/social-images/{seo_social_images_theme}/open_graph/{id}

The field is added to the blueprint on EntryBlueprintFound event. Augmentation made it possible to have the field return its default value even if the field's value hasn't been saved on the entry.

How to reproduce

This is happening as part of my Advanced SEO addon. So there are lots of moving parts and I don't quite know a good way to share how to reproduce this. I'm happy to whip up a basic repo that uses the addon so you can see it in action if that helps.

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 9.52.16
PHP Version: 8.3.3
Composer Version: 2.7.1
Environment: local
Debug Mode: ENABLED
URL: statamic-advanced-seo.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 1
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.44.0 PRO

Statamic Addons
aerni/advanced-seo: dev-fix/multisite

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

None

Additional details

No response

betty4920taylor commented 6 months ago

It sounds like PR #8742 introduced a breaking change for your setup, specifically affecting the preview target that relies on data augmentation in the resolvePreviewTargetUrl method. The removal of augmentation in that PR has impacted the functionality you rely on.

The seo_social_images_theme fieldtype wrapper, which derives its default value from a subfield, is also affected. This field is added to the blueprint on the EntryBlueprintFound event, and the augmentation previously allowed the field to return its default value even if the field's value hasn't been saved on the entry.

Regarding reproduction, given the complexity of your setup with the Advanced SEO addon, providing a basic repository using the addon could indeed help in understanding and reproducing the issue more effectively. Catlikesbest

Your environment details are comprehensive, which is helpful for understanding the context of the issue. If you encounter any additional details or updates, feel free to share them for further investigation.

Let me know if you need assistance in creating the repository or if there's anything else I can assist you with.

jackmcdade commented 6 months ago

@betty4920taylor Hi Ai!

aerni commented 5 months ago

While this is technically still a breaking change, I resolved my issue by augmenting the value of seo_social_images_theme before adding it to the preview targets instead of relying on the parsing of the variable in the resolvePreviewTargetUrl() of the Entry class.