-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
@bdunogier is this ready for QA? |
} | ||
|
||
$contentItems = $this->contentLoader->find(new Query( | ||
['filter' => new Query\Criterion\ContentId($destinationContentIds)] |
There was a problem hiding this comment.
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; }
There was a problem hiding this comment.
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.
5505643
to
41a1e0f
Compare
@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). |
41a1e0f
to
6cbe7cf
Compare
Always run a multiple search, and return the results depending on the multiple flag.
6cbe7cf
to
045fd7f
Compare
@@ -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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's alright 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
The
RelationFieldDefinitionMapper
is used for bothezobjectrelation
andezobjectrelationlist
. The resolver is also the same, but was not correctly updated forezobjectrelation
, 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.