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:
authorMatthieu Aubry <matt@piwik.org>2015-12-04 03:12:29 +0300
committerMatthieu Aubry <matt@piwik.org>2015-12-04 03:12:29 +0300
commit6cde84c08d35fc0c49dbf0603e05dbd71f68e5f5 (patch)
tree925d733fbb09f6751c5b35ce3ca91674efa31de9 /core
parentf0a48bedd88123805f1eee2e029bec9e40e4428e (diff)
Check whether string actually contains value to prevent from copying the string to reduce memory usage
Diffstat (limited to 'core')
-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;
}