thepixelage / craft-fragments

Fragments is a Craft CMS plugin for managing content and presentational fragments.
https://www.thepixelage.com/plugins/fragments
Other
6 stars 1 forks source link

Eagerload fragments without rules throws TypeError #20

Closed robbeman closed 2 years ago

robbeman commented 2 years ago
TypeError
count(): Argument #1 ($value) must be of type Countable|array, string given

https://github.com/thepixelage/craft-fragments/blob/4def4555f7400380fb971a59f4592dd278eb245a/src/elements/db/FragmentQuery.php#L64

Reproduction

  1. Create a fragments field myFragments
  2. Link a fragment with a rule type specified, but no rules added image
  3. Eager load the fragments field on your entry page
    {% do craft.app.elements.eagerLoadElements(
        className(entry),
        [entry],
        [
            'myFragments',
        ]
    ) %}
  4. Observe the TypeError image
MrRonbot commented 2 years ago

@robbeman This is now fixed in 1.1.3, but you will need to re-save the fragment to make it re-save the JSON data correctly.

robbeman commented 2 years ago

Thank you so much for being this quick. 🙏