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

Knowledge Base: Reserved Words #236

Closed
sjclark opened this issue Sep 16, 2020 · 13 comments
Closed

Knowledge Base: Reserved Words #236

sjclark opened this issue Sep 16, 2020 · 13 comments

Comments

@sjclark
Copy link
Contributor

sjclark commented Sep 16, 2020

Seems with V3 theres a few more people having issues with accidentally using reserved words - leading to difficult to diagnose issues. I thought it might be good to have a list of reserved words in the docs? Not sure of the best way to structure this - or it might be better integrated as a running list of terms to prevent being validated/used in the admin. Or used as a list to generate more verbose errors in common contexts.

Theres been mention from @robdekort @damcclean @edalzell and @jasonvarga (on chat / forum / issues) that this should be documented somewhere.

Wildly imperfect list (primarily of restricted field names) from the issues I've seen recently:
Haven't had a chance to find the context for some (assume 'as' is a parameter), and many are just tags names

Also:
https://www.php.net/manual/en/reserved.keywords.php

And all tags (I guess)?
https://statamic.dev/tags

Apologies for the lack of a strong format for this, just kept seeing mention that someone should do this. Totally understand it might not be possible due to these restricted words being very context-specific.

@duncanmcclean
Copy link
Member

I've also seen value pop up as a reserved word too. It causes issues when you try and grab a field in Antlers, likely because of augmentation.

@robdekort
Copy link
Contributor

Great job! Does laravel have reserved words?

@sjclark
Copy link
Contributor Author

sjclark commented Sep 16, 2020

Great job! Does laravel have reserved words?

I had a relatively cursory search and couldn't find anything beyond PHP's list, and mention of messages, attributes & entity

@edalzell
Copy link
Contributor

We should list the context as well as it's different, for example, if you use user or form in a route you get unexpected results.

@arthurperton
Copy link

Nice, a list like this would be helpful!

You also should not use length as a field name. Learned by experience :)
It is as reserved keyword in JavaScript and probably leads to trouble in the CP's Vue components.

@berdjabrahamian
Copy link

berdjabrahamian commented Jan 14, 2021

I looks like the word listings is reserved as well
Tried it on 2 fresh installs

Created a collections called Listings - and hitting '/listings' returns
The requested resource /listings was not found on this server.

However if I use the word 'Listing' then it will load perfectly fine

If someone can also verify it

---- EDIT -----
I take it back, looks like on the 3rd fresh install its loading as expected, however will keep an eye on it, to make sure it wasnt something else that caused that error to show up

---- EDIT #2 ----
Must have been having a brain fart - I had a custom asset container called listings as well, and it was pointing to a folder in PUBLIC called listings.

Changed the name to something else and we are all good

@edalzell
Copy link
Contributor

apparently you can't use content_type as a field either, it breaks things.

@arthurperton
Copy link

When you use {taxonomy} as a parameter in a route, it breaks (404).

@jasonvarga
Copy link
Member

Arthur, if the field is not max_items: 1, then it would be an array and wouldn't work.

@arthurperton
Copy link

Jason I don’t think I understand your comment in this context, what are you referring to?

@edalzell
Copy link
Contributor

When you use {taxonomy} as a parameter in a route, it breaks (404).

it breaks because of Statamic's route/model binding

@jasonvarga
Copy link
Member

Ah yes. That'd be it. Ignore my other comment. 😄

@arthurperton
Copy link

🎉

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

No branches or pull requests

7 participants