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-31675: do not cast parameters part to string #39

Merged
merged 1 commit into from
Jun 16, 2020

Conversation

bdunogier
Copy link
Member

@bdunogier bdunogier commented Jun 8, 2020

Question Answer
JIRA issue EZP-31675
Type bug
Target eZ Platform version v2.x, v3.x
BC breaks no
Tests pass yes
Doc needed no

Due to a string typehint in the Query Field Service, integer or boolean parameters always ended up as strings, causing errors in the Query Types options resolution.

Checklist:

  • PR description is updated.
  • Tests are implemented.
  • Added code follows Coding Standards (use $ composer fix-cs).
  • PR is ready for a review.

Copy link
Contributor

@Nattfarinn Nattfarinn left a comment

Choose a reason for hiding this comment

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

private function isExpression($expression): bool
{
    return is_string($expression) && substr($expression, 0, 2) !== '@=';
}

and:

foreach ($expressions as $key => $expression) {
    if (is_array($expression)) {
        $expressions[$key] = $this->resolveParameters($expression, $variables);
    } else if ($this->isExpression($expression)) {
        $expressions[$key] = $this->resolveExpression($expression, $variables);
    } else {
        $expressions[$key] = $expression;
    }
}

Would be a bit cleaner without removing typehint and we would avoid "do nothing path" of resolveExpression method.

@bdunogier
Copy link
Member Author

Good idea, @Nattfarinn, thank you.

@bdunogier bdunogier force-pushed the ezp31675-parameter_string_cast branch from cfa66bd to 27041b1 Compare June 8, 2020 11:25
@bdunogier
Copy link
Member Author

@Nattfarinn is it better now ?

@bdunogier bdunogier force-pushed the ezp31675-parameter_string_cast branch 2 times, most recently from d3e70e2 to c4c8862 Compare June 8, 2020 11:54
@bdunogier bdunogier requested a review from Nattfarinn June 9, 2020 12:56
@bdunogier bdunogier force-pushed the ezp31675-parameter_string_cast branch from c4c8862 to d6dd94e Compare June 9, 2020 13:12
@bdunogier bdunogier force-pushed the ezp31675-parameter_string_cast branch from d6dd94e to 68e99e8 Compare June 9, 2020 15:51
@bdunogier
Copy link
Member Author

Thank you for the review & review-request, @Nattfarinn.

@lserwatka lserwatka merged commit 1719edd into 1.0 Jun 16, 2020
@lserwatka lserwatka deleted the ezp31675-parameter_string_cast branch June 16, 2020 06:51
@lserwatka
Copy link
Member

@adamwojs could you merge it up?

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.

3 participants