From 7b677318c47c272f4fd689b10d759b27a9215440 Mon Sep 17 00:00:00 2001
From: mattab <matthieu.aubry@gmail.com>
Date: Tue, 22 Oct 2013 11:57:16 +1300
Subject: [PATCH] Fixing build

---
 core/Tracker/Action.php                                   | 2 +-
 core/Tracker/ActionClickUrl.php                           | 7 ++-----
 core/Tracker/ActionSiteSearch.php                         | 2 +-
 core/Tracker/GoalManager.php                              | 5 -----
 core/Tracker/TableLogAction.php                           | 8 +++++++-
 .../PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php | 2 +-
 .../OneVisitorTwoVisits_withCookieSupportTest.php         | 3 +++
 7 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/core/Tracker/Action.php b/core/Tracker/Action.php
index c5bfa782dc..d2edff64f5 100644
--- a/core/Tracker/Action.php
+++ b/core/Tracker/Action.php
@@ -171,7 +171,7 @@ class Action implements ActionInterface
 
     protected function getNameAndType()
     {
-        return array($this->getActionName(), ActionInterface::TYPE_PAGE_TITLE, $prefix = false);
+        return array($this->getActionName(), ActionInterface::TYPE_PAGE_TITLE);
     }
 
     protected function getUrlAndType()
diff --git a/core/Tracker/ActionClickUrl.php b/core/Tracker/ActionClickUrl.php
index 82d6c312cc..18f55e6f26 100644
--- a/core/Tracker/ActionClickUrl.php
+++ b/core/Tracker/ActionClickUrl.php
@@ -29,12 +29,9 @@ class ActionClickUrl extends Action
 
     protected function getActionsToLookup()
     {
-        $actions = parent::getActionsToLookup();
-        // set the right type
-        $actions['idaction_url'][1] = $this->getActionType();
-
         return array(
-            'idaction_url' => $actions['idaction_url']
+            // Note: we do not normalize download/oulink URL
+            'idaction_url' => array($this->getActionUrl(), $this->getActionType())
         );
     }
 
diff --git a/core/Tracker/ActionSiteSearch.php b/core/Tracker/ActionSiteSearch.php
index fc9e6e374c..3c2c945b10 100644
--- a/core/Tracker/ActionSiteSearch.php
+++ b/core/Tracker/ActionSiteSearch.php
@@ -44,7 +44,7 @@ class ActionSiteSearch extends Action
     protected function getActionsToLookup()
     {
         return array(
-            'idaction_name' => array($this->getActionName(), ActionInterface::TYPE_SITE_SEARCH, $prefix = false),
+            'idaction_name' => array($this->getActionName(), ActionInterface::TYPE_SITE_SEARCH),
             'idaction_url' => $this->getUrlAndType()
         );
     }
diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php
index 0c5e1f330d..cddce27472 100644
--- a/core/Tracker/GoalManager.php
+++ b/core/Tracker/GoalManager.php
@@ -630,11 +630,6 @@ class GoalManager
             $actionsToLookupAllItems = array_merge($actionsToLookupAllItems, $actionsToLookup);
         }
 
-        // add prefixId = false expected by loadIdsFromLogActionTable()
-        foreach($actionsToLookupAllItems as &$actionToLookup) {
-            $actionToLookup[] = false;
-        }
-
         $actionsLookedUp = TableLogAction::loadIdsAction($actionsToLookupAllItems);
 
         // Replace SKU, name & category by their ID action
diff --git a/core/Tracker/TableLogAction.php b/core/Tracker/TableLogAction.php
index 25b838787c..4f2bb2b90b 100644
--- a/core/Tracker/TableLogAction.php
+++ b/core/Tracker/TableLogAction.php
@@ -36,7 +36,7 @@ class TableLogAction
 
     /**
      * This function will find the idaction from the lookup table piwik_log_action,
-     * given an Action name and type.
+     * given an Action name, type, and an optional URL Prefix.
      *
      * This is used to record Page URLs, Page Titles, Ecommerce items SKUs, item names, item categories
      *
@@ -46,6 +46,12 @@ class TableLogAction
      */
     public static function loadIdsAction($actionsNameAndType)
     {
+        // Add url prefix if not set
+        foreach($actionsNameAndType as &$action) {
+            if(count($action) == 2) {
+                $action[] = null;
+            }
+        }
         $actionIds = self::queryIdsAction($actionsNameAndType);
 
         list($queriedIds, $fieldNamesToInsert) = self::processIdsToInsert($actionsNameAndType, $actionIds);
diff --git a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
index 1fb49286fa..bd42b8eb57 100644
--- a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
+++ b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php
@@ -36,9 +36,9 @@ class Test_Piwik_Fixture_TwoSitesTwoVisitorsDifferentDays extends Test_Piwik_Bas
 
     private function setUpWebsitesAndGoals()
     {
-        // tests run in UTC, the Tracker in UTC
         $ecommerce = $this->allowConversions ? 1 : 0;
 
+        // tests run in UTC, the Tracker in UTC
         self::createWebsite($this->dateTime, $ecommerce, "Site 1");
         self::createWebsite($this->dateTime, 0, "Site 2");
 
diff --git a/tests/PHPUnit/Integration/OneVisitorTwoVisits_withCookieSupportTest.php b/tests/PHPUnit/Integration/OneVisitorTwoVisits_withCookieSupportTest.php
index f021f0711f..16665596ab 100755
--- a/tests/PHPUnit/Integration/OneVisitorTwoVisits_withCookieSupportTest.php
+++ b/tests/PHPUnit/Integration/OneVisitorTwoVisits_withCookieSupportTest.php
@@ -21,7 +21,10 @@ class Test_Piwik_Integration_OneVisitorTwoVisits_WithCookieSupport extends Integ
      */
     public function testApi($api, $params)
     {
+
+        //var_dump(\Piwik\Db::get()->fetchAll('select * from piwiktests_log_action' ));
         $this->runApiTests($api, $params);
+
     }
 
     public function getApiForTesting()
-- 
GitLab