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:
authorThomas Steur <thomas.steur@gmail.com>2015-11-18 04:20:39 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-11-19 07:14:31 +0300
commit3154cba01693ef0d583567bc89659ea9868656fa (patch)
tree02a484f530fef2b312f69d9b2f0e6a0c92bb28fb /core/Segment
parent433c5c93a8524bd5d4dec7c6f73bc8dca957cb66 (diff)
use union of segments for custom variables
Diffstat (limited to 'core/Segment')
-rw-r--r--core/Segment/SegmentExpression.php58
1 files changed, 18 insertions, 40 deletions
diff --git a/core/Segment/SegmentExpression.php b/core/Segment/SegmentExpression.php
index cd2e0038bd..5f1a7fea27 100644
--- a/core/Segment/SegmentExpression.php
+++ b/core/Segment/SegmentExpression.php
@@ -158,11 +158,14 @@ class SegmentExpression
$operator = $leaf[self::INDEX_BOOL_OPERATOR];
$operandDefinition = $leaf[self::INDEX_OPERAND];
-
$operand = $this->getSqlMatchFromDefinition($operandDefinition, $availableTables);
if ($operand[self::INDEX_OPERAND_OPERATOR] !== null) {
- $this->valuesBind = array_merge($this->valuesBind, $operand[1]);
+ if (is_array($operand[self::INDEX_OPERAND_OPERATOR])) {
+ $this->valuesBind = array_merge($this->valuesBind, $operand[self::INDEX_OPERAND_OPERATOR]);
+ } else {
+ $this->valuesBind[] = $operand[self::INDEX_OPERAND_OPERATOR];
+ }
}
$operand = $operand[self::INDEX_OPERAND_NAME];
@@ -189,12 +192,12 @@ class SegmentExpression
*/
protected function getSqlMatchFromDefinition($def, &$availableTables)
{
- $fields = $def[0];
+ $field = $def[0];
$matchType = $def[1];
$value = $def[2];
// Segment::getCleanedExpression() may return array(null, $matchType, null)
- $operandWillNotMatchAnyRow = empty($fields) && is_null($value);
+ $operandWillNotMatchAnyRow = empty($field) && is_null($value);
if($operandWillNotMatchAnyRow) {
if($matchType == self::MATCH_EQUAL) {
// eg. pageUrl==DoesNotExist
@@ -221,10 +224,6 @@ class SegmentExpression
return array($sqlExpression, $value = null);
}
- if (!is_array($fields)) {
- $fields = array($fields);
- }
-
$alsoMatchNULLValues = false;
switch ($matchType) {
case self::MATCH_EQUAL:
@@ -289,44 +288,23 @@ class SegmentExpression
// We match NULL values when rows are excluded only when we are not doing a
$alsoMatchNULLValues = $alsoMatchNULLValues && !empty($value);
+ $sqlMatch = str_replace('%s', $field, $sqlMatch);
- $sqlExpressions = array();
- $values = array();
- foreach ($fields as $field) {
- $sqlMatchReplaced = str_replace('%s', $field, $sqlMatch);
-
- if ($matchType === self::MATCH_ACTIONS_CONTAINS
- || is_null($value)
- ) {
- $sqlExpression = "( $sqlMatchReplaced )";
+ if ($matchType === self::MATCH_ACTIONS_CONTAINS
+ || is_null($value)
+ ) {
+ $sqlExpression = "( $sqlMatch )";
+ } else {
+ if ($alsoMatchNULLValues) {
+ $sqlExpression = "( $field IS NULL OR $sqlMatch ? )";
} else {
- if ($alsoMatchNULLValues) {
- $sqlExpression = "( $field IS NULL OR $sqlMatchReplaced ? )";
- } else {
- $sqlExpression = "$sqlMatchReplaced ?";
- }
+ $sqlExpression = "$sqlMatch ?";
}
-
- $sqlExpressions[] = $sqlExpression;
-
- if ($value !== null) {
- if(is_array($value)) {
- $values = array_merge($values, $value);
- } else {
- $values[] = $value;
- }
- }
-
- $this->checkFieldIsAvailable($field, $availableTables);
}
- if (count($fields) == 1) {
- $sqlExpression = reset($sqlExpressions);
- } else {
- $sqlExpression = '((' . implode(") OR (", $sqlExpressions) . '))';
- }
+ $this->checkFieldIsAvailable($field, $availableTables);
- return array($sqlExpression, $values);
+ return array($sqlExpression, $value);
}
/**