cms icon indicating copy to clipboard operation
cms copied to clipboard

[5.x]: Entry to Array convert ignores already eager loaded relationships

Open thisisablock opened this issue 2 years ago • 1 comments

What happened?

Description

If an entry will be loaded with eager relationships (via with()), the array conversion should include the eager loaded content.

Steps to reproduce

  1. Create an EntryType with a matrix field with entry types containing relational fields (for example asset)
  2. Create a Entry with filled field
  3. In PHP - load this entry eager loaded with the with() function to and save that to a variable
  4. call $entry->toArray();

Expected behavior

The toArray conversion should contain the already loaded relationships.

Actual behavior

The converted array not resolving the eager loaded content. The $_eagerLoadedElements array is untouched on associative array conversion.

Craft CMS version

5.0.0-beta3

PHP version

8.3

Operating system and version

MacOs (ddev)

Database type and version

mysql 8.0

Image driver and version

No response

Installed plugins and versions

-

thisisablock avatar Feb 26 '24 19:02 thisisablock

This is working as expected. toArray() should not be impacted by whether elements were eager-loaded.

brandonkelly avatar Feb 27 '24 22:02 brandonkelly