Add in deprecated warning if amount is not numeric and use filter var to return appro...
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 15 Apr 2021 01:34:44 +0000 (11:34 +1000)
committereileen <emcnaughton@wikimedia.org>
Mon, 19 Apr 2021 01:21:56 +0000 (13:21 +1200)
CRM/Core/Payment.php

index 491ad8939b42648208863786d1731cfe6520516e..86ea55a019fc9583da39b34824d4de5f9644cc31 100644 (file)
@@ -1174,6 +1174,10 @@ abstract class CRM_Core_Payment {
    * @throws \CRM_Core_Exception
    */
   protected function getAmount($params = []) {
+    if (!CRM_Utils_Rule::numeric($params['amount'])) {
+      CRM_Core_Error::deprecatedWarning('Passing Amount value that is not numeric is deprecated please report this in gitlab');
+      return filter_var($params['amount'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
+    }
     return $params['amount'];
   }