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.x]: Matrix-field $value can be instance of Collection -> method craft\\elements\\ElementCollection::setCachedResult does not exist #13421

Closed
Anubarak opened this issue Jul 13, 2023 · 2 comments
Assignees

Comments

@Anubarak
Copy link
Contributor

Anubarak commented Jul 13, 2023

What happened?

Description

$value in your relation / Matrix fields can always be instance of Collection instead of ElementQueryInterface
https://github.com/craftcms/cms/blob/develop/src/fields/Matrix.php#L822-L825

if (!$allBlocksValidate) {
    // Just in case the blocks weren't already cached
    $value->setCachedResult($blocks);
}

->

if (!$allBlocksValidate && $value instanceof ElementQueryInterface) {
    // Just in case the blocks weren't already cached
    $value->setCachedResult($blocks);
}

Steps to reproduce

  1. use eager loading
  2. save the matrix block

Expected behavior

Craft CMS version

4.4.5

PHP version

8.2.0

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

@i-just
Copy link
Contributor

i-just commented Jul 13, 2023

Hi, thanks for reporting! I raised a PR for this.

@brandonkelly
Copy link
Member

Craft 4.4.16 is out with a fix for this.

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

3 participants