-
Notifications
You must be signed in to change notification settings - Fork 641
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.x]: BaseRelationField::afterElementSave $value can be type Collection instead of ElementQuery #11667
Comments
I don’t see how that could have worked in Craft 3 if cms/src/fields/BaseRelationField.php Line 763 in e30d46f
|
In Craft 3 Line 3352 in e30d46f
Vs https://github.com/craftcms/cms/blob/develop/src/base/Element.php#L3746 The same error occurs if you mark the element as dirty as described in my matrix example. |
Ahhh, ok, thanks! Got this and #11670 fixed for the next release. |
What a relief - thank you very much. |
4.2.0 is out with those fixes. |
What happened?
Description
I recently updated a project to Craft 4 and due to heavy logic I need to eager load many fields - even after setting them.
So I frequently end up with logic like
Because otherwise the amount of duplicated Queries would be insane.
Unfortunately you changed your Element.php and added a
condition in your
getFieldValue
. Due to that code yourBaseRelationField::afterElementSave
receives a Collection instead of a Query as it's value and the next conditions will fail.Steps to reproduce
Expected behavior
Your BaseRelationField should either check the value or the Element should be able to return the Query instead
Actual behavior
There is an Exception
Property [id] does not exist on this collection instance.
Craft CMS version
4.x
PHP version
8.1
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response
The text was updated successfully, but these errors were encountered: