CRM-16544 - Select::where() - Less aggressive dedupe
authorTim Otten <totten@civicrm.org>
Tue, 1 Sep 2015 00:59:27 +0000 (17:59 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 1 Sep 2015 00:59:27 +0000 (17:59 -0700)
The where() function attempts to dedupe WHERE clauses, but this could
misbehave when similar clauses are used with different data, and it's been
implicated in a symptom where CiviMail shows irrelevant attachments.

http://civicrm.stackexchange.com/a/5059/93

CRM/Utils/SQL/Select.php

index cdc50c9e80264b33da02ab2756a44e4b020f962d..89fa4b0e4319bdd85cc05d568ddaaaf0ec9d5a0e 100644 (file)
@@ -236,7 +236,8 @@ class CRM_Utils_SQL_Select implements ArrayAccess {
   public function where($exprs, $args = NULL) {
     $exprs = (array) $exprs;
     foreach ($exprs as $expr) {
-      $this->wheres[$expr] = $this->interpolate($expr, $args);
+      $evaluatedExpr = $this->interpolate($expr, $args);
+      $this->wheres[$evaluatedExpr] = $evaluatedExpr;
     }
     return $this;
   }