-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.2.5]: relatedTo with multiply Categories Error: Serialization of 'Closure' is not allowed #11981
Comments
I'm having trouble replicating this one. Are there any errors in the |
there are tons of errors, which file do you want? ;) Also the debug bar does not work for me. It shows: if you want to, i can send you all files via email |
That's the output of the page
|
Thanks! Unfortunately, I'm still not able to replicate on my end. Can you clear out your If not, can you send a database backup and your composer files over to [email protected]? |
Does not work, i will send you the files |
Just my two cents: In general just as a quick "fix" to avoid this bug (plus gain performance) I would suggest to execute your query and pass the result as related to instead of the query itself. As of Craft: it's easily fixable if you execute the query at the beginning instead of casting it all the time. Ok: $relatedTo = Entry::find()->section('someSection');
$query = Entry::find()->relatedTo($relatedTo);
$query->ids() Not okay: $relatedTo = Entry::find()->section('someSection');
$query = Entry::find()->relatedTo($relatedTo);
$query->ids();
$query->ids(); // or all or getRawSql or something like that |
Hi @Anubarak indeed it worked like this: {% set ids = block.category.ids %}
{% set query = craft.entries
.section(['blog'])
.relatedTo(ids)
.with(['ovImage'])
.limit(block.limit) %} thanks a lot! |
Fixes a serialization error that occurs when an ElementQuery is passed into the `normalizeRelatedToParam` method. #11981
We tracked this down to a bug that could have potentially affected Craft 3 as well, so we’ve now fixed this for the next Craft 3 and 4 releases. (#12055) |
Craft 3.7.56 and 4.2.6 are out with the fix for this. |
What happened?
Description
After updating to Craft 4 this query cause an error at query
block.category
is a Categories field and can include multiple categories. If just one category is selected no error appears but also no data, with more categories selected:Serialization of 'Closure' is not allowed
Craft CMS version
4.2.5
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: