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-26804: Search with section id list filter #201
Conversation
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.
Besides the few remarks, looks good to me.
I'd also simplify the commit message to remove "eZFind", as the commit is part of the ezfind repo.
classes/ezfezpsolrquerybuilder.php
Outdated
@@ -1530,6 +1531,53 @@ protected function getContentClassFilterQuery( $contentClassIdent ) | |||
} | |||
|
|||
/** | |||
* Generate section query filter. | |||
* | |||
* @param mixed eZSection id or list of ids. |
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.
@param int|int[] $sectionIdent eZSection id or list of ids.
classes/ezfezpsolrquerybuilder.php
Outdated
* @param mixed eZSection id or list of ids. | ||
* | ||
* @return string Section query filter. Returns null if invalid | ||
* $sectionIdent is provided. |
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.
You need to align the second line with string
.
classes/ezfezpsolrquerybuilder.php
Outdated
|
||
return implode( ' OR ', $sectionQueryParts ); | ||
} | ||
elseif ( (int)$sectionIdent . '' == $sectionIdent . '' ) |
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.
I'd handle this case first as it is the most common. Then I'd get rid of the else
, as we return inside the if.
@bdunogier I take your remarks into account :) |
classes/ezfezpsolrquerybuilder.php
Outdated
{ | ||
return eZSolr::getMetaFieldName( 'section_id' ) . ':' . $sectionIdent; | ||
} | ||
elseif ( is_array( $sectionIdent ) ) |
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.
You don't need the else
, since you return in the if
above.
@bdunogier I removed the else |
Ping @bdunogier |
classes/ezfezpsolrquerybuilder.php
Outdated
foreach ( $sectionIdent as $sectionID ) | ||
{ | ||
$sectionID = trim( $sectionID ); | ||
if ( empty( $sectionID ) ) |
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.
Is empty array value something we need to support? it could just go straight to error, or?
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.
I can remove it
classes/ezfezpsolrquerybuilder.php
Outdated
return null; | ||
} | ||
|
||
if ( is_numeric( $sectionIdent ) ) |
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.
might be better to use ctype_digit()
Beside remark, +1 |
JIRA: https://jira.ez.no/browse/EZP-26804