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-30457: FieldType::getSortInfo should be implemented by impl. only if the FT is sortable #2677

Merged
merged 2 commits into from
Jun 27, 2019

Conversation

adamwojs
Copy link
Member

Question Answer
JIRA issue EZP-30457
Bug/Improvement no
New feature yes
Target version master
BC breaks no
Tests pass yes
Doc needed no

Method eZ\Publish\Core\FieldType\FieldType::getSortInfo should be implemented by Developer only if the FT is sortable.

Currently, the default implementation throws a RuntimeException: "Not implemented, yet.". Usually, the developer figures out that something is missing on the first try of adding FT to the CT ...

TODO:

  • Implement feature / fix a bug.
  • Implement tests.
  • Fix new code according to Coding Standards ($ composer fix-cs).
  • Ask for Code Review.

…ouldn't throw an exception in default implementation
@@ -271,7 +271,7 @@ public function applyDefaultSettings(&$fieldSettings)
*/
protected function getSortInfo(Value $value)
{
throw new \RuntimeException('Not implemented, yet.');
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Imo null would be better

Copy link
Member

Choose a reason for hiding this comment

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

Imo null would be better

@pawbuj, I agree but this has deeper consequences. Right now false is internally treated as "no sort info".

@adamwojs Does this PR block anything?
Asking because I think we need to rectify this and indeed use null.
Use case: you have boolean FT which you want to sort by false first.

Copy link
Member Author

@adamwojs adamwojs Jun 26, 2019

Choose a reason for hiding this comment

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

@adamwojs Does this PR block anything?

Generic Field Type depends on this change.

Asking because I think we need to rectify this and indeed use null.
Use case: you have boolean FT which you want to sort by false first.

null is also allowed value here, see \eZ\Publish\Core\FieldType\Null\Type::getSortInfo. Using false is just a "non-formal" convention for non-sortable FT.

Copy link
Member

Choose a reason for hiding this comment

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

null is also allowed value here, see \eZ\Publish\Core\FieldType\Null\Type::getSortInfo. Using false is just a "non-formal" convention for non-sortable FT.

What are the implications of returning null then?

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 are no implications at this point. Value returned by getSortInfo is passed as \eZ\Publish\SPI\Persistence\Content\FieldValue::$sortKey to \eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter implementation and needs to be handled there.

Suggestion applied in fa8fc75

…Info shouldn't throw an exception in default implementation
@adamwojs
Copy link
Member Author

PR updated according to @pawbuj suggestion.

@adamwojs adamwojs merged commit 8cb4871 into master Jun 27, 2019
@adamwojs adamwojs deleted the ezp_30457 branch June 27, 2019 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

6 participants