diff --git a/core/Nonce.php b/core/Nonce.php index fecaaa776440312bf775c9be8e7dc6df9f2fa4e6..825b9aea5690fa351f0d0646b9165e9c6b178869 100644 --- a/core/Nonce.php +++ b/core/Nonce.php @@ -140,8 +140,10 @@ class Nonce } // standard ports - $origins[] = 'http://' . $host; - $origins[] = 'https://' . $host; + $origins = array( + 'http://' . $host, + 'https://' . $host, + ); // non-standard ports if (!empty($port) && $port != 80 && $port != 443) { diff --git a/core/Updater.php b/core/Updater.php index 6cd6bf757f8eb567f4c50d5d25721babbdc2b977..1527da723a9ec778daa025c994a5e1cc14969915 100644 --- a/core/Updater.php +++ b/core/Updater.php @@ -231,7 +231,6 @@ class Updater private function loadComponentsWithUpdateFile() { $componentsWithUpdateFile = array(); - $hasDimensionUpdate = null; foreach ($this->componentsWithNewVersion as $name => $versions) { $currentVersion = $versions[self::INDEX_CURRENT_VERSION]; diff --git a/js/tracker.php b/js/tracker.php index 4a86e53977e54973b553adcfb0d87f694fd10595..0a842b8c0fdcfefdb752442ebdce68a8bc978ff0 100644 --- a/js/tracker.php +++ b/js/tracker.php @@ -33,7 +33,6 @@ $file = '../piwik.js'; $daysExpireFarFuture = 10; -$compressFileSuffix = false; $byteStart = $byteEnd = false; if (!defined("PIWIK_KEEP_JS_TRACKER_COMMENT") || !PIWIK_KEEP_JS_TRACKER_COMMENT diff --git a/misc/others/geoipUpdateRows.php b/misc/others/geoipUpdateRows.php index fa43c5d6c48b02021cb84e0f23e9cffbb299142a..df480d395d974042e0b4718803bab04fdba9d63c 100755 --- a/misc/others/geoipUpdateRows.php +++ b/misc/others/geoipUpdateRows.php @@ -172,7 +172,7 @@ for (; $start < $end; $start += $limit) { continue; } - foreach ($rows as $i => $row) { + foreach ($rows as $row) { $fieldsToSet = array(); foreach ($logVisitFieldsToUpdate as $field => $ignore) { if (empty($fieldsToSet[$field])) { diff --git a/misc/others/test_generateLotsVisitsWebsites.php b/misc/others/test_generateLotsVisitsWebsites.php index 4dd23c5f5148ea83f32272e3ceed7feb4d203ade..33f050fc7750bbb9740367536bcd7f719088d348 100644 --- a/misc/others/test_generateLotsVisitsWebsites.php +++ b/misc/others/test_generateLotsVisitsWebsites.php @@ -58,7 +58,7 @@ class Piwik_StressTests_CopyLogs SELECT `idsite`, `idvisitor`, `visitor_localtime`, `visitor_returning`, `visitor_count_visits`, CONCAT(CURRENT_DATE() , \" \", FLOOR(RAND()*24) , \":\",FLOOR(RAND()*60),\":\",FLOOR(RAND()*60)), CONCAT(CURRENT_DATE() , \" \", FLOOR(RAND()*24) , \":\",FLOOR(RAND()*60),\":\",FLOOR(RAND()*60)), `visit_exit_idaction_url`, `visit_exit_idaction_name`, `visit_entry_idaction_url`, `visit_entry_idaction_name`, `visit_total_actions`, `visit_total_time`, `visit_goal_converted`, `visit_goal_buyer`, `referer_type`, `referer_name`, `referer_url`, `referer_keyword`, `config_id`, `config_os`, `config_browser_name`, `config_browser_version`, `config_resolution`, `config_pdf`, `config_flash`, `config_java`, `config_director`, `config_quicktime`, `config_realplayer`, `config_windowsmedia`, `config_gears`, `config_silverlight`, `config_cookie`, `location_ip`, `location_browser_lang`, `location_country`, `location_provider`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `visitor_days_since_last`, `visitor_days_since_order`, `visitor_days_since_first` FROM `" . Common::prefixTable('log_visit') . "` WHERE idsite >= 1 AND date(visit_last_action_time) between '$startDate' and '$endDate' ;"; - $result = $db->query($sql); + $db->query($sql); $this->log(" Copying actions..."); $sql = "INSERT INTO " . Common::prefixTable('log_link_visit_action') . " (`idsite`, `idvisitor`, `server_time`, `idvisit`, `idaction_url`, `idaction_url_ref`, `idaction_name`, `idaction_name_ref`, `time_spent_ref_action`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`) @@ -67,21 +67,21 @@ class Piwik_StressTests_CopyLogs WHERE idsite >= 1 AND date(server_time) between '$startDate' and '$endDate' ;"; // LIMIT 1000000 - $result = $db->query($sql); + $db->query($sql); $this->log(" Copying conversions..."); $sql = "INSERT IGNORE INTO `" . Common::prefixTable('log_conversion') . "` (`idvisit`, `idsite`, `visitor_days_since_first`, `visitor_days_since_order`, `visitor_count_visits`, `idvisitor`, `server_time`, `idaction_url`, `idlink_va`, `referer_visit_server_date`, `referer_type`, `referer_name`, `referer_keyword`, `visitor_returning`, `location_country`, `url`, `idgoal`, `revenue`, `buster`, `idorder`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `items`, `revenue_subtotal`, `revenue_tax`, `revenue_shipping`, `revenue_discount`) SELECT `idvisit`, `idsite`, `visitor_days_since_first`, `visitor_days_since_order`, `visitor_count_visits`, `idvisitor`, CONCAT(CURRENT_DATE() , \" \", FLOOR(RAND()*24) , \":\",FLOOR(RAND()*60),\":\",FLOOR(RAND()*60)), `idaction_url`, `idlink_va`, `referer_visit_server_date`, `referer_type`, `referer_name`, `referer_keyword`, `visitor_returning`, `location_country`, `url`, `idgoal`, `revenue`, FLOOR(`buster` * RAND()), CONCAT(`idorder`,SUBSTRING(MD5(RAND()) FROM 1 FOR 9)) , `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `items`, `revenue_subtotal`, `revenue_tax`, `revenue_shipping`, `revenue_discount` FROM `" . Common::prefixTable('log_conversion') . "` WHERE idsite >= 1 AND date(server_time) between '$startDate' and '$endDate' ;"; - $result = $db->query($sql); + $db->query($sql); $this->log(" Copying purchased items..."); $sql = "INSERT INTO `" . Common::prefixTable('log_conversion_item') . "` (`idsite`, `idvisitor`, `server_time`, `idvisit`, `idorder`, `idaction_sku`, `idaction_name`, `idaction_category`, `price`, `quantity`, `deleted`) SELECT `idsite`, `idvisitor`, CONCAT(CURRENT_DATE() , \" \", TIME(`server_time`)), `idvisit`, CONCAT(`idorder`,SUBSTRING(MD5(RAND()) FROM 1 FOR 9)) , `idaction_sku`, `idaction_name`, `idaction_category`, `price`, `quantity`, `deleted` FROM `" . Common::prefixTable('log_conversion_item') . "` WHERE idsite >= 1 AND date(server_time) between '$startDate' and '$endDate' ;"; - $result = $db->query($sql); + $db->query($sql); $now = $this->getVisitsToday(); $actions = $this->getActionsToday(); diff --git a/plugins/API/ProcessedReport.php b/plugins/API/ProcessedReport.php index 86a7fd169830c40961a29c0a96aeb53b9295ab70..ef1fcf618211cf6b4a1f62925e343bceca36eb8e 100644 --- a/plugins/API/ProcessedReport.php +++ b/plugins/API/ProcessedReport.php @@ -449,7 +449,7 @@ class ProcessedReport list($newReport, $columns, $rowsMetadata, $totals) = $this->handleTableReport($idSite, $dataTable, $reportMetadata, $showRawMetrics); - foreach ($columns as $columnId => &$name) { + foreach ($columns as &$name) { $name = ucfirst($name); } $website = new Site($idSite); @@ -534,7 +534,7 @@ class ProcessedReport $rowsMetadata->setKeyName("prettyDate"); // Process each Simple entry - foreach ($dataTable->getDataTables() as $label => $simpleDataTable) { + foreach ($dataTable->getDataTables() as $simpleDataTable) { $this->removeEmptyColumns($columns, $reportMetadata, $simpleDataTable); list($enhancedSimpleDataTable, $rowMetadata) = $this->handleSimpleDataTable($idSite, $simpleDataTable, $columns, $hasDimension, $showRawMetrics); diff --git a/plugins/API/RowEvolution.php b/plugins/API/RowEvolution.php index 69bb5e2f5643142c0580544b357daab9c4f5ee03..84bc431c4765d3b90e64d964175656462c92932b 100644 --- a/plugins/API/RowEvolution.php +++ b/plugins/API/RowEvolution.php @@ -144,7 +144,7 @@ class RowEvolution $logo = $actualLabel = false; $urlFound = false; - foreach ($dataTable->getDataTables() as $date => $subTable) { + foreach ($dataTable->getDataTables() as $subTable) { /** @var $subTable DataTable */ $subTable->applyQueuedFilters(); if ($subTable->getRowsCount() > 0) { diff --git a/plugins/Actions/API.php b/plugins/Actions/API.php index c91506088584a1e04c04cc29b2ab43f4c9b0deeb..ed161bdfecd8b5c3928ffb15c2c265bee55c2794 100644 --- a/plugins/Actions/API.php +++ b/plugins/Actions/API.php @@ -81,8 +81,10 @@ class API extends \Piwik\Plugin\API } if ($avgGenerationTimeRequested) { - $tempColumns[] = Archiver::METRIC_SUM_TIME_RECORD_NAME; - $tempColumns[] = Archiver::METRIC_HITS_TIMED_RECORD_NAME; + $tempColumns = array( + Archiver::METRIC_SUM_TIME_RECORD_NAME, + Archiver::METRIC_HITS_TIMED_RECORD_NAME, + ); $columns = array_merge($columns, $tempColumns); $columns = array_unique($columns); @@ -342,7 +344,6 @@ class API extends \Piwik\Plugin\API $dataTable = $customVariables->getEmptyClone(); $customVariableDatatables = $customVariables->getDataTables(); - $dataTables = $dataTable->getDataTables(); foreach ($customVariableDatatables as $key => $customVariableTableForDate) { // we do not enter the IF, in the case idSite=1,3 AND period=day&date=datefrom,dateto, if ($customVariableTableForDate instanceof DataTable diff --git a/plugins/CoreVisualizations/JqplotDataGenerator/Evolution.php b/plugins/CoreVisualizations/JqplotDataGenerator/Evolution.php index 3de82dbc17da5f2600049e6bcf0325ca0db5b89c..0fdaa2c1eb2e4841048934e2507e9514f06e0a36 100644 --- a/plugins/CoreVisualizations/JqplotDataGenerator/Evolution.php +++ b/plugins/CoreVisualizations/JqplotDataGenerator/Evolution.php @@ -78,7 +78,7 @@ class Evolution extends JqplotDataGenerator $axisXOnClick = array(); $queryStringAsHash = $this->getQueryStringAsHash(); - foreach ($dataTable->getDataTables() as $idDataTable => $metadataDataTable) { + foreach ($dataTable->getDataTables() as $metadataDataTable) { $dateInUrl = $metadataDataTable->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getDateStart(); $parameters = array( 'idSite' => $idSite, diff --git a/plugins/CoreVisualizations/Visualizations/Cloud.php b/plugins/CoreVisualizations/Visualizations/Cloud.php index 6598f97b899a16fbc4c81409191bde510da0cbe3..0a78e219e6d5231dcb72300c382e6e7dd2b626d6 100644 --- a/plugins/CoreVisualizations/Visualizations/Cloud.php +++ b/plugins/CoreVisualizations/Visualizations/Cloud.php @@ -143,7 +143,7 @@ class Cloud extends Visualization $tmpArray = $this->wordsArray; $this->wordsArray = array(); - foreach ($keys as $key => $value) { + foreach ($keys as $value) { $this->wordsArray[$value] = $tmpArray[$value]; } diff --git a/plugins/Goals/Visualizations/Goals.php b/plugins/Goals/Visualizations/Goals.php index 512ca91633e0059b85f23348bb16de679f975e0b..0b8c2c5365523f9c60fe344a7b925922edd14617 100644 --- a/plugins/Goals/Visualizations/Goals.php +++ b/plugins/Goals/Visualizations/Goals.php @@ -191,7 +191,7 @@ class Goals extends HtmlTable // set columns to display (columns of same type but different goals will be next to each other, // ie, goal_0_nb_conversions, goal_1_nb_conversions, etc.) - foreach ($goalColumnTemplates as $idx => $columnTemplate) { + foreach ($goalColumnTemplates as $columnTemplate) { foreach ($idGoals as $idGoal) { $this->config->columns_to_display[] = sprintf($columnTemplate, $idGoal); } diff --git a/plugins/ImageGraph/StaticGraph.php b/plugins/ImageGraph/StaticGraph.php index 6c6fbb27052ec7fe4e1cc4f288ecce51340dd03f..b21d5e35ac2230aab638322a9b0da6eb779e1b4e 100644 --- a/plugins/ImageGraph/StaticGraph.php +++ b/plugins/ImageGraph/StaticGraph.php @@ -311,7 +311,7 @@ abstract class StaticGraph $maxWidth = 0; $maxHeight = 0; - foreach ($values as $column => $data) { + foreach ($values as $data) { foreach ($data as $value) { list($valueWidth, $valueHeight) = $this->getTextWidthHeight($value); diff --git a/plugins/LanguagesManager/Commands/CompareKeys.php b/plugins/LanguagesManager/Commands/CompareKeys.php index 9fb1478392b09b48b58bed5826cdcb062e4560df..a5998f79caf21b9c57bb9f24b9bfd14ca64791c6 100644 --- a/plugins/LanguagesManager/Commands/CompareKeys.php +++ b/plugins/LanguagesManager/Commands/CompareKeys.php @@ -30,8 +30,6 @@ class CompareKeys extends ConsoleCommand protected function execute(InputInterface $input, OutputInterface $output) { - $dialog = $this->getHelperSet()->get('dialog'); - $command = $this->getApplication()->find('translations:fetch'); $arguments = array( 'command' => 'translations:fetch', diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php index b09d3344d6eb7e00aa0780430ac1b427c60d4a0b..b4c1c3eb06ee91871044c63f1024a87477700e97 100644 --- a/plugins/Live/Visitor.php +++ b/plugins/Live/Visitor.php @@ -892,7 +892,7 @@ class Visitor implements VisitorInterface // Enrich ecommerce carts/orders with the list of products usort($ecommerceDetails, array('static', 'sortByServerTime')); - foreach ($ecommerceDetails as $key => &$ecommerceConversion) { + foreach ($ecommerceDetails as &$ecommerceConversion) { $sql = "SELECT log_action_sku.name as itemSKU, log_action_name.name as itemName, diff --git a/plugins/MultiSites/API.php b/plugins/MultiSites/API.php index 37f3b73b0b050a291ff8f77e2147b0ef2dc280fa..5a6ef950c5cad54dfe85beb625d5eeb5f15e4ddd 100755 --- a/plugins/MultiSites/API.php +++ b/plugins/MultiSites/API.php @@ -398,11 +398,6 @@ class API extends \Piwik\Plugin\API $this->setMetricsTotalsMetadata($table, $apiMetrics); } } else { - $revenueMetric = ''; - if (Common::isGoalPluginEnabled()) { - $revenueMetric = Archiver::getRecordName(self::GOAL_REVENUE_METRIC); - } - $totals = array(); foreach ($apiMetrics as $label => $metricInfo) { $totalMetadataName = self::getTotalMetadataName($label); diff --git a/plugins/Referrers/API.php b/plugins/Referrers/API.php index 9f97da3fe72ff60deb9fad78e2fabc525a38f296..a2c747141b634c7a210d8da069b03174b031deff 100644 --- a/plugins/Referrers/API.php +++ b/plugins/Referrers/API.php @@ -452,7 +452,7 @@ class API extends \Piwik\Plugin\API $socialName = $row->getColumn('label'); $i = 1; // start at one because idSubtable=0 is equivalent to idSubtable=false - foreach (Common::getSocialUrls() as $domain => $name) { + foreach (Common::getSocialUrls() as $name) { if ($name == $socialName) { $row->c[Row::DATATABLE_ASSOCIATED] = $i; break; diff --git a/plugins/SegmentEditor/SegmentSelectorControl.php b/plugins/SegmentEditor/SegmentSelectorControl.php index 9188a707dba0d3e186bea6550b0a0520a15e03f7..bb58caa29762c6cf20eeb6ff443569669d46582c 100644 --- a/plugins/SegmentEditor/SegmentSelectorControl.php +++ b/plugins/SegmentEditor/SegmentSelectorControl.php @@ -39,7 +39,7 @@ class SegmentSelectorControl extends UIControl $segments = APIMetadata::getInstance()->getSegmentsMetadata($this->idSite); - $segmentsByCategory = $customVariablesSegments = array(); + $segmentsByCategory = array(); foreach ($segments as $segment) { if ($segment['category'] == Piwik::translate('General_Visit') && ($segment['type'] == 'metric' && $segment['segment'] != 'visitIp') diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php index 0e65eff82474aecbf3ea03d30d881a4ccac2acef..faeddf9f0b66ac54c856205a8af44b60b8fbaaa9 100644 --- a/plugins/Transitions/API.php +++ b/plugins/Transitions/API.php @@ -128,7 +128,6 @@ class API extends \Piwik\Plugin\API */ private function deriveIdAction($actionName, $actionType) { - $actionsPlugin = new Actions; switch ($actionType) { case 'url': $originalActionName = $actionName; diff --git a/plugins/UsersManager/LastSeenTimeLogger.php b/plugins/UsersManager/LastSeenTimeLogger.php index 61e6c8b1308ab6058ff939b2fedf21862fa5edc8..a89ebd00184f8a8f958c07a57f3cc70ca2f30b0b 100644 --- a/plugins/UsersManager/LastSeenTimeLogger.php +++ b/plugins/UsersManager/LastSeenTimeLogger.php @@ -35,7 +35,6 @@ class LastSeenTimeLogger public function logCurrentUserLastSeenTime() { $module = Common::getRequestVar('module', false); - $action = Common::getRequestVar('action', false); $currentUserLogin = Piwik::getCurrentUserLogin(); // only log time for non-anonymous visits to the reporting UI diff --git a/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php b/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php index c1888c6c852fd5ea937764297b022f22b44cba46..564d80ed53863dcbf788f11e2dcd984f967c7b3b 100755 --- a/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php +++ b/tests/PHPUnit/Benchmarks/Fixtures/ThousandSitesTwelveVisitsEachOneDay.php @@ -19,26 +19,12 @@ class Piwik_Test_Fixture_ThousandSitesTwelveVisitsEachOneDay public function setUp() { - $goals = APIGoals::getInstance(); - // add one thousand sites $allIdSites = array(); for ($i = 0; $i < 1000; ++$i) { $allIdSites[] = Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #$i"); } - // add goals to 500 sites - $idGoals = array(); - foreach ($allIdSites as $idSite) { - if ($idSite % 2 == 0) { - $idGoal1 = $goals->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5); - $idGoal2 = $goals->addGoal($idSite, 'all', 'url', 'http', 'contains'); - $idGoals[$idSite] = array($idGoal1, $idGoal2); - } else { - $idGoals[$idSite] = array(); - } - } - $urls = array(); for ($i = 0; $i != 3; ++$i) { $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1); diff --git a/tests/PHPUnit/Core/CookieTest.php b/tests/PHPUnit/Core/CookieTest.php index d222184fc9be5a449fde77adea5e217ae68e025b..d173e60f4c0d6e69cc7dcf50dab7edaf273dc452 100644 --- a/tests/PHPUnit/Core/CookieTest.php +++ b/tests/PHPUnit/Core/CookieTest.php @@ -98,7 +98,7 @@ class CookieTest extends PHPUnit_Framework_TestCase * serialize() uses its internal maachine representation when floats expressed in E-notation, * which may vary between php versions, OS, and hardware platforms */ - $testData = $tests['exp float'] = -5.0E+142; + $testData = -5.0E+142; // intentionally disabled; this doesn't work // $this->assertEquals( safe_serialize($testData), serialize($testData) ); $this->assertEquals($testData, unserialize(safe_serialize($testData))); diff --git a/tests/PHPUnit/Core/DataTable/Filter/LimitTest.php b/tests/PHPUnit/Core/DataTable/Filter/LimitTest.php index e5a4a3a7b7d9e22fa318882c5c77e1c09001e305..14705926a50c2aec9f9216c5e491f9303316d5f4 100644 --- a/tests/PHPUnit/Core/DataTable/Filter/LimitTest.php +++ b/tests/PHPUnit/Core/DataTable/Filter/LimitTest.php @@ -222,10 +222,6 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $filter = new Limit($table, 2, 4); $filter->filter($table); - $colAfter = $colExpected = array(); - foreach ($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); - foreach ($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); - $this->assertEquals(array_values($expectedtable->getRows()), array_values($table->getRows())); } @@ -258,10 +254,6 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $filter = new Limit($table, 2, 1); $filter->filter($table); - $colAfter = $colExpected = array(); - foreach ($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); - foreach ($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); - $this->assertEquals(array_values($expectedtable->getRows()), array_values($table->getRows())); } @@ -293,10 +285,6 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $filter = new Limit($table, 0, 15); $filter->filter($table); - $colAfter = $colExpected = array(); - foreach ($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); - foreach ($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); - $this->assertEquals(array_values($expectedtable->getRows()), array_values($table->getRows())); } @@ -328,10 +316,6 @@ class DataTable_Filter_LimitTest extends PHPUnit_Framework_TestCase $filter = new Limit($table, 8, 15); $filter->filter($table); - $colAfter = $colExpected = array(); - foreach ($table->getRows() as $row) $colAfter[] = $row->getColumn('label'); - foreach ($expectedtable->getRows() as $row) $colExpected[] = $row->getColumn('label'); - $this->assertEquals(array_values($expectedtable->getRows()), array_values($table->getRows())); } diff --git a/tests/PHPUnit/Core/DataTableTest.php b/tests/PHPUnit/Core/DataTableTest.php index 5388a8117c6326d7a59fc6b2fa76c993a49e389f..97d53e860ea41f533074a3a2bbafd9c06b5563fc 100644 --- a/tests/PHPUnit/Core/DataTableTest.php +++ b/tests/PHPUnit/Core/DataTableTest.php @@ -436,7 +436,6 @@ class DataTableTest extends PHPUnit_Framework_TestCase * does not take in consideration those tables * -> we check that the DataTable_Manager is not impacting DataTable */ - $useless2 = new DataTable; $useless1->addRowFromArray(array(Row::COLUMNS => array(8487,),)); $useless3 = new DataTable; $useless3->addRowFromArray(array(Row::COLUMNS => array(8487,),)); diff --git a/tests/PHPUnit/Core/Period/DayTest.php b/tests/PHPUnit/Core/Period/DayTest.php index 694ecad0d5de1cec35551f17ccfd15b1f145ced1..8321a3bddce4d5fa07c3f7e3b4027f43c52229d9 100644 --- a/tests/PHPUnit/Core/Period/DayTest.php +++ b/tests/PHPUnit/Core/Period/DayTest.php @@ -20,7 +20,7 @@ class Period_DayTest extends PHPUnit_Framework_TestCase public function testInvalidDate() { try { - $period = new Day('Invalid Date'); + new Day('Invalid Date'); } catch (Exception $e) { return; } diff --git a/tests/PHPUnit/Core/PeriodTest.php b/tests/PHPUnit/Core/PeriodTest.php index f3be99517971b29be6670e82d5d6e2ab1e20c547..8888c4c763670ac275491c0bfe825eae63102cf0 100644 --- a/tests/PHPUnit/Core/PeriodTest.php +++ b/tests/PHPUnit/Core/PeriodTest.php @@ -94,7 +94,7 @@ class PeriodTest extends PHPUnit_Framework_TestCase public function testFactoryInvalid() { try { - $period = Period\Factory::build('inValid', Date::today()); + Period\Factory::build('inValid', Date::today()); } catch (Exception $e) { return; } diff --git a/tests/PHPUnit/Core/ServeStaticFileTest.php b/tests/PHPUnit/Core/ServeStaticFileTest.php index ef65358d6baa93c54360fea6457417ff3e0bed1e..143b83944ad995994edf06a9c6e8b4c64f5ece7a 100644 --- a/tests/PHPUnit/Core/ServeStaticFileTest.php +++ b/tests/PHPUnit/Core/ServeStaticFileTest.php @@ -329,7 +329,7 @@ class Test_Piwik_ServeStaticFile extends PHPUnit_Framework_TestCase curl_setopt($curlHandle, CURLOPT_URL, $this->getTestFileSrvModeUrl()); curl_setopt($curlHandle, CURLOPT_ENCODING, "deflate"); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); - $fullResponse = curl_exec($curlHandle); + curl_exec($curlHandle); curl_close($curlHandle); $firstAccessModificationTime = filemtime($deflateFileLocation); @@ -341,7 +341,7 @@ class Test_Piwik_ServeStaticFile extends PHPUnit_Framework_TestCase curl_setopt($curlHandle, CURLOPT_URL, $this->getTestFileSrvModeUrl()); curl_setopt($curlHandle, CURLOPT_ENCODING, "deflate"); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); - $fullResponse = curl_exec($curlHandle); + curl_exec($curlHandle); curl_close($curlHandle); // Tests the .deflate file has not been generated twice @@ -370,7 +370,7 @@ class Test_Piwik_ServeStaticFile extends PHPUnit_Framework_TestCase curl_setopt($curlHandle, CURLOPT_URL, $this->getTestFileSrvModeUrl()); curl_setopt($curlHandle, CURLOPT_ENCODING, "deflate"); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); - $fullResponse = curl_exec($curlHandle); + curl_exec($curlHandle); curl_close($curlHandle); $firstAccessModificationTime = filemtime($deflateFileLocation); @@ -385,7 +385,7 @@ class Test_Piwik_ServeStaticFile extends PHPUnit_Framework_TestCase curl_setopt($curlHandle, CURLOPT_URL, $this->getTestFileSrvModeUrl()); curl_setopt($curlHandle, CURLOPT_ENCODING, "deflate"); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); - $fullResponse = curl_exec($curlHandle); + curl_exec($curlHandle); curl_close($curlHandle); clearstatcache(); @@ -435,7 +435,7 @@ class Test_Piwik_ServeStaticFile extends PHPUnit_Framework_TestCase curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlHandle, CURLOPT_ENCODING, "deflate"); $partialResponse = curl_exec($curlHandle); - $responseInfo = curl_getinfo($curlHandle); + curl_getinfo($curlHandle); curl_close($curlHandle); clearstatcache(); @@ -464,7 +464,7 @@ class Test_Piwik_ServeStaticFile extends PHPUnit_Framework_TestCase curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlHandle, CURLOPT_ENCODING, "deflate"); $fullResponse = curl_exec($curlHandle); - $responseInfo = curl_getinfo($curlHandle); + curl_getinfo($curlHandle); curl_close($curlHandle); clearstatcache(); diff --git a/tests/PHPUnit/Core/Translate/WriterTest.php b/tests/PHPUnit/Core/Translate/WriterTest.php index cdf142217096e65f7dcf3f483c3c7bb8be204566..c62ca6cb35983c40187f32cadbcd0e3407b0db4f 100644 --- a/tests/PHPUnit/Core/Translate/WriterTest.php +++ b/tests/PHPUnit/Core/Translate/WriterTest.php @@ -50,7 +50,7 @@ class WriterTest extends PHPUnit_Framework_TestCase */ public function testConstructorInvalid() { - $translationWriter = new Writer('en', 'InValIdPlUGin'); + new Writer('en', 'InValIdPlUGin'); } /** diff --git a/tests/PHPUnit/Core/UnzipTest.php b/tests/PHPUnit/Core/UnzipTest.php index b7115ec2f1794879128c4d0adf1e269a26448988..12f754c8b7c2970fb3d22509d0d15e518670f6a6 100644 --- a/tests/PHPUnit/Core/UnzipTest.php +++ b/tests/PHPUnit/Core/UnzipTest.php @@ -121,7 +121,6 @@ class UnzipTest extends PHPUnit_Framework_TestCase { clearstatcache(); $filename = dirname(__FILE__) . '/Unzip/zaabs.zip'; - $extractDir = PIWIK_USER_PATH . '/tmp/latest/'; $unzip = new ZipArchive($filename); $this->assertContains('No error', $unzip->errorInfo()); @@ -150,7 +149,7 @@ class UnzipTest extends PHPUnit_Framework_TestCase $filename = dirname(__FILE__) . '/Unzip/NotExisting.zip'; try { - $unzip = new ZipArchive($filename); + new ZipArchive($filename); } catch (Exception $e) { return; } diff --git a/tests/PHPUnit/Fixture.php b/tests/PHPUnit/Fixture.php index 05bf19ad0f6448f6a0d30a6ac750cee8497c5a1f..d09ee974f34ae3a2af4ea9f16135e75deccf2247 100644 --- a/tests/PHPUnit/Fixture.php +++ b/tests/PHPUnit/Fixture.php @@ -689,10 +689,8 @@ class Fixture extends PHPUnit_Framework_Assert $dump = fopen($url, 'rb'); $outfile = fopen($outfileName, 'wb'); - $bytesRead = 0; while (!feof($dump)) { fwrite($outfile, fread($dump, $bufferSize), $bufferSize); - $bytesRead += $bufferSize; } fclose($dump); fclose($outfile); diff --git a/tests/PHPUnit/Integration/AnnotationsTest.php b/tests/PHPUnit/Integration/AnnotationsTest.php index 2dfd150e18c5afa5cc798548d3e31ae5c17fad95..9945b63902530ebd038a59cfb2bb1f67d01413b7 100755 --- a/tests/PHPUnit/Integration/AnnotationsTest.php +++ b/tests/PHPUnit/Integration/AnnotationsTest.php @@ -31,7 +31,6 @@ class AnnotationsTest extends IntegrationTestCase public function getApiForTesting() { $idSite1 = self::$fixture->idSite1; - $idSite2 = self::$fixture->idSite2; return array( @@ -279,7 +278,7 @@ class AnnotationsTest extends IntegrationTestCase } } else { $request = new Request($request); - $response = $request->process(); + $request->process(); } } diff --git a/tests/PHPUnit/Integration/Core/ArchiveProcessingTest.php b/tests/PHPUnit/Integration/Core/ArchiveProcessingTest.php index a87ee6dd8fc36236aca24d2ca285f22db553fdd1..3a522ee0ccba5f2454cc09a37ea831f36f570e08 100644 --- a/tests/PHPUnit/Integration/Core/ArchiveProcessingTest.php +++ b/tests/PHPUnit/Integration/Core/ArchiveProcessingTest.php @@ -370,7 +370,6 @@ class Core_ArchiveProcessingTest extends DatabaseTestCase */ public function testTableInsertBatchBlob() { - $siteTimezone = 'America/Toronto'; $dateLabel = '2011-03-31'; $table = ArchiveTableCreator::getBlobTable(Date::factory($dateLabel)); @@ -402,7 +401,6 @@ class Core_ArchiveProcessingTest extends DatabaseTestCase */ public function testTableInsertBatchIterateBlob() { - $siteTimezone = 'America/Toronto'; $dateLabel = '2011-03-31'; $table = ArchiveTableCreator::getBlobTable(Date::factory($dateLabel)); diff --git a/tests/PHPUnit/Integration/Core/WidgetsListTest.php b/tests/PHPUnit/Integration/Core/WidgetsListTest.php index ab3dcb9f8885c1afb6ac41675dbc88a002e139e6..7afd9dc0a5fa369a1394064fd3ff08a991302212 100644 --- a/tests/PHPUnit/Integration/Core/WidgetsListTest.php +++ b/tests/PHPUnit/Integration/Core/WidgetsListTest.php @@ -90,7 +90,6 @@ class Core_WidgetsListTest extends DatabaseTestCase ); foreach ($numberOfWidgets AS $category => $widgetCount) { - $expected = count($widgets[$category]); $this->assertEquals($widgetCount, count($widgets[$category])); } } diff --git a/tests/PHPUnit/Integration/Plugins/SitesManagerTest.php b/tests/PHPUnit/Integration/Plugins/SitesManagerTest.php index 87c5023eca030a21909903489daeb142caa258d2..3c9b6042bcce1982f5b7d4faadc1739b45c5db70 100644 --- a/tests/PHPUnit/Integration/Plugins/SitesManagerTest.php +++ b/tests/PHPUnit/Integration/Plugins/SitesManagerTest.php @@ -345,7 +345,7 @@ class Plugins_SitesManagerTest extends DatabaseTestCase try { $idsite = $this->_addSite(); $toAdd = array("http:mpigeq"); - $insertedUrls = API::getInstance()->addSiteAliasUrls($idsite, $toAdd); + API::getInstance()->addSiteAliasUrls($idsite, $toAdd); } catch (Exception $e) { return; } @@ -361,7 +361,7 @@ class Plugins_SitesManagerTest extends DatabaseTestCase { try { $toAdd = array("http://pigeq.com/test"); - $insertedUrls = API::getInstance()->addSiteAliasUrls(-1, $toAdd); + API::getInstance()->addSiteAliasUrls(-1, $toAdd); } catch (Exception $e) { return; } @@ -377,7 +377,7 @@ class Plugins_SitesManagerTest extends DatabaseTestCase { try { $toAdd = array("http://pigeq.com/test"); - $insertedUrls = API::getInstance()->addSiteAliasUrls(155, $toAdd); + API::getInstance()->addSiteAliasUrls(155, $toAdd); } catch (Exception $e) { return; } @@ -423,7 +423,7 @@ class Plugins_SitesManagerTest extends DatabaseTestCase public function testGetSiteFromIdWrongId1() { try { - $siteInfo = API::getInstance()->getSiteFromId(0); + API::getInstance()->getSiteFromId(0); } catch (Exception $e) { return; } @@ -438,7 +438,7 @@ class Plugins_SitesManagerTest extends DatabaseTestCase public function testGetSiteFromIdWrongId2() { try { - $siteInfo = API::getInstance()->getSiteFromId("x1"); + API::getInstance()->getSiteFromId("x1"); } catch (Exception $e) { return; } @@ -460,7 +460,7 @@ class Plugins_SitesManagerTest extends DatabaseTestCase FakeAccess::setIdSitesAdmin(array()); try { - $siteInfo = API::getInstance()->getSiteFromId(1); + API::getInstance()->getSiteFromId(1); } catch (Exception $e) { return; } @@ -504,9 +504,9 @@ class Plugins_SitesManagerTest extends DatabaseTestCase */ public function testGetSitesWithAdminAccess() { - $idsite = API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/")); - $idsite = API::getInstance()->addSite("site2", array("http://piwik.com/test/")); - $idsite = API::getInstance()->addSite("site3", array("http://piwik.org")); + API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/")); + API::getInstance()->addSite("site2", array("http://piwik.com/test/")); + API::getInstance()->addSite("site3", array("http://piwik.org")); $resultWanted = array( 0 => array("idsite" => 1, "name" => "site1", "main_url" => "http://piwik.net", "ecommerce" => 0, "excluded_ips" => "", 'sitesearch' => 1, 'sitesearch_keyword_parameters' => '', 'sitesearch_category_parameters' => '', 'excluded_parameters' => '', 'excluded_user_agents' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => '', 'keep_url_fragment' => 0, 'type' => 'website'), @@ -544,9 +544,9 @@ class Plugins_SitesManagerTest extends DatabaseTestCase */ public function testGetSitesWithViewAccess() { - $idsite = API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/")); - $idsite = API::getInstance()->addSite("site2", array("http://piwik.com/test/")); - $idsite = API::getInstance()->addSite("site3", array("http://piwik.org")); + API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/")); + API::getInstance()->addSite("site2", array("http://piwik.com/test/")); + API::getInstance()->addSite("site3", array("http://piwik.org")); $resultWanted = array( 0 => array("idsite" => 1, "name" => "site1", "main_url" => "http://piwik.net", "ecommerce" => 0, 'sitesearch' => 1, 'sitesearch_keyword_parameters' => '', 'sitesearch_category_parameters' => '', "excluded_ips" => "", 'excluded_parameters' => '', 'excluded_user_agents' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => '', 'keep_url_fragment' => 0, 'type' => 'website'), @@ -584,9 +584,9 @@ class Plugins_SitesManagerTest extends DatabaseTestCase */ public function testGetSitesWithAtLeastViewAccess() { - $idsite = API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/"), $ecommerce = 1); - $idsite = API::getInstance()->addSite("site2", array("http://piwik.com/test/")); - $idsite = API::getInstance()->addSite("site3", array("http://piwik.org")); + API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com/test/"), $ecommerce = 1); + API::getInstance()->addSite("site2", array("http://piwik.com/test/")); + API::getInstance()->addSite("site3", array("http://piwik.org")); $resultWanted = array( 0 => array("idsite" => 1, "name" => "site1", "main_url" => "http://piwik.net", "ecommerce" => 1, "excluded_ips" => "", 'sitesearch' => 1, 'sitesearch_keyword_parameters' => '', 'sitesearch_category_parameters' => '', 'excluded_parameters' => '', 'excluded_user_agents' => '', 'timezone' => 'UTC', 'currency' => 'USD', 'group' => '', 'keep_url_fragment' => 0, 'type' => 'website'), @@ -810,7 +810,7 @@ class Plugins_SitesManagerTest extends DatabaseTestCase public function testAddSitesInvalidTimezone($timezone) { try { - $idsite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, + API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $ip = '', $params = '', $timezone); } catch (Exception $e) { return; @@ -825,7 +825,7 @@ class Plugins_SitesManagerTest extends DatabaseTestCase { try { $invalidCurrency = '€'; - $idsite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, + API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, '', 'UTC', $invalidCurrency); } catch (Exception $e) { return; @@ -907,9 +907,9 @@ class Plugins_SitesManagerTest extends DatabaseTestCase */ public function testGetSitesIdFromSiteUrlSuperUser() { - $idsite = API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com")); - $idsite = API::getInstance()->addSite("site2", array("http://piwik.com", "http://piwik.net")); - $idsite = API::getInstance()->addSite("site3", array("http://piwik.com", "http://piwik.org")); + API::getInstance()->addSite("site1", array("http://piwik.net", "http://piwik.com")); + API::getInstance()->addSite("site2", array("http://piwik.com", "http://piwik.net")); + API::getInstance()->addSite("site3", array("http://piwik.com", "http://piwik.org")); $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.org'); $this->assertTrue(count($idsites) == 1); @@ -929,9 +929,9 @@ class Plugins_SitesManagerTest extends DatabaseTestCase */ public function testGetSitesIdFromSiteUrlUser() { - $idsite = API::getInstance()->addSite("site1", array("http://www.piwik.net", "http://piwik.com")); - $idsite = API::getInstance()->addSite("site2", array("http://piwik.com", "http://piwik.net")); - $idsite = API::getInstance()->addSite("site3", array("http://piwik.com", "http://piwik.org")); + API::getInstance()->addSite("site1", array("http://www.piwik.net", "http://piwik.com")); + API::getInstance()->addSite("site2", array("http://piwik.com", "http://piwik.net")); + API::getInstance()->addSite("site3", array("http://piwik.com", "http://piwik.org")); $saveAccess = Access::getInstance(); @@ -987,7 +987,7 @@ class Plugins_SitesManagerTest extends DatabaseTestCase */ public function testGetSitesFromTimezones() { - $idsite1 = API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'UTC'); + API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'UTC'); $idsite2 = API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'Pacific/Auckland'); $idsite3 = API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'Pacific/Auckland'); $idsite4 = API::getInstance()->addSite("site3", array("http://piwik.org"), null, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, null, null, 'UTC+10'); diff --git a/tests/PHPUnit/Integration/PrivacyManagerTest.php b/tests/PHPUnit/Integration/PrivacyManagerTest.php index 591be30265772addcd1f53d6f1ecf5cd7f7b77c3..336361b31cbe0ed3a6cca717cfa042fd9e22b364 100644 --- a/tests/PHPUnit/Integration/PrivacyManagerTest.php +++ b/tests/PHPUnit/Integration/PrivacyManagerTest.php @@ -613,7 +613,7 @@ class PrivacyManagerTest extends IntegrationTestCase $start = Date::factory(self::$dateTime); self::$idSite = Fixture::createWebsite('2012-01-01', $ecommerce = 1); - $idGoal = APIGoals::getInstance()->addGoal(self::$idSite, 'match all', 'url', 'http', 'contains'); + APIGoals::getInstance()->addGoal(self::$idSite, 'match all', 'url', 'http', 'contains'); $t = Fixture::getTracker(self::$idSite, $start, $defaultInit = true); $t->enableBulkTracking(); @@ -812,7 +812,6 @@ class PrivacyManagerTest extends IntegrationTestCase return; } - $tempTableName = Common::prefixTable(LogDataPurger::TEMP_TABLE_NAME); $logLinkVisitActionTable = Common::prefixTable("log_link_visit_action"); $sql = "INSERT INTO $logLinkVisitActionTable diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php index abe5659c43ea729be6eaba18013b4018d1c15927..b255b4f189bffe7596277a41a3531d5f78c5c9d3 100755 --- a/tests/PHPUnit/IntegrationTestCase.php +++ b/tests/PHPUnit/IntegrationTestCase.php @@ -328,7 +328,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase protected function generateUrlsApi($parametersToSet, $formats, $periods, $supertableApi = false, $setDateLastN = false, $language = false, $fileExtension = false) { // Get the URLs to query against the API for all functions starting with get* - $skipped = $requestUrls = array(); + $requestUrls = array(); $apiMetadata = new DocumentationGenerator; foreach (Proxy::getInstance()->getMetadata() as $class => $info) { $moduleName = Proxy::getInstance()->getModuleNameFromClassName($class); @@ -340,7 +340,6 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase && in_array($moduleName, $this->apiToCall) === false && in_array($apiId, $this->apiToCall) === false ) { - $skipped[] = $apiId; continue; } elseif ( ((strpos($methodName, 'get') !== 0 && $methodName != 'generateReport') @@ -352,7 +351,6 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase || $methodName == 'getHeaderLogoUrl' ) ) { // Excluded modules from test - $skipped[] = $apiId; continue; } @@ -418,7 +416,6 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase $exampleUrl = $apiMetadata->getExampleUrl($class, $methodName, $parametersToSet); if ($exampleUrl === false) { - $skipped[] = $apiId; continue; } @@ -743,7 +740,6 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase { $result = @file_get_contents($filePath); if (empty($result)) { - $expectedDir = dirname($filePath); $this->missingExpectedFiles[] = $filePath; return null; } @@ -994,7 +990,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase $bind = array(); foreach ($rows as $row) { $values = array(); - foreach ($row as $name => $value) { + foreach ($row as $value) { if (is_null($value)) { $values[] = 'NULL'; } else if (is_numeric($value)) { diff --git a/tests/PHPUnit/Plugins/LanguagesManagerTest.php b/tests/PHPUnit/Plugins/LanguagesManagerTest.php index 04898443f73df7955cb04062da551b2d6f5cd1f5..617f7941ef7d826fcd13b0b4d8b0e971ce724671 100755 --- a/tests/PHPUnit/Plugins/LanguagesManagerTest.php +++ b/tests/PHPUnit/Plugins/LanguagesManagerTest.php @@ -110,7 +110,7 @@ class Test_LanguagesManager extends PHPUnit_Framework_TestCase */ function testWriterInvalidPlugin() { - $writer = new Writer('de', 'iNvaLiDPluGin'); // invalid plugin throws exception + new Writer('de', 'iNvaLiDPluGin'); // invalid plugin throws exception } /**