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

EZP-30414: Relation fields aren't resolved #30

Merged
merged 3 commits into from
Apr 11, 2019

Conversation

bdunogier
Copy link
Member

@bdunogier bdunogier commented Apr 2, 2019

JIRA: https://jira.ez.no/browse/EZP-30414

The RelationFieldDefinitionMapper is used for both ezobjectrelation and ezobjectrelationlist. The resolver is also the same, but was not correctly updated for ezobjectrelation, making it return null in every case for it.

The resolver has been changed to always fetch multiple items, and return one or an array depending on the multiple flag.

@lserwatka
Copy link
Member

@bdunogier is this ready for QA?

}

$contentItems = $this->contentLoader->find(new Query(
['filter' => new Query\Criterion\ContentId($destinationContentIds)]
Copy link

@crosa7 crosa7 Apr 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this with Solr enabled and it will throw an exception when $destinationContentIds is an empty array, a suggestion would be to add the following before "$contentItems = ..."
if(empty($destinationContentIds)) { return $multiple ? [] : null; }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, very good remark @crosa7. It should be fixed now.

@bdunogier bdunogier force-pushed the object_relation_resolver_fix branch from 5505643 to 41a1e0f Compare April 4, 2019 22:49
@bdunogier
Copy link
Member Author

bdunogier commented Apr 4, 2019

@lserwatka Not yet. I have extracted the perf optimization commit, as it is not ready. I'll check @crosa7's feedback, and I'll mark it as ready for review (friday).

@bdunogier bdunogier force-pushed the object_relation_resolver_fix branch from 41a1e0f to 6cbe7cf Compare April 5, 2019 09:01
@bdunogier bdunogier marked this pull request as ready for review April 5, 2019 09:03
Bertrand Dunogier added 2 commits April 5, 2019 11:20
Always run a multiple search, and return the results depending on the multiple flag.
@bdunogier bdunogier force-pushed the object_relation_resolver_fix branch from 6cbe7cf to 045fd7f Compare April 5, 2019 09:20
@bdunogier bdunogier requested a review from webhdx April 5, 2019 09:20
@@ -136,24 +136,23 @@ public function resolveDomainFieldValue(Content $content, $fieldDefinitionIdenti

public function resolveDomainRelationFieldValue(Field $field, $multiple = false)
{
if (!$field->value instanceof FieldType\RelationList\Value) {
throw new UserError("$field->fieldTypeIdentifier is not a RelationList field value");
if ($field->value instanceof FieldType\RelationList\Value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it also work with ImageAsset fieldtype? It's also a Relation field if I'm not mistaken.

Also I'd extract the essence from this method and split into multiple methods for Relation, RelationList, ImageAssets to avoid nasty if statements.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About Image Asset, no, not really. It does load the related asset, indeed, but does extra things, and doesn't have much in common with relations overall (see ImageAssetFieldResolver).

I'll see what I can do to make it more readable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There. I have moved the ID extraction to its own method. I could break it down into two, one for Relation, one for RelationList, but imho it is good enough that way. What do you think @webhdx ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's alright 👍

@bdunogier bdunogier requested a review from webhdx April 10, 2019 08:07
@lserwatka lserwatka changed the title Fixed resolution of ezobjectrelation fields EZP-30414: Relation fields aren't resolved Apr 10, 2019
Copy link
Member

@mnocon mnocon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@lserwatka lserwatka merged commit b219f23 into master Apr 11, 2019
@lserwatka lserwatka deleted the object_relation_resolver_fix branch April 11, 2019 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants