-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fixed counting exception #1188
Fixed counting exception #1188
Changes from 1 commit
bdbcd25
56af866
bb36584
665df90
b8794b7
b1c48f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,6 +140,16 @@ public function count() | |
$countQuery->setFirstResult(null)->setMaxResults(null); | ||
|
||
try { | ||
$parser = new Query\Parser($countQuery); | ||
$parameterMappings = $parser->parse($parser)->getParameterMappings(); | ||
$parameters = $countQuery->getParameters(); | ||
foreach($parameters as $k=>$param){ | ||
if(!array_key_exists($param->getName(), $parameterMappings)){ | ||
$parameters->remove($k); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems wrong: too many bound parameters and you are removing some? This may even introduce security issues... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doctrine didn't removes it automatically when count is performed on something like this: return $this->getEntityManager()->createQuery(
"select r,"
. "(sum(case when rr.helpful=true then 1 else 0 end)* 100 / (count(rr.helpful)+0.00001)) as hidden percent_cnt,"
. "(case when (sum(case when rr.helpful=true then 1 else 0 end)* 100 / (count(rr.helpful)+0.00001))>:percent_of_helpfulness and count(rr.helpful)>:minimum_votes then 1 else 0 end) as hidden valuable_cnt"
. " from MerixGameBundle:Review r left join r.reviewRatings rr"
. " where r.game = :game group by r.id order by valuable_cnt desc, percent_cnt desc"
)
->setParameter('percent_of_helpfulness', self::PERCENT_OF_HELPFULNESS)
->setParameter('minimum_votes', self::MINIMUM_VOTES)
->setParameter('game', $game); |
||
} | ||
} | ||
$countQuery->setParameters($parameters); | ||
|
||
$data = $countQuery->getScalarResult(); | ||
$data = array_map('current', $data); | ||
$this->count = array_sum($data); | ||
|
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.
Add an empty newline before this line