statamic / docs

Statamic Documentation
https://statamic.dev
Other
116 stars 379 forks source link

Knowledge Base: Reserved Words #236

Closed sjclark closed 3 years ago

sjclark commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Great job! Does laravel have reserved words?

sjclark commented 4 years ago

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 commented 4 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

arthurperton commented 3 years ago

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

jasonvarga commented 3 years ago

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

arthurperton commented 3 years ago

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

edalzell commented 3 years ago

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

it breaks because of Statamic's route/model binding

jasonvarga commented 3 years ago

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

arthurperton commented 3 years ago

🎉