Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/Common.php')
-rw-r--r--core/Common.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/core/Common.php b/core/Common.php
index 76c9777605..6dfa2d22fa 100644
--- a/core/Common.php
+++ b/core/Common.php
@@ -474,7 +474,10 @@ class Common
} elseif ($varType === 'integer') {
if ($value == (string)(int)$value) $ok = true;
} elseif ($varType === 'float') {
- if ($value == (string)(float)$value) $ok = true;
+ $valueToCompare = (string)(float)$value;
+ $valueToCompare = Common::forceDotAsSeparatorForDecimalPoint($valueToCompare);
+
+ if ($value == $valueToCompare) $ok = true;
} elseif ($varType === 'array') {
if (is_array($value)) $ok = true;
} else {
@@ -1078,6 +1081,22 @@ class Common
}
/**
+ * Force the separator for decimal point to be a dot. See https://github.com/piwik/piwik/issues/6435
+ * If for instance a German locale is used it would be a comma otherwise.
+ *
+ * @param float|string $value
+ * @return string
+ */
+ public static function forceDotAsSeparatorForDecimalPoint($value)
+ {
+ if (null === $value || false === $value) {
+ return $value;
+ }
+
+ return str_replace(',', '.', $value);
+ }
+
+ /**
* Sets outgoing header.
*
* @param string $header The header.