Skip to content

Commit

Permalink
Fixes #4828 no comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Mar 27, 2014
1 parent b65ad76 commit ed3f588
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions core/DataAccess/LogAggregator.php
Expand Up @@ -500,6 +500,7 @@ public function queryEcommerceItems($dimension)
', ',
array(
"log_action.name AS label",
sprintf("log_conversion_item.%s AS labelIdAction", $dimension),
sprintf(
'%s AS `%d`',
self::getSqlRevenue('SUM(log_conversion_item.quantity * log_conversion_item.price)'),
Expand Down
16 changes: 10 additions & 6 deletions core/Segment.php
Expand Up @@ -364,10 +364,12 @@ private function generateJoins($tables)
$conversionItemAvailable = ($conversionItemAvailable || $table == "log_conversion_item");
}

return array(
$return = array(
'sql' => $sql,
'joinWithSubSelect' => $joinWithSubSelect
);
return $return;

}

/**
Expand Down Expand Up @@ -421,17 +423,18 @@ private function buildSelectQuery($select, $from, $where, $orderBy, $groupBy)
*/
private function buildWrappedSelectQuery($select, $from, $where, $orderBy, $groupBy)
{
preg_match_all("/(log_visit|log_conversion|log_action).[a-z0-9_\*]+/", $select, $matches);
$matchTables = "(log_visit|log_conversion_item|log_conversion|log_action)";
preg_match_all("/". $matchTables ."\.[a-z0-9_\*]+/", $select, $matches);
$neededFields = array_unique($matches[0]);

if (count($neededFields) == 0) {
throw new Exception("No needed fields found in select expression. "
. "Please use a table prefix.");
}

$select = preg_replace('/(log_visit|log_conversion|log_action)\./', 'log_inner.', $select);
$orderBy = preg_replace('/(log_visit|log_conversion|log_action)\./', 'log_inner.', $orderBy);
$groupBy = preg_replace('/(log_visit|log_conversion|log_action)\./', 'log_inner.', $groupBy);
$select = preg_replace('/'.$matchTables.'\./', 'log_inner.', $select);
$orderBy = preg_replace('/'.$matchTables.'\./', 'log_inner.', $orderBy);
$groupBy = preg_replace('/'.$matchTables.'\./', 'log_inner.', $groupBy);

$from = "(
SELECT
Expand All @@ -445,6 +448,7 @@ private function buildWrappedSelectQuery($select, $from, $where, $orderBy, $grou
) AS log_inner";

$where = false;
return $this->buildSelectQuery($select, $from, $where, $orderBy, $groupBy);
$query = $this->buildSelectQuery($select, $from, $where, $orderBy, $groupBy);
return $query;
}
}

0 comments on commit ed3f588

Please sign in to comment.