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:
authorMatthieu Aubry <matt@piwik.org>2015-12-04 04:00:03 +0300
committerMatthieu Aubry <matt@piwik.org>2015-12-04 04:00:03 +0300
commit2d3b5e56cd42bda646205a40d2070157ed97a969 (patch)
tree028ae23c9541f5598e54dcb17408657ac0d10fe8
parentde427f33efa56695a1701c54b6f703c692b1dcb7 (diff)
parent6cde84c08d35fc0c49dbf0603e05dbd71f68e5f5 (diff)
Merge pull request #9329 from piwik/escapelikestring_memory_2
Check whether string actually contains value to prevent from copying the string to reduce memory usage
-rw-r--r--core/Segment/SegmentExpression.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/Segment/SegmentExpression.php b/core/Segment/SegmentExpression.php
index 5f1a7fea27..605cd13682 100644
--- a/core/Segment/SegmentExpression.php
+++ b/core/Segment/SegmentExpression.php
@@ -279,7 +279,7 @@ class SegmentExpression
// it can be used internally to inject sub-expressions into the query.
// see Segment::getCleanedExpression()
$sqlMatch = '%s IN (' . $value['SQL'] . ')';
- $value = $this->escapeLikeString($value['bind']);
+ $value = $value['bind'];
break;
default:
throw new Exception("Filter contains the match type '" . $matchType . "' which is not supported");
@@ -337,8 +337,14 @@ class SegmentExpression
*/
private function escapeLikeString($str)
{
- $str = str_replace("%", "\%", $str);
- $str = str_replace("_", "\_", $str);
+ if (false !== strpos($str, '%')) {
+ $str = str_replace("%", "\%", $str);
+ }
+
+ if (false !== strpos($str, '_')) {
+ $str = str_replace("_", "\_", $str);
+ }
+
return $str;
}