Retain preferred array format while searching Money values.
authoreileen <emcnaughton@wikimedia.org>
Tue, 9 Oct 2018 17:10:38 +0000 (18:10 +0100)
committereileen <emcnaughton@wikimedia.org>
Wed, 10 Oct 2018 11:33:47 +0000 (12:33 +0100)
The preferred BAO_Query format is ['BETWEEN' => [12.40 AND 13.50]] but this is currently being munged back
into legacy format, creating a test fail

Note that the search doesn't work properly with international commas, with, or without
this patch :-(

CRM/Core/BAO/CustomQuery.php

index b71acb1081ce6a18c7e4400587eb1d6dc3934fb9..a923bb53c15084b88ae5c04441783a96bb2ba51c 100644 (file)
@@ -420,10 +420,16 @@ SELECT f.id, f.label, f.data_type,
             $value = CRM_Utils_Array::value($op, (array) $value, $value);
             if (is_array($value)) {
               foreach ($value as $key => $val) {
-                $value[$key] = CRM_Utils_Rule::cleanMoney($value[$key]);
+                // @todo - this clean money should be in the form layer - it's highly likely to be doing more harm than good here
+                // Note the only place I can find that this code is reached by is searching a custom money field in advanced search.
+                // with euro style comma separators this doesn't work - with or without this cleanMoney.
+                // So this should be removed but is not increasing the brokeness IMHO
+                $value[$op][$key] = CRM_Utils_Rule::cleanMoney($value[$key]);
               }
             }
             else {
+              // @todo - this clean money should be in the form layer - it's highly likely to be doing more harm than good here
+              // comments per above apply. cleanMoney
               $value = CRM_Utils_Rule::cleanMoney($value);
             }