From fd41dccadb6eaf07e1aff4e41153d87423b525d6 Mon Sep 17 00:00:00 2001
From: mattab <matthieu.aubry@gmail.com>
Date: Fri, 1 Nov 2013 14:31:16 +1300
Subject: [PATCH] Minor

---
 plugins/Actions/Archiver.php                 | 49 ++++++++++++--------
 plugins/CustomVariables/Archiver.php         |  3 +-
 plugins/PrivacyManager/LogDataPurger.php     |  4 +-
 plugins/Transitions/API.php                  |  5 +-
 tests/PHPUnit/Core/ReleaseCheckListTest.php  |  3 +-
 tests/PHPUnit/Plugins/PrivacyManagerTest.php |  2 +-
 6 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php
index 680402c2e8..862e5d496c 100644
--- a/plugins/Actions/Archiver.php
+++ b/plugins/Actions/Archiver.php
@@ -129,6 +129,34 @@ class Archiver extends \Piwik\Plugin\Archiver
         return " AND log_link_visit_action.idaction_event_category IS NULL";
     }
 
+    /**
+     * @param $select
+     * @param $from
+     */
+    protected function updateQuerySelectFromForSiteSearch(&$select, &$from)
+    {
+        $selectFlagNoResultKeywords = ",
+				CASE WHEN (MAX(log_link_visit_action.custom_var_v" . ActionSiteSearch::CVAR_INDEX_SEARCH_COUNT . ") = 0
+				    AND log_link_visit_action.custom_var_k" . ActionSiteSearch::CVAR_INDEX_SEARCH_COUNT . " = '" . ActionSiteSearch::CVAR_KEY_SEARCH_COUNT . "')
+				THEN 1 ELSE 0 END
+				    AS `" . Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT . "`";
+
+        //we need an extra JOIN to know whether the referrer "idaction_name_ref" was a Site Search request
+        $from[] = array(
+            "table"      => "log_action",
+            "tableAlias" => "log_action_name_ref",
+            "joinOn"     => "log_link_visit_action.idaction_name_ref = log_action_name_ref.idaction"
+        );
+
+        $selectPageIsFollowingSiteSearch = ",
+				SUM( CASE WHEN log_action_name_ref.type = " . Action::TYPE_SITE_SEARCH . "
+				      THEN 1 ELSE 0 END)
+                    AS `" . Metrics::INDEX_PAGE_IS_FOLLOWING_SITE_SEARCH_NB_HITS . "`";
+
+        $select .= $selectFlagNoResultKeywords
+            . $selectPageIsFollowingSiteSearch;
+    }
+
     /**
      * Initializes the DataTables created by the archiveDay function.
      */
@@ -216,26 +244,7 @@ class Archiver extends \Piwik\Plugin\Archiver
         // 1) No result Keywords
         // 2) For each page view, count number of times the referrer page was a Site Search
         if ($this->isSiteSearchEnabled()) {
-            $selectFlagNoResultKeywords = ",
-				CASE WHEN (MAX(log_link_visit_action.custom_var_v" . ActionSiteSearch::CVAR_INDEX_SEARCH_COUNT . ") = 0
-				    AND log_link_visit_action.custom_var_k" . ActionSiteSearch::CVAR_INDEX_SEARCH_COUNT . " = '" . ActionSiteSearch::CVAR_KEY_SEARCH_COUNT . "')
-				THEN 1 ELSE 0 END
-				    AS `" . Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT . "`";
-
-            //we need an extra JOIN to know whether the referrer "idaction_name_ref" was a Site Search request
-            $from[] = array(
-                "table"      => "log_action",
-                "tableAlias" => "log_action_name_ref",
-                "joinOn"     => "log_link_visit_action.idaction_name_ref = log_action_name_ref.idaction"
-            );
-
-            $selectPageIsFollowingSiteSearch = ",
-				SUM( CASE WHEN log_action_name_ref.type = " . Action::TYPE_SITE_SEARCH. "
-				      THEN 1 ELSE 0 END)
-                    AS `"    . Metrics::INDEX_PAGE_IS_FOLLOWING_SITE_SEARCH_NB_HITS . "`";
-
-            $select .= $selectFlagNoResultKeywords
-                . $selectPageIsFollowingSiteSearch;
+                $this->updateQuerySelectFromForSiteSearch($select, $from);
         }
 
         $this->archiveDayQueryProcess($select, $from, $where, $orderBy, $groupBy, "idaction_name", $rankingQuery);
diff --git a/plugins/CustomVariables/Archiver.php b/plugins/CustomVariables/Archiver.php
index 81a8755885..49c29e2cdd 100644
--- a/plugins/CustomVariables/Archiver.php
+++ b/plugins/CustomVariables/Archiver.php
@@ -85,8 +85,7 @@ class Archiver extends \Piwik\Plugin\Archiver
     protected function getSelectAveragePrice()
     {
         $field = "custom_var_v" . \PiwikTracker::CVAR_INDEX_ECOMMERCE_ITEM_PRICE;
-        return LogAggregator::getSqlRevenue("AVG(log_link_visit_action.{$field})")
-        . " as `" . Metrics::INDEX_ECOMMERCE_ITEM_PRICE_VIEWED . "`";
+        return LogAggregator::getSqlRevenue("AVG(log_link_visit_action." . $field . ")") . " as `" . Metrics::INDEX_ECOMMERCE_ITEM_PRICE_VIEWED . "`";
     }
 
     protected function aggregateFromVisits($query, $keyField, $valueField)
diff --git a/plugins/PrivacyManager/LogDataPurger.php b/plugins/PrivacyManager/LogDataPurger.php
index 8b953172a4..e648a00f0c 100755
--- a/plugins/PrivacyManager/LogDataPurger.php
+++ b/plugins/PrivacyManager/LogDataPurger.php
@@ -269,7 +269,9 @@ class LogDataPurger
             'log_link_visit_action' => array('idaction_url',
                                              'idaction_url_ref',
                                              'idaction_name',
-                                             'idaction_name_ref'),
+                                             'idaction_name_ref',
+                                             'idaction_event_category',
+                                             'idaction_event_action'),
 
             'log_conversion'        => array('idaction_url'),
 
diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php
index 8aed9317f3..4972c7dfad 100644
--- a/plugins/Transitions/API.php
+++ b/plugins/Transitions/API.php
@@ -21,7 +21,6 @@ use Piwik\DataTable\Row;
 use Piwik\DataTable;
 use Piwik\Metrics;
 use Piwik\Period;
-use Piwik\Period\Day;
 use Piwik\Piwik;
 use Piwik\Plugins\Actions\Actions;
 use Piwik\Plugins\Actions\ArchivingHelper;
@@ -149,9 +148,7 @@ class API extends \Piwik\Plugin\API
                 $id = $actionsPlugin->getIdActionFromSegment($actionName, 'idaction_name', SegmentExpression::MATCH_EQUAL, 'pageTitle');
 
                 if ($id < 0) {
-                    $unknown = ArchivingHelper::getUnknownActionName(
-                        Action::TYPE_PAGE_TITLE);
-
+                    $unknown = ArchivingHelper::getUnknownActionName(Action::TYPE_PAGE_TITLE);
                     if (trim($actionName) == trim($unknown)) {
                         $id = $actionsPlugin->getIdActionFromSegment('', 'idaction_name', SegmentExpression::MATCH_EQUAL, 'pageTitle');
                     }
diff --git a/tests/PHPUnit/Core/ReleaseCheckListTest.php b/tests/PHPUnit/Core/ReleaseCheckListTest.php
index df09b3e345..e7dfe6d939 100644
--- a/tests/PHPUnit/Core/ReleaseCheckListTest.php
+++ b/tests/PHPUnit/Core/ReleaseCheckListTest.php
@@ -1,7 +1,6 @@
 <?php
 use Piwik\Filesystem;
 use Piwik\SettingsServer;
-use Piwik\Tracker\Db;
 
 /**
  * Piwik - Open source web analytics
@@ -140,7 +139,7 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase
     public function testProfilingDisabledInProduction()
     {
         require_once 'Tracker/Db.php';
-        $this->assertTrue(Db::isProfilingEnabled() === false, 'SQL profiler should be disabled in production! See Db::$profiling');
+        $this->assertTrue(\Piwik\Tracker\Db::isProfilingEnabled() === false, 'SQL profiler should be disabled in production! See Db::$profiling');
     }
 
     /**
diff --git a/tests/PHPUnit/Plugins/PrivacyManagerTest.php b/tests/PHPUnit/Plugins/PrivacyManagerTest.php
index 2b57df702e..3668995bc2 100755
--- a/tests/PHPUnit/Plugins/PrivacyManagerTest.php
+++ b/tests/PHPUnit/Plugins/PrivacyManagerTest.php
@@ -873,7 +873,7 @@ class PrivacyManagerTest extends IntegrationTestCase
         // 5 entries per period w/ visits
         // + 1 entry for every period in the month (the 'done' rows)
         // + 1 garbage metric
-        // + 2 entries per range period (4 total) + 2 'done...' entries per range period (4 total)
+        // log_link_visit_action+ 2 entries per range period (4 total) + 2 'done...' entries per range period (4 total)
         // + 2 entries per segment (2 total) + 2 'done...' entries per segment (2 total)
         return self::JAN_METRIC_ARCHIVE_COUNT * 5 + self::TOTAL_JAN_ARCHIVE_COUNT + 1 + 8 + 4;
     }
-- 
GitLab