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

[5.x] fix(Terms): getCreatables() throws an error if no user is authenticated. #10232

Closed
wants to merge 1 commit into from

Conversation

sbrow
Copy link

@sbrow sbrow commented May 30, 2024

What

This simple, one-character PR changes src/Fieldtypes/Terms so that it won't throw an error if no user is authenticated when getCreatables() is called.

Why

I originally raised this issue in duncanmcclean/simple-commerce#1076. In brief, the shop / products page for my store failed to work for unauthenticated users after adding a taxonomy field to the blueprint for product variations.

This issue stems from a Statamic\Fields\Field class being created and the meta() method being invoked on it.

Whether this is a misuse of the framework, or a bug therein, I leave for you to decide.

Personally, I don't see the harm in allowing getCreatables() to work when no user is authenticated, but let me know if I'm wrong.

I have an image here of the stack trace I encountered:

image

Let me know if there's anything else you need from me 😄

@duncanmcclean
Copy link
Member

Thanks for this pull request!

However, the fieldtype's preload method (which is what's calling the getCreatables method) shouldn't be getting called unless you're loading a publish form in the Control Panel, in which case there will be an authenticated user.

I haven't been able to look into the issue yet, but I imagine the fix will end up being on the Simple Commerce side.

@sbrow sbrow deleted the 5.x branch May 31, 2024 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants