statamic / cms

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

Bard field error: Arr::isAssoc() must be of the type array (since Statamic 3.0.4) #2369

Closed jimblue closed 4 years ago

jimblue commented 4 years ago

Bug Description

After updating to Statamic release 3.0.5 bard page with bard field return an error.

Extra Detail

Using bard field like suggested in the doc:

<div itemprop="articleBody">
  {{ bard_field }}
  {{ partial src="templates/blog/post/sets/{type}" }}
  {{ /bard_field }}
</div>

The error:

Screenshot 2020-09-05 at 23 19 55

Environment

Statamic 3.0.5 Pro
Laravel 7.27.0
PHP 7.4.10
4rn0/statamic-v3-image-optimizer 1.0.2
jimblue/htmlmin 1.0.0
jimblue/instagram dev-develop
jimblue/mapbox 1.0.0
jimblue/webpacker dev-develop
statamic/seo-pro 2.0.10
vitor-ao commented 4 years ago

Same error happens when a fieldset has a checkbox field and none of the options are selected.

billmn commented 4 years ago

Even if you use code like this:

{{ collection:posts scope="post" }}
    {{ post:title }}

    {{ categories scope="category" }} <- this scope throw an exception
        {{ category:title }}
    {{ /categories }}
{{ /collection:posts }}

"Posts" is a collection that have related "Categories" entries through an "Entries" field type in the blueprint.

(I know that "scope" in this situation is not necessary but i think it shouldn't raise an exception if it is used).

Probably this happen even before the 3.0.5

jimblue commented 4 years ago

Probably this happen even before the 3.0.5

It was perfectly working before 3.0.5

jasonvarga commented 4 years ago

Probably introduced in 3.0.4, so stay on 3.0.3 for the moment. Will fix this soon.

edalzell commented 4 years ago

I still get this error on 3.0.6. I've cleared all the caches, etc.

Likely this part of my template:

{{ posts scope="page"}}
    {{ partial:blog-post truncation="true" comment_link="true" }}
{{ /posts }}
Pixney-William commented 4 years ago

I get this issue with 3.0.6

{{ paginate }}

{{if total_items > items_limit}}

<div class="w-full ">

    <div class="c-pagination">

        <a class="c-button" href="{{ prev_page }}">{{ svg src="left"}}</a>

        {{ current_page }} / {{ total_pages }}

        <a class="c-button" href="{{ next_page }}">{{ svg src="right"}}</a>

    </div>

</div>

{{ /if }}

{{ /paginate }}
acurrieclark commented 4 years ago

It seems there are lots of different possible types for $values here, not just Value or Array. I have a situation where with recursive navs where the {{ depth }} tag results in an int type.

jasonvarga commented 4 years ago

@acurrieclark Could you share your template where the depth variable is being used and causing the error?

acurrieclark commented 4 years ago

@jasonvarga Of course. Should have added it sooner, apologies

https://gist.github.com/acurrieclark/a3e43a1e268cc35a980dd526029b175f

jasonvarga commented 4 years ago

Thanks @acurrieclark

Looks like the cause is this line: https://gist.github.com/acurrieclark/a3e43a1e268cc35a980dd526029b175f#file-statamic-menu-php-L35

{{ depth - 1 }} is not something Antlers supports. Was this even doing what you expected before 3.0.4?

The way to do that in Antlers is to use the minus modifier. {{ depth | -:1 }}

acurrieclark commented 4 years ago

@jasonvarga it was doing what I wanted, but clearly not as a result of my efforts! Just made that change and all is well in 3.0.6. Thanks for taking the time to look at it for me.

jimblue commented 4 years ago

This is solved on my side with 3.0.6 🙏🏼

jasonvarga commented 4 years ago

More fixes in 3.0.7