bobdenotter / configuration-notices

💡 A small tool to point out common pitfalls for Bolt 4 configuration settings
MIT License
9 stars 4 forks source link

Call to a member function all() on null #9

Open develth opened 3 years ago

develth commented 3 years ago

Hello,

currently my Dashbaord throws this error while running the Checks.

https://github.com/bobdenotter/configuration-notices/blob/d00aa60588d35cdfcdd702038c4d0de6802fe797/src/Checks.php#L169

Could be fixed with a nullcheck before Line 169

if($fields->get('slug')->get('uses') === null){
    continue;
}
bobdenotter commented 3 years ago

Hi @develth,

Can this be caused by a certain contenttype not having a type: slug field?

develth commented 3 years ago

Hi @bobdenotter,

yes, my start content-type has no defined slugtype

eduardomart commented 3 years ago

Hi, this seems to be fixed in Bolt 4.1.3 (which updates config-notices)

However, as mentioned in slack, before this fix I added a type: slug to all my content types to try to resolve the issue, although I really don't need the slugs in my content types which are viewless and singleton. But I think since I had added the slug field previously, even after removing it, this notice remains in the dashboard:

Screen Shot 2020-10-22 at 1 17 58 PM

Not a big deal to see this warning, but I thought it was worth reporting it.

simongroenewolt commented 3 years ago

This is probably because a default slug field is created by the ContentTypesParser here: https://github.com/bolt/core/blob/f698e2d8546f72072517fb8a58f788fb1d87450f/src/Configuration/Parser/ContentTypesParser.php#L238

I-Valchev commented 3 years ago

hi @eduardomart , this notice is about the uses attribute of the slug, not the slug itself.

Every slug should have a uses attribute, as far as I am aware, because that's what Bolt uses to generate it (when people don't put it in manually, which is like.. almost always )

simongroenewolt commented 3 years ago

@I-Valchev I was online when @eduardomart mentioned it on slack. I think it's clear that it is about 'uses' part - what is confusing is the wording of the message combined with the contents of contenttypes.yaml. @eduardomart removed the slug field (didn't have one in the first place) but the message is stating "The .... has a slug field 'slug' ...". So the message tells you you have a slug field, and you cannot see it in your contenttypes.yaml. (Because the slug field was added in the ContentTypesParser).

I think that if Bolt was less 'friendly' and just barked instantly about a missing slug field instead of creating one for you it might be clearer, but I don't know the reasoning behind adding the hidden slug.

I-Valchev commented 3 years ago

Ah, right I get you! Sorry, didn't understand the problem initially.

I'm not sure it is a good idea to remove the default in bolt, because bolt does depend on having a slug in a few places... maybe we should re-word the configuration notice 🤔