verbb / vizy

A flexible visual editor for Craft CMS
Other
44 stars 8 forks source link

AssetQuery? error leading to failed search index updation / project config sync #74

Closed rungta closed 2 years ago

rungta commented 2 years ago

Description

We’ve been experiencing a lot of failed Updating search indexes tasks, and today, failed project config syncs as well with the following errors:

Search Index job:

Argument 1 passed to craft\fields\BaseRelationField::_all() must implement interface craft\elements\db\ElementQueryInterface, array given, called in .../vendor/craftcms/cms/src/fields/BaseRelationField.php on line 582

Project config sync:

[…]
- updating matrixBlockTypes.07119041-be85-4197-b0ac-81fac00a5b81.fields.7a0434b8-2551-4fd4-ac5a-6bdcae2e05ee.settings.typeSettings.__assoc__.0 ... done
- updating matrixBlockTypes.89302011-310e-4188-ae90-09a1d9f1322d.fields.53a4034e-e749-4a2a-a3f1-5d0adf2c0050.settings.typeSettings.__assoc__.1 ... done
- updating entryTypes.911bb069-c613-445b-977c-e3ff5369e417.fieldLayouts.00470b6c-8654-4d77-8495-712c506e8e55.tabs.0.elements.5 ... 
 - updating entryTypes.911bb069-c613-445b-977c-e3ff5369e417 ... 

error: Argument 1 passed to craft\fields\BaseRelationField::_all() must implement interface craft\elements\db\ElementQueryInterface, array given, called in ../vendor/craftcms/cms/src/fields/BaseRelationField.php on line 582

We had written to Craft support and Oli helped narrow it down to Vizy -- disabling Vizy and re-running the search job or ./craft project-config/apply fixes the issue and both tasks complete successfully. His words:

Josh might spot something straight away.

To me it looked like when the field is marked to be searchable, rather than passing the asset as an AssetQuery, it simply passes the asset ID.

Steps to reproduce Have not been able to figure out the steps to reproduce this consistently. We are seeing the project config sync error on production but not on dev/staging, where the search index job failures are probably more consistently appearing on all envs.

Additional info

Additional context We do have blocks with Asset fields in some of our Vizy fields.

engram-design commented 2 years ago

Thanks for the investigation here, fixed for the next release. To get the fix early, change your verbb/vizy requirement in composer.json to:

"require": {
  "verbb/vizy": "dev-craft-3 as 1.0.7",
  "...": "..."
}

Then run composer update.

rungta commented 2 years ago

Worked like a charm. Thanks @engram-design!

engram-design commented 2 years ago

Fixed in 1.0.8.