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:
authormattab <matthieu.aubry@gmail.com>2016-04-11 06:00:57 +0300
committermattab <matthieu.aubry@gmail.com>2016-04-11 06:00:57 +0300
commitd5a329b285acafbb71c498a9b0dab3511a4ee45c (patch)
treed78582bf111f314056ba5e4dbe2e129dc399674f /core
parent92bb72883c53c77a1c7adce13dcf817127188764 (diff)
Select 10 times more rows so that resultset after grouping is more likely to contain enough records
Diffstat (limited to 'core')
-rw-r--r--core/DataTable/Renderer/Csv.php25
1 files changed, 19 insertions, 6 deletions
diff --git a/core/DataTable/Renderer/Csv.php b/core/DataTable/Renderer/Csv.php
index 15d6b8ce74..d7b58783ee 100644
--- a/core/DataTable/Renderer/Csv.php
+++ b/core/DataTable/Renderer/Csv.php
@@ -271,17 +271,16 @@ class Csv extends Renderer
// Excel / Libreoffice formulas may start with one of these characters
$formulaStartsWith = array('=', '+', '-', '@');
- // remove first % sign
- $count = 1;
- $valueWithoutPercentSign = str_replace('%', '', $value, $count);
+ // remove first % sign and if string is still a number, return it as is
+ $valueWithoutFirstPercentSign = $this->removeFirstPercentSign($value);
- if (empty($valueWithoutPercentSign)
+ if (empty($valueWithoutFirstPercentSign)
|| !is_string($value)
- || is_numeric($valueWithoutPercentSign)) {
+ || is_numeric($valueWithoutFirstPercentSign)) {
return $value;
}
- $firstCharCellValue = $valueWithoutPercentSign[0];
+ $firstCharCellValue = $valueWithoutFirstPercentSign[0];
$isFormula = in_array($firstCharCellValue, $formulaStartsWith);
if($isFormula) {
return "'" . $value;
@@ -480,4 +479,18 @@ class Csv extends Renderer
}
return $str;
}
+
+ /**
+ * @param $value
+ * @return mixed
+ */
+ protected function removeFirstPercentSign($value)
+ {
+ $needle = '%';
+ $posPercent = strpos($value, $needle);
+ if ($posPercent !== false) {
+ return substr_replace($value, '', $posPercent, strlen($needle));
+ }
+ return $value;
+ }
}