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

Content->toArray() always returns [] for relations. #1900

Closed
simongroenewolt opened this issue Sep 24, 2020 · 0 comments · Fixed by #1927
Closed

Content->toArray() always returns [] for relations. #1900

simongroenewolt opened this issue Sep 24, 2020 · 0 comments · Fixed by #1927

Comments

@simongroenewolt
Copy link
Contributor

When calling toArray() on an object of type Bolt\Entity\Content you'll get a serialized version of the content. However, the current implementation always returns the empty array for 'relations'.

Details

Question Answer
Relevant Bolt Version 4.0
Install type Composer install
BC Break no
PHP version 7.2 / 7.3 / 7.4
Web server NA
For UX/UI issues NA

Reproduction

Take a look at the source of Content.php (https://github.com/bolt/core/blob/6d838da3e4bebfd702f4512200295d7b840d7846/src/Entity/Content.php) and locate the toArray() function to the 'relations' being set to []

$result['relations'] = [];
.

Steps to reproduce

Get a reference to a content object in php that has at least one relation set and call $myContentItem->toArray();

The resulting array has a key 'relations' that will be [], even if the content does have a relation.

Expected result

I'd expect the toArray() call to either return with the actual relations, or alternatively without the 'relations' key at all. In the last case I'd expect this to be mentioned in the phpdoc of the function.

Actual result

The key 'relations' is always [].

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

Successfully merging a pull request may close this issue.

1 participant