Skip to content
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.5.0]: Matrix serializeValue() fields closure #13592

Closed
lukasNo1 opened this issue Aug 23, 2023 · 2 comments
Closed

[4.5.0]: Matrix serializeValue() fields closure #13592

lukasNo1 opened this issue Aug 23, 2023 · 2 comments

Comments

@lukasNo1
Copy link

lukasNo1 commented Aug 23, 2023

Description

Since craft 4.5.0 the Matrix serializeValue() returns the fields a closure rather than an array of fields like in 4.4.*
https://github.com/craftcms/cms/blob/develop/src/fields/Matrix.php#L578

My use case goes something like this:

  1. We serialise a MatrixBlockQuery with $field->serializeValue()
  2. We use $entry->setFieldValue('fieldname', $serializedValue) to copy the matrix Block to a different matrix field (of the same type)

Since 4.5.0 the setFieldValue doesnt work anymore. The matrix fields gets created, but the fields are just blank as this function is expecting an array of fields and cannot read the closure

Craft CMS version

4.5.0

PHP version

8.2

@lukasNo1
Copy link
Author

I saw the change was added to provide lazy loading to graphQl queries.

I am implementing a workaround for now with looping through the response from serializeValue() and executing the fields closure, but i would appreciate it if you could make the serializeValue() compatible with the setFieldValue() function. Maybe with an additional parameter $lazyLoad = true in the serializeValue() function?

@lukasNo1 lukasNo1 changed the title 4.5.0: Matrix serializeValue() closure [4.5.0]: Matrix serializeValue() fields closure Aug 23, 2023
@brandonkelly
Copy link
Member

Sorry, that was not an intended change! Craft 4.5.1 is out with Matrix::serializeValues() reverted to how it was before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants