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
path: root/core
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-11-05 08:04:43 +0300
committerThomas Steur <thomas.steur@googlemail.com>2014-11-07 03:25:59 +0300
commitac4d19763d4467fb848ebd84c6e3747e82edebab (patch)
treefbf762e6d221ef6e27b6028cdaced52bf387fdb5 /core
parentaaa2b72da730d2f86625273c036cdac0e3ffd113 (diff)
refs #6435 replace possible comma with a dot. Not 100% sure if that works yet
Diffstat (limited to 'core')
-rw-r--r--core/ArchiveProcessor.php3
-rw-r--r--core/Common.php16
-rw-r--r--core/Tracker/Action.php2
-rw-r--r--core/Tracker/Db.php1
-rw-r--r--core/Tracker/GoalManager.php7
5 files changed, 26 insertions, 3 deletions
diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php
index 71e90cde23..c93e913e0c 100644
--- a/core/ArchiveProcessor.php
+++ b/core/ArchiveProcessor.php
@@ -260,6 +260,7 @@ class ArchiveProcessor
$metrics = $this->getAggregatedNumericMetrics($columns, $operationToApply);
foreach($metrics as $column => $value) {
+ $value = Common::forceDotAsSeparatorForDecimalPoint($value);
$this->archiveWriter->insertRecord($column, $value);
}
// if asked for only one field to sum
@@ -314,6 +315,8 @@ class ArchiveProcessor
public function insertNumericRecord($name, $value)
{
$value = round($value, 2);
+ $value = Common::forceDotAsSeparatorForDecimalPoint($value);
+
$this->archiveWriter->insertRecord($name, $value);
}
diff --git a/core/Common.php b/core/Common.php
index 76c9777605..d3ff241ccf 100644
--- a/core/Common.php
+++ b/core/Common.php
@@ -1078,6 +1078,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.
diff --git a/core/Tracker/Action.php b/core/Tracker/Action.php
index 23372538ac..ee78960529 100644
--- a/core/Tracker/Action.php
+++ b/core/Tracker/Action.php
@@ -357,7 +357,7 @@ abstract class Action
$customValue = $this->getCustomFloatValue();
if (!empty($customValue)) {
- $visitAction[self::DB_COLUMN_CUSTOM_FLOAT] = $customValue;
+ $visitAction[self::DB_COLUMN_CUSTOM_FLOAT] = Common::forceDotAsSeparatorForDecimalPoint($customValue);
}
$customVariables = $this->getCustomVariables();
diff --git a/core/Tracker/Db.php b/core/Tracker/Db.php
index 1fe081daac..0c419d8f6e 100644
--- a/core/Tracker/Db.php
+++ b/core/Tracker/Db.php
@@ -102,6 +102,7 @@ abstract class Db
foreach ($this->queriesProfiling as $query => $info) {
$time = $info['sum_time_ms'];
+ $time = Common::forceDotAsSeparatorForDecimalPoint($time);
$count = $info['count'];
$queryProfiling = "INSERT INTO " . Common::prefixTable('log_profiling') . "
diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php
index 9f989df935..f17b9a2b96 100644
--- a/core/Tracker/GoalManager.php
+++ b/core/Tracker/GoalManager.php
@@ -277,7 +277,10 @@ class GoalManager
return $revenue;
}
- return round($revenue, self::REVENUE_PRECISION);
+ $revenue = round($revenue, self::REVENUE_PRECISION);
+ $revenue = Common::forceDotAsSeparatorForDecimalPoint($revenue);
+
+ return $revenue;
}
/**
@@ -633,7 +636,7 @@ class GoalManager
'idaction_category3' => (int)$item[self::INTERNAL_ITEM_CATEGORY3],
'idaction_category4' => (int)$item[self::INTERNAL_ITEM_CATEGORY4],
'idaction_category5' => (int)$item[self::INTERNAL_ITEM_CATEGORY5],
- 'price' => $item[self::INTERNAL_ITEM_PRICE],
+ 'price' => Common::forceDotAsSeparatorForDecimalPoint($item[self::INTERNAL_ITEM_PRICE]),
'quantity' => $item[self::INTERNAL_ITEM_QUANTITY],
'deleted' => isset($item['deleted']) ? $item['deleted'] : 0, //deleted
'idorder' => isset($goal['idorder']) ? $goal['idorder'] : self::ITEM_IDORDER_ABANDONED_CART, //idorder = 0 in log_conversion_item for carts