diff --git a/plugins/UserId/Reports/GetUsers.php b/plugins/UserId/Reports/GetUsers.php index d2abdbf3935..37c97564537 100644 --- a/plugins/UserId/Reports/GetUsers.php +++ b/plugins/UserId/Reports/GetUsers.php @@ -60,8 +60,11 @@ public function configureView(ViewDataTable $view) $view->config->show_insights = false; $view->config->show_pivot_by_subtable = false; $view->config->no_data_message = Piwik::translate('CoreHome_ThereIsNoDataForThisReport') . '

' - . sprintf(Piwik::translate('UserId_ThereIsNoDataForThisReportHelp'), - "", ""); + . sprintf( + Piwik::translate('UserId_ThereIsNoDataForThisReportHelp'), + "", + "" + ); if ($view->isViewDataTableId(HtmlTable::ID)) { $view->config->disable_row_evolution = false; diff --git a/plugins/UsersManager/Controller.php b/plugins/UsersManager/Controller.php index e4ae50f2c79..f95d650ddcb 100644 --- a/plugins/UsersManager/Controller.php +++ b/plugins/UsersManager/Controller.php @@ -521,12 +521,16 @@ public function recordAnonymousUserSettings() $anonymousDefaultReport = Common::getRequestVar('anonymousDefaultReport'); $anonymousDefaultDate = Common::getRequestVar('anonymousDefaultDate'); $userLogin = 'anonymous'; - APIUsersManager::getInstance()->setUserPreference($userLogin, + APIUsersManager::getInstance()->setUserPreference( + $userLogin, APIUsersManager::PREFERENCE_DEFAULT_REPORT, - $anonymousDefaultReport); - APIUsersManager::getInstance()->setUserPreference($userLogin, + $anonymousDefaultReport + ); + APIUsersManager::getInstance()->setUserPreference( + $userLogin, APIUsersManager::PREFERENCE_DEFAULT_REPORT_DATE, - $anonymousDefaultDate); + $anonymousDefaultDate + ); $toReturn = $response->getResponse(); } catch (Exception $e) { $toReturn = $response->getResponseException($e); @@ -566,12 +570,16 @@ public function recordUserSettings() 'use12HourClock' => $timeFormat, ]); - APIUsersManager::getInstance()->setUserPreference($userLogin, + APIUsersManager::getInstance()->setUserPreference( + $userLogin, APIUsersManager::PREFERENCE_DEFAULT_REPORT, - $defaultReport); - APIUsersManager::getInstance()->setUserPreference($userLogin, + $defaultReport + ); + APIUsersManager::getInstance()->setUserPreference( + $userLogin, APIUsersManager::PREFERENCE_DEFAULT_REPORT_DATE, - $defaultDate); + $defaultDate + ); $toReturn = $response->getResponse(); } catch (Exception $e) { $toReturn = $response->getResponseException($e); diff --git a/plugins/UsersManager/Model.php b/plugins/UsersManager/Model.php index 288a7a7607b..df93b783210 100644 --- a/plugins/UsersManager/Model.php +++ b/plugins/UsersManager/Model.php @@ -309,8 +309,10 @@ public function generateRandomTokenAuth() private function generateTokenAuth() { - return md5(Common::getRandomString(32, - 'abcdef1234567890') . microtime(true) . Common::generateUniqId() . SettingsPiwik::getSalt()); + return md5(Common::getRandomString( + 32, + 'abcdef1234567890' + ) . microtime(true) . Common::generateUniqId() . SettingsPiwik::getSalt()); } /** @@ -340,8 +342,11 @@ public function addTokenAuth( throw new \Exception('User ' . $login . ' does not exist'); } - BaseValidator::check('Description', $description, - [new NotEmpty(), new CharacterLength(1, self::MAX_LENGTH_TOKEN_DESCRIPTION)]); + BaseValidator::check( + 'Description', + $description, + [new NotEmpty(), new CharacterLength(1, self::MAX_LENGTH_TOKEN_DESCRIPTION)] + ); if (empty($dateExpired)) { $dateExpired = null; @@ -354,8 +359,10 @@ public function addTokenAuth( $tokenAuth = $this->hashTokenAuth($tokenAuth); $db = $this->getDb(); - $db->query($insertSql, - [$login, $description, $tokenAuth, $dateCreated, $dateExpired, $isSystemToken, self::TOKEN_HASH_ALGO, $secureOnly]); + $db->query( + $insertSql, + [$login, $description, $tokenAuth, $dateCreated, $dateExpired, $isSystemToken, self::TOKEN_HASH_ALGO, $secureOnly] + ); return $db->lastInsertId(); } @@ -372,8 +379,10 @@ public function getUserTokenDescriptionByIdTokenAuth($idTokenAuth, $login) { $db = $this->getDb(); - $token = $db->fetchRow("SELECT description FROM " . $this->tokenTable . " WHERE `idusertokenauth` = ? and login = ? LIMIT 1", - array($idTokenAuth, $login)); + $token = $db->fetchRow( + "SELECT description FROM " . $this->tokenTable . " WHERE `idusertokenauth` = ? and login = ? LIMIT 1", + array($idTokenAuth, $login) + ); return $token ? $token['description'] : ''; } @@ -425,16 +434,20 @@ public function deleteExpiredTokens($expiredSince) { $db = $this->getDb(); - return $db->query("DELETE FROM " . $this->tokenTable . " WHERE `date_expired` is not null and date_expired < ?", - $expiredSince); + return $db->query( + "DELETE FROM " . $this->tokenTable . " WHERE `date_expired` is not null and date_expired < ?", + $expiredSince + ); } public function getExpiredInvites($expiredSince) { $db = $this->getDb(); - return $db->fetchAll("SELECT * FROM " . $this->userTable . " WHERE `invite_expired_at` is not null and invite_expired_at < ?", - $expiredSince); + return $db->fetchAll( + "SELECT * FROM " . $this->userTable . " WHERE `invite_expired_at` is not null and invite_expired_at < ?", + $expiredSince + ); } public function checkUserHasUnexpiredToken($login) @@ -442,8 +455,10 @@ public function checkUserHasUnexpiredToken($login) $db = $this->getDb(); $expired = $this->getQueryNotExpiredToken(); $bind = array_merge(array($login), $expired['bind']); - return $db->fetchOne("SELECT idusertokenauth FROM " . $this->tokenTable . " WHERE `login` = ? and " . $expired['sql'], - $bind); + return $db->fetchOne( + "SELECT idusertokenauth FROM " . $this->tokenTable . " WHERE `login` = ? and " . $expired['sql'], + $bind + ); } public function deleteAllTokensForUser($login) @@ -461,8 +476,10 @@ public function getAllNonSystemTokensForLogin($login) $expired = $this->getQueryNotExpiredToken(); $bind = array_merge(array($login), $expired['bind']); - return $db->fetchAll("SELECT * FROM " . $this->tokenTable . " WHERE `login` = ? and system_token = 0 and " . $expired['sql'] . ' order by idusertokenauth ASC', - $bind); + return $db->fetchAll( + "SELECT * FROM " . $this->tokenTable . " WHERE `login` = ? and system_token = 0 and " . $expired['sql'] . ' order by idusertokenauth ASC', + $bind + ); } public function getAllHashedTokensForLogins($logins) @@ -477,8 +494,10 @@ public function getAllHashedTokensForLogins($logins) $expired = $this->getQueryNotExpiredToken(); $bind = array_merge($logins, $expired['bind']); - $tokens = $db->fetchAll("SELECT password FROM " . $this->tokenTable . " WHERE `login` IN (" . $placeholder . ") and " . $expired['sql'], - $bind); + $tokens = $db->fetchAll( + "SELECT password FROM " . $this->tokenTable . " WHERE `login` IN (" . $placeholder . ") and " . $expired['sql'], + $bind + ); return array_column($tokens, 'password'); } @@ -486,8 +505,10 @@ public function deleteToken($idTokenAuth, $login) { $db = $this->getDb(); - return $db->query("DELETE FROM " . $this->tokenTable . " WHERE `idusertokenauth` = ? and login = ?", - array($idTokenAuth, $login)); + return $db->query( + "DELETE FROM " . $this->tokenTable . " WHERE `idusertokenauth` = ? and login = ?", + array($idTokenAuth, $login) + ); } public function setTokenAuthWasUsed($tokenAuth, $dateLastUsed) @@ -522,8 +543,10 @@ private function updateTokenAuthTable($idTokenAuth, $fields) $bind[] = $idTokenAuth; $db = $this->getDb(); - $db->query(sprintf('UPDATE `%s` SET %s WHERE `idusertokenauth` = ?', $this->tokenTable, implode(', ', $set)), - $bind); + $db->query( + sprintf('UPDATE `%s` SET %s WHERE `idusertokenauth` = ?', $this->tokenTable, implode(', ', $set)), + $bind + ); } public function getUserByEmail($userEmail) @@ -737,8 +760,10 @@ public function deleteUserAccess($userLogin, $idSites = null) $db->query("DELETE FROM " . Common::prefixTable("access") . " WHERE login = ?", $userLogin); } else { foreach ($idSites as $idsite) { - $db->query("DELETE FROM " . Common::prefixTable("access") . " WHERE idsite = ? AND login = ?", - [$idsite, $userLogin]); + $db->query( + "DELETE FROM " . Common::prefixTable("access") . " WHERE idsite = ? AND login = ?", + [$idsite, $userLogin] + ); } } } diff --git a/plugins/UsersManager/UsersManager.php b/plugins/UsersManager/UsersManager.php index 128908a8c01..32b337a971a 100644 --- a/plugins/UsersManager/UsersManager.php +++ b/plugins/UsersManager/UsersManager.php @@ -70,8 +70,14 @@ public function addSystemSummaryItems(&$systemSummary) $numUsers--; } - $systemSummary[] = new SystemSummary\Item($key = 'users', Piwik::translate('General_NUsers', $numUsers), - $value = null, array('module' => 'UsersManager', 'action' => 'index'), $icon = 'icon-user', $order = 5); + $systemSummary[] = new SystemSummary\Item( + $key = 'users', + Piwik::translate('General_NUsers', $numUsers), + $value = null, + array('module' => 'UsersManager', 'action' => 'index'), + $icon = 'icon-user', + $order = 5 + ); } public function onPlatformInitialized() @@ -175,12 +181,16 @@ public static function checkPassword($password) Piwik::postEvent('UsersManager.checkPassword', array($password)); if (!self::isValidPasswordString($password)) { - throw new Exception(Piwik::translate('UsersManager_ExceptionInvalidPassword', - array(self::PASSWORD_MIN_LENGTH))); + throw new Exception(Piwik::translate( + 'UsersManager_ExceptionInvalidPassword', + array(self::PASSWORD_MIN_LENGTH) + )); } if (mb_strlen($password) > self::PASSWORD_MAX_LENGTH) { - throw new Exception(Piwik::translate('UsersManager_ExceptionInvalidPasswordTooLong', - array(self::PASSWORD_MAX_LENGTH))); + throw new Exception(Piwik::translate( + 'UsersManager_ExceptionInvalidPasswordTooLong', + array(self::PASSWORD_MAX_LENGTH) + )); } } diff --git a/plugins/UsersManager/tests/Integration/TokenSecureOnlyTest.php b/plugins/UsersManager/tests/Integration/TokenSecureOnlyTest.php index 8ee728610f2..b4ccae0e601 100644 --- a/plugins/UsersManager/tests/Integration/TokenSecureOnlyTest.php +++ b/plugins/UsersManager/tests/Integration/TokenSecureOnlyTest.php @@ -36,8 +36,15 @@ private static function createUserAndTokens() UsersManagerAPI::getInstance()->setUserAccess('user1', 'view', [1]); $userModel = new UsersManagerModel(); - $userModel->addTokenAuth('user1', self::$tokenSecureOnly, 'Secure Only', '2020-01-02 03:04:05', - null, false, true); + $userModel->addTokenAuth( + 'user1', + self::$tokenSecureOnly, + 'Secure Only', + '2020-01-02 03:04:05', + null, + false, + true + ); } } diff --git a/plugins/UsersManager/tests/Integration/UsersManagerTest.php b/plugins/UsersManager/tests/Integration/UsersManagerTest.php index b4a8d745024..dc1fc4551a1 100644 --- a/plugins/UsersManager/tests/Integration/UsersManagerTest.php +++ b/plugins/UsersManager/tests/Integration/UsersManagerTest.php @@ -248,9 +248,11 @@ public function testAddUserWrongEmail() public function testAddUserLongPassword() { $login = "geggeqgeqag"; - $this->api->addUser($login, - "geqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaeg", - "mgeagi@geq.com"); + $this->api->addUser( + $login, + "geqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaegeqgeagaeg", + "mgeagi@geq.com" + ); $user = $this->api->getUser($login); $this->assertEquals($login, $user['login']); } @@ -269,8 +271,10 @@ public function testAddUser() $user = $this->model->getUser($login); // check that the date registered is correct - $this->assertTrue($time <= strtotime($user['date_registered']) && strtotime($user['date_registered']) <= time(), - "the date_registered " . strtotime($user['date_registered']) . " is different from the time() " . time()); + $this->assertTrue( + $time <= strtotime($user['date_registered']) && strtotime($user['date_registered']) <= time(), + "the date_registered " . strtotime($user['date_registered']) . " is different from the time() " . time() + ); // check that password and token are properly set $this->assertEquals(60, strlen($user['password'])); @@ -487,10 +491,14 @@ public function testGetUsers() ); $expectedUsers = array($user1, $user2, $user3); $this->assertEquals($expectedUsers, $users); - $this->assertEquals(array($user1), - $this->_removeNonTestableFieldsFromUsers($this->api->getUsers('gegg4564eqgeqag'))); - $this->assertEquals(array($user1, $user2), - $this->_removeNonTestableFieldsFromUsers($this->api->getUsers('gegg4564eqgeqag,geggeqge632ge56a4qag'))); + $this->assertEquals( + array($user1), + $this->_removeNonTestableFieldsFromUsers($this->api->getUsers('gegg4564eqgeqag')) + ); + $this->assertEquals( + array($user1, $user2), + $this->_removeNonTestableFieldsFromUsers($this->api->getUsers('gegg4564eqgeqag,geggeqge632ge56a4qag')) + ); } public function testGetUsers_withViewAccess_shouldThrowAnException() @@ -1168,8 +1176,10 @@ private function addSites($numberOfSites) for ($index = 0; $index < $numberOfSites; $index++) { $name = "test" . ($index + 1); - $idSites[] = APISitesManager::getInstance()->addSite($name, - array("http://piwik.net", "http://piwik.com/test/")); + $idSites[] = APISitesManager::getInstance()->addSite( + $name, + array("http://piwik.net", "http://piwik.com/test/") + ); } return $idSites; diff --git a/plugins/VisitFrequency/Controller.php b/plugins/VisitFrequency/Controller.php index 7c6bb1c00c5..4128e42e1ae 100644 --- a/plugins/VisitFrequency/Controller.php +++ b/plugins/VisitFrequency/Controller.php @@ -71,8 +71,13 @@ public function getEvolutionGraph() } } - $view = $this->getLastUnitGraphAcrossPlugins($this->pluginName, __FUNCTION__, $columns, - $selectableColumns, $documentation); + $view = $this->getLastUnitGraphAcrossPlugins( + $this->pluginName, + __FUNCTION__, + $columns, + $selectableColumns, + $documentation + ); if (empty($view->config->columns_to_display)) { $view->config->columns_to_display = array('nb_visits_returning'); diff --git a/plugins/VisitorInterest/API.php b/plugins/VisitorInterest/API.php index 5f08685badf..77b3241bed8 100644 --- a/plugins/VisitorInterest/API.php +++ b/plugins/VisitorInterest/API.php @@ -66,7 +66,13 @@ public function getNumberOfVisitsPerPage($idSite, $period, $date, $segment = fal public function getNumberOfVisitsByDaysSinceLast($idSite, $period, $date, $segment = false) { $dataTable = $this->getDataTable( - Archiver::DAYS_SINCE_LAST_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS); + Archiver::DAYS_SINCE_LAST_RECORD_NAME, + $idSite, + $period, + $date, + $segment, + Metrics::INDEX_NB_VISITS + ); $dataTable->queueFilter('AddSegmentByRangeLabel', array('daysSinceLastVisit')); $dataTable->queueFilter('BeautifyRangeLabels', array(Piwik::translate('Intl_OneDay'), Piwik::translate('Intl_NDays'))); return $dataTable; @@ -85,7 +91,13 @@ public function getNumberOfVisitsByDaysSinceLast($idSite, $period, $date, $segme public function getNumberOfVisitsByVisitCount($idSite, $period, $date, $segment = false) { $dataTable = $this->getDataTable( - Archiver::VISITS_COUNT_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS); + Archiver::VISITS_COUNT_RECORD_NAME, + $idSite, + $period, + $date, + $segment, + Metrics::INDEX_NB_VISITS + ); $dataTable->queueFilter('AddSegmentByRangeLabel', array('visitCount')); $dataTable->queueFilter('BeautifyRangeLabels', array( diff --git a/plugins/VisitorInterest/RecordBuilders/Engagement.php b/plugins/VisitorInterest/RecordBuilders/Engagement.php index f92a96551c3..096893dc546 100644 --- a/plugins/VisitorInterest/RecordBuilders/Engagement.php +++ b/plugins/VisitorInterest/RecordBuilders/Engagement.php @@ -43,17 +43,29 @@ protected function aggregate(ArchiveProcessor $archiveProcessor): array // collect our extra aggregate select fields $selects = array(); $selects = array_merge($selects, LogAggregator::getSelectsFromRangedColumn( - 'visit_total_time', Archiver::getSecondsGap(), 'log_visit', $prefixes[Archiver::TIME_SPENT_RECORD_NAME] + 'visit_total_time', + Archiver::getSecondsGap(), + 'log_visit', + $prefixes[Archiver::TIME_SPENT_RECORD_NAME] )); $selects = array_merge($selects, LogAggregator::getSelectsFromRangedColumn( - 'visit_total_actions', Archiver::$pageGap, 'log_visit', $prefixes[Archiver::PAGES_VIEWED_RECORD_NAME] + 'visit_total_actions', + Archiver::$pageGap, + 'log_visit', + $prefixes[Archiver::PAGES_VIEWED_RECORD_NAME] )); $selects = array_merge($selects, LogAggregator::getSelectsFromRangedColumn( - 'visitor_count_visits', Archiver::$visitNumberGap, 'log_visit', $prefixes[Archiver::VISITS_COUNT_RECORD_NAME] + 'visitor_count_visits', + Archiver::$visitNumberGap, + 'log_visit', + $prefixes[Archiver::VISITS_COUNT_RECORD_NAME] )); $selects = array_merge($selects, LogAggregator::getSelectsFromRangedColumn( - 'FLOOR(log_visit.visitor_seconds_since_last / 86400)', Archiver::$daysSinceLastVisitGap, 'log_visit', $prefixes[Archiver::DAYS_SINCE_LAST_RECORD_NAME], + 'FLOOR(log_visit.visitor_seconds_since_last / 86400)', + Archiver::$daysSinceLastVisitGap, + 'log_visit', + $prefixes[Archiver::DAYS_SINCE_LAST_RECORD_NAME], $restrictToReturningVisitors = true )); diff --git a/plugins/VisitsSummary/API.php b/plugins/VisitsSummary/API.php index 4ed57e1e9ac..9c62eadbea9 100644 --- a/plugins/VisitsSummary/API.php +++ b/plugins/VisitsSummary/API.php @@ -118,8 +118,10 @@ public function getSumVisitsLengthPretty($idSite, $period, $date, $segment = fal $table = $this->getSumVisitsLength($idSite, $period, $date, $segment); if (is_object($table)) { - $table->filter('ColumnCallbackReplace', - array('sum_visit_length', array($formatter, 'getPrettyTimeFromSeconds'), array(true))); + $table->filter( + 'ColumnCallbackReplace', + array('sum_visit_length', array($formatter, 'getPrettyTimeFromSeconds'), array(true)) + ); } else { $table = $formatter->getPrettyTimeFromSeconds($table, true); } diff --git a/plugins/VisitsSummary/Controller.php b/plugins/VisitsSummary/Controller.php index 31e00d9b7f8..d399c60358c 100644 --- a/plugins/VisitsSummary/Controller.php +++ b/plugins/VisitsSummary/Controller.php @@ -117,8 +117,13 @@ public function getEvolutionGraph() } // $callingAction may be specified to distinguish between // "VisitsSummary_WidgetLastVisits" and "VisitsSummary_WidgetOverviewGraph" - $view = $this->getLastUnitGraphAcrossPlugins($this->pluginName, __FUNCTION__, $columns, - $selectableColumns, $documentation); + $view = $this->getLastUnitGraphAcrossPlugins( + $this->pluginName, + __FUNCTION__, + $columns, + $selectableColumns, + $documentation + ); if (empty($view->config->columns_to_display)) { $view->config->columns_to_display = array('nb_visits'); diff --git a/tests/PHPUnit/Fixtures/DisablePluginArchive.php b/tests/PHPUnit/Fixtures/DisablePluginArchive.php index ff130924aed..2568e186e93 100644 --- a/tests/PHPUnit/Fixtures/DisablePluginArchive.php +++ b/tests/PHPUnit/Fixtures/DisablePluginArchive.php @@ -61,19 +61,19 @@ private function trackVisits() // testing URL excluded parameters $parameterToExclude = 'excluded_parameter'; APISitesManager::getInstance()->updateSite( - $idSite, - 'new name', - $url = array('http://site.com'), - $ecommerce = 0, - $siteSearch = 0, - $searchKeywordParameters = null, - $searchCategoryParameters = null, - $excludedIps = null, - $parameterToExclude . ',anotherParameter', - $timezone = null, - $currency = null, - $group = null, - $startDate = null + $idSite, + 'new name', + $url = array('http://site.com'), + $ecommerce = 0, + $siteSearch = 0, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIps = null, + $parameterToExclude . ',anotherParameter', + $timezone = null, + $currency = null, + $group = null, + $startDate = null ); // Record 1st page view diff --git a/tests/PHPUnit/Fixtures/InvalidVisits.php b/tests/PHPUnit/Fixtures/InvalidVisits.php index 881ca250192..319ff2cf677 100644 --- a/tests/PHPUnit/Fixtures/InvalidVisits.php +++ b/tests/PHPUnit/Fixtures/InvalidVisits.php @@ -102,10 +102,26 @@ private function trackVisits() // test unknown url exclusion works $urls = array("http://piwik.net", "http://my.stuff.com/"); - API::getInstance()->updateSite($idSite, $siteName = null, $urls, $ecommerce = null, $siteSearch = null, - $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, $excludedQueryParams = null, - $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = null, - $keepUrlFragments = null, $type = null, $settings = null, $excludeUnknownUrls = 1); + API::getInstance()->updateSite( + $idSite, + $siteName = null, + $urls, + $ecommerce = null, + $siteSearch = null, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIps = null, + $excludedQueryParams = null, + $timezone = null, + $currency = null, + $group = null, + $startDate = null, + $excludedUserAgents = null, + $keepUrlFragments = null, + $type = null, + $settings = null, + $excludeUnknownUrls = 1 + ); Cache::regenerateCacheWebsiteAttributes([1]); $t->setIp("125.4.5.6"); @@ -118,10 +134,26 @@ private function trackVisits() // undo exclude unknown urls change (important when multiple fixtures are setup together, as is done in OmniFixture) - API::getInstance()->updateSite($idSite, $siteName = null, $urls, $ecommerce = null, $siteSearch = null, - $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, $excludedQueryParams = null, - $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = null, - $keepUrlFragments = null, $type = null, $settings = null, $excludeUnknownUrls = 0); + API::getInstance()->updateSite( + $idSite, + $siteName = null, + $urls, + $ecommerce = null, + $siteSearch = null, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIps = null, + $excludedQueryParams = null, + $timezone = null, + $currency = null, + $group = null, + $startDate = null, + $excludedUserAgents = null, + $keepUrlFragments = null, + $type = null, + $settings = null, + $excludeUnknownUrls = 0 + ); Cache::regenerateCacheWebsiteAttributes([1]); try { diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php index 2c739a06c20..bad019036d2 100644 --- a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php +++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php @@ -66,13 +66,21 @@ public function setUpWebsitesAndGoals() } if (!self::siteCreated($idSite = 2)) { - self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'Piwik test two', - $siteUrl = 'http://example-site-two.com'); + self::createWebsite( + $this->dateTime, + $ecommerce = 0, + $siteName = 'Piwik test two', + $siteUrl = 'http://example-site-two.com' + ); } if (!self::siteCreated($idSite = 3)) { - self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'Piwik test three', - $siteUrl = 'http://example-site-three.com'); + self::createWebsite( + $this->dateTime, + $ecommerce = 0, + $siteName = 'Piwik test three', + $siteUrl = 'http://example-site-three.com' + ); } } diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php index e47ac948ff1..898990154af 100644 --- a/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php +++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogsWithXssAttempts.php @@ -72,22 +72,48 @@ public function setUpWebsitesAndGoals() if (!self::goalExists($idSite = 1, $idGoal = 1)) { APIGoals::getInstance()->addGoal( - $this->idSite, $xssTesting->forTwig("goal name"), 'url', 'http', 'contains', false, 5, false, $xssTesting->forTwig("goal description")); + $this->idSite, + $xssTesting->forTwig("goal name"), + 'url', + 'http', + 'contains', + false, + 5, + false, + $xssTesting->forTwig("goal description") + ); } if (!self::siteCreated($idSite = 2)) { - self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = $xssTesting->forAngular('Piwik test two'), - $siteUrl = 'http://example-site-two.com'); + self::createWebsite( + $this->dateTime, + $ecommerce = 0, + $siteName = $xssTesting->forAngular('Piwik test two'), + $siteUrl = 'http://example-site-two.com' + ); } if (!self::goalExists($idSite = 2, $idGoal = 2)) { APIGoals::getInstance()->addGoal( - $this->idSite, $xssTesting->forAngular("second goal"), 'url', 'http', 'contains', false, 5, false, $xssTesting->forAngular("goal description")); + $this->idSite, + $xssTesting->forAngular("second goal"), + 'url', + 'http', + 'contains', + false, + 5, + false, + $xssTesting->forAngular("goal description") + ); } if (!self::siteCreated($idSite = 3)) { - self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'Piwik test three', - $siteUrl = 'http://example-site-three.com'); + self::createWebsite( + $this->dateTime, + $ecommerce = 0, + $siteName = 'Piwik test three', + $siteUrl = 'http://example-site-three.com' + ); } } @@ -96,7 +122,11 @@ public function addAnnotations() $xssTesting = new XssTesting(); APIAnnotations::getInstance()->add($this->idSite, '2012-08-09', "Note 1", $starred = 1); APIAnnotations::getInstance()->add( - $this->idSite, '2012-08-08', $xssTesting->forTwig("annotation"), $starred = 0); + $this->idSite, + '2012-08-08', + $xssTesting->forTwig("annotation"), + $starred = 0 + ); APIAnnotations::getInstance()->add($this->idSite, '2012-08-10', $xssTesting->forAngular("Annotation note 3"), $starred = 1); } diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php index 81c510d10b4..76b8f8c04df 100644 --- a/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php +++ b/tests/PHPUnit/Fixtures/ManyVisitsWithGeoIP.php @@ -224,7 +224,8 @@ protected function trackVisit(\MatomoTracker $t, $fixtureCounter, $visitorCounte $date = $date->addHour(0.05); $t->setForceVisitDateTime($date->getDatetime()); - $r = $t->doTrackEvent('Cat' . $visitorCounter, + $r = $t->doTrackEvent( + 'Cat' . $visitorCounter, 'Action' . $visitorCounter, 'Name' . $visitorCounter, 345.678 + $visitorCounter diff --git a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php index 9f10cbe46c8..960528a198d 100644 --- a/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php +++ b/tests/PHPUnit/Fixtures/ManyVisitsWithMockLocationProvider.php @@ -250,7 +250,8 @@ private function trackAction(\MatomoTracker $t, $actionType, $visitorCounter, $a { if ($actionType == 'pageview') { self::checkResponse($t->doTrackPageView( - is_null($actionNum) ? "title_$visitorCounter" : "title_$visitorCounter / title_$actionNum")); + is_null($actionNum) ? "title_$visitorCounter" : "title_$visitorCounter / title_$actionNum" + )); } else if ($actionType == 'download') { $root = is_null($actionNum) ? "http://cloudsite$visitorCounter.com" : "http://cloudsite$visitorCounter.com/$actionNum"; diff --git a/tests/PHPUnit/Fixtures/SomePageGoalVisitsWithConversions.php b/tests/PHPUnit/Fixtures/SomePageGoalVisitsWithConversions.php index 97e7035f4c8..284755f0375 100644 --- a/tests/PHPUnit/Fixtures/SomePageGoalVisitsWithConversions.php +++ b/tests/PHPUnit/Fixtures/SomePageGoalVisitsWithConversions.php @@ -47,21 +47,40 @@ private function setUpWebsitesAndGoals() // Newsletter signup goal if (!self::goalExists($idSite = 1, $idGoal = 1)) { - APIGoals::getInstance()->addGoal($this->idSite, 'Goal 1', 'event_action', 'click', - 'contains', false, 10); + APIGoals::getInstance()->addGoal( + $this->idSite, + 'Goal 1', + 'event_action', + 'click', + 'contains', + false, + 10 + ); } // Contact me signup goal if (!self::goalExists($idSite = 1, $idGoal = 2)) { - APIGoals::getInstance()->addGoal($this->idSite, 'Goal "<2~$%+"', 'event_action', 'press', - 'contains', false, 10); + APIGoals::getInstance()->addGoal( + $this->idSite, + 'Goal "<2~$%+"', + 'event_action', + 'press', + 'contains', + false, + 10 + ); } } private function setUpSegment() { - APISegmentEditor::getInstance()->add('goalsByCountry', 'countryCode==' . $this->segmentCountryCode, - $this->idSite, true, true); + APISegmentEditor::getInstance()->add( + 'goalsByCountry', + 'countryCode==' . $this->segmentCountryCode, + $this->idSite, + true, + true + ); } private function doPageVisit($t, string $pageLetter, ?string $subPage = null) diff --git a/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php b/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php index 6739e8580e7..39776a577bb 100644 --- a/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php +++ b/tests/PHPUnit/Fixtures/SomeVisitsAllConversions.php @@ -41,16 +41,28 @@ private function setUpWebsitesAndGoals() // First, a goal that is only recorded once per visit if (!self::goalExists($idSite = 1, $idGoal = 1)) { API::getInstance()->addGoal( - $this->idSite, 'triggered js ONCE', 'title', 'Thank you', 'contains', $caseSensitive = false, - $revenue = 10, $allowMultipleConversions = false + $this->idSite, + 'triggered js ONCE', + 'title', + 'Thank you', + 'contains', + $caseSensitive = false, + $revenue = 10, + $allowMultipleConversions = false ); } // Second, a goal allowing multiple conversions if (!self::goalExists($idSite = 1, $idGoal = 2)) { API::getInstance()->addGoal( - $this->idSite, 'triggered js MULTIPLE ALLOWED', 'manually', '', '', $caseSensitive = false, - $revenue = 10, $allowMultipleConversions = true + $this->idSite, + 'triggered js MULTIPLE ALLOWED', + 'manually', + '', + '', + $caseSensitive = false, + $revenue = 10, + $allowMultipleConversions = true ); } diff --git a/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php b/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php index 2835500b46c..0b2646f9763 100644 --- a/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php +++ b/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php @@ -35,8 +35,13 @@ public function tearDown(): void private function setUpWebsitesAndGoals() { if (!self::siteCreated($idSite = 1)) { - self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'Piwik test', $siteUrl = false, - $siteSearch = 1); + self::createWebsite( + $this->dateTime, + $ecommerce = 0, + $siteName = 'Piwik test', + $siteUrl = false, + $siteSearch = 1 + ); } } @@ -117,9 +122,15 @@ private function trackVisits() $this->trackPageView($tracker, 0.2, 'page/one.html', $laterDate); $this->trackPageView($tracker, 0.25, '', $laterDate, $pageViewType = 'download'); $this->trackPageView($tracker, 0.3, 'page/one.html', $laterDate); - $this->trackPageView($tracker, 0.35, 'page/search.html#q=anotherkwd', $laterDate, - $pageViewType = 'site-search', $searchKeyword = 'anotherkwd', - $searchCategory = 'mysearchcat'); + $this->trackPageView( + $tracker, + 0.35, + 'page/search.html#q=anotherkwd', + $laterDate, + $pageViewType = 'site-search', + $searchKeyword = 'anotherkwd', + $searchCategory = 'mysearchcat' + ); $tracker->setIp('156.5.3.8'); diff --git a/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php b/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php index aad330e4509..10833c033a1 100644 --- a/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php +++ b/tests/PHPUnit/Fixtures/ThreeGoalsOnePageview.php @@ -43,15 +43,27 @@ private function setUpWebsitesAndGoals() if (!self::goalExists($idSite = 1, $idGoal = 1)) { API::getInstance()->addGoal( - $this->idSite, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, - $revenue = 10, $allowMultipleConversions = 1 + $this->idSite, + 'Goal 1 - Thank you', + 'title', + 'Thank you', + 'contains', + $caseSensitive = false, + $revenue = 10, + $allowMultipleConversions = 1 ); } if (!self::goalExists($idSite = 1, $idGoal = 2)) { API::getInstance()->addGoal( - $this->idSite, 'Goal 2 - Hello', 'url', 'hellow', 'contains', $caseSensitive = false, - $revenue = 10, $allowMultipleConversions = 0 + $this->idSite, + 'Goal 2 - Hello', + 'url', + 'hellow', + 'contains', + $caseSensitive = false, + $revenue = 10, + $allowMultipleConversions = 0 ); } diff --git a/tests/PHPUnit/Fixtures/ThreeVisitsWithCustomEvents.php b/tests/PHPUnit/Fixtures/ThreeVisitsWithCustomEvents.php index f13ad515272..f74758b95c3 100644 --- a/tests/PHPUnit/Fixtures/ThreeVisitsWithCustomEvents.php +++ b/tests/PHPUnit/Fixtures/ThreeVisitsWithCustomEvents.php @@ -38,8 +38,18 @@ private function setUpWebsitesAndGoals() // These two goals are to check events don't trigger for URL or Title matching APIGoals::getInstance()->addGoal($this->idSite, 'triggered js', 'url', 'webradio', 'contains'); APIGoals::getInstance()->addGoal($this->idSite, 'triggered js', 'title', 'Music', 'contains'); - $idGoalTriggeredOnEventCategory = APIGoals::getInstance()->addGoal($this->idSite, 'event matching', 'event_category', 'CategoryTriggersGoal', 'contains', false, - 8, true, '', true); + $idGoalTriggeredOnEventCategory = APIGoals::getInstance()->addGoal( + $this->idSite, + 'event matching', + 'event_category', + 'CategoryTriggersGoal', + 'contains', + false, + 8, + true, + '', + true + ); $this->assertEquals($idGoalTriggeredOnEventCategory, self::$idGoalTriggeredOnEventCategory); } diff --git a/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php b/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php index 72761184353..24f9afaaf68 100644 --- a/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php +++ b/tests/PHPUnit/Fixtures/TwoSitesEcommerceOrderWithItems.php @@ -47,8 +47,14 @@ private function setUpWebsitesAndGoals() if (!self::goalExists($this->idSite, $this->idGoalStandard)) { API::getInstance()->addGoal( - $this->idSite, 'title match, triggered ONCE', 'title', 'incredible', 'contains', - $caseSensitive = false, $revenue = 10, $allowMultipleConversions = true + $this->idSite, + 'title match, triggered ONCE', + 'title', + 'incredible', + 'contains', + $caseSensitive = false, + $revenue = 10, + $allowMultipleConversions = true ); } } diff --git a/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php b/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php index 68233a231d5..1a2642b740f 100644 --- a/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php +++ b/tests/PHPUnit/Fixtures/TwoSitesManyVisitsOverSeveralDaysWithSearchEngineReferrers.php @@ -43,9 +43,20 @@ private function setUpWebsitesAndGoals() $siteCreated = $this->dateTime; if (!self::siteCreated($idSite = 1)) { - self::createWebsite($siteCreated, 0, false, false, 1, null, - null, null, null, 0, null, - self::EXCLUDED_REFERRER_URL); + self::createWebsite( + $siteCreated, + 0, + false, + false, + 1, + null, + null, + null, + null, + 0, + null, + self::EXCLUDED_REFERRER_URL + ); } if (!self::goalExists($idSite = 1, $idGoal = 1)) { @@ -54,7 +65,15 @@ private function setUpWebsitesAndGoals() if (!self::goalExists($idSite = 1, $idGoal = 2)) { API::getInstance()->addGoal( - $this->idSite, 'another triggered php', 'manually', '', '', false, false, true); + $this->idSite, + 'another triggered php', + 'manually', + '', + '', + false, + false, + true + ); } if (!self::siteCreated($idSite = 2)) { diff --git a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php index 26ec6126072..3c66300bd47 100644 --- a/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php +++ b/tests/PHPUnit/Fixtures/TwoSitesTwoVisitorsDifferentDays.php @@ -67,15 +67,39 @@ private function setUpWebsitesAndGoals() } APISitesManager::getInstance()->updateSite( - $this->idSite1, "Site 1", $urls = null, $ecommerce = null, $siteSearch = null, - $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, - $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, - $startDate = null, $excludedUserAgents = null, $keepURLFragments = 2); // KEEP_URL_FRAGMENT_NO No for idSite 1 + $this->idSite1, + "Site 1", + $urls = null, + $ecommerce = null, + $siteSearch = null, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIps = null, + $excludedQueryParameters = null, + $timezone = null, + $currency = null, + $group = null, + $startDate = null, + $excludedUserAgents = null, + $keepURLFragments = 2 + ); // KEEP_URL_FRAGMENT_NO No for idSite 1 APISitesManager::getInstance()->updateSite( - $this->idSite2, "Site 2", $urls = null, $ecommerce = null, $siteSearch = null, - $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, - $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, - $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); // KEEP_URL_FRAGMENT_YES Yes for idSite 2 + $this->idSite2, + "Site 2", + $urls = null, + $ecommerce = null, + $siteSearch = null, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIps = null, + $excludedQueryParameters = null, + $timezone = null, + $currency = null, + $group = null, + $startDate = null, + $excludedUserAgents = null, + $keepURLFragments = 1 + ); // KEEP_URL_FRAGMENT_YES Yes for idSite 2 } public function trackVisits() diff --git a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php index 5589b50745b..96e48638b31 100644 --- a/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php +++ b/tests/PHPUnit/Fixtures/TwoVisitsWithCustomVariables.php @@ -106,12 +106,24 @@ private function trackVisits() self::checkResponse($visitorA->doTrackGoal($idGoal)); if ($this->doExtraQuoteTests) { - $visitorA->setCustomVariable($id = 2, $name = 'var1', $value = 'looking at "profile page"', - $scope = 'page'); - $visitorA->setCustomVariable($id = 3, $name = 'var2', $value = '\'looking at "\profile page"\'', - $scope = 'page'); - $visitorA->setCustomVariable($id = 4, $name = 'var3', $value = '\\looking at "\profile page"\\', - $scope = 'page'); + $visitorA->setCustomVariable( + $id = 2, + $name = 'var1', + $value = 'looking at "profile page"', + $scope = 'page' + ); + $visitorA->setCustomVariable( + $id = 3, + $name = 'var2', + $value = '\'looking at "\profile page"\'', + $scope = 'page' + ); + $visitorA->setCustomVariable( + $id = 4, + $name = 'var3', + $value = '\\looking at "\profile page"\\', + $scope = 'page' + ); self::checkResponse($visitorA->doTrackPageView('Concurrent page views')); } diff --git a/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php b/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php index a4f6a21abf5..6315805c240 100644 --- a/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php +++ b/tests/PHPUnit/Fixtures/VisitsInDifferentTimezones.php @@ -34,14 +34,28 @@ private function setUpWebsitesAndGoals() { // tests run in UTC, the Tracker in UTC if (!self::siteCreated($idSite = 1)) { - self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'site in AST', $siteUrl = false, - $siteSearch = 1, $searchKeywordParameters = null, - $searchCategoryParameters = null, $timezone = 'America/Barbados' /* AST = UTC-4 */); + self::createWebsite( + $this->dateTime, + $ecommerce = 0, + $siteName = 'site in AST', + $siteUrl = false, + $siteSearch = 1, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $timezone = 'America/Barbados' /* AST = UTC-4 */ + ); } if (!self::siteCreated($idSite = 2)) { - self::createWebsite($this->dateTime, $ecommerce = 0, $siteName = 'site in UTC', $siteUrl = false, - $siteSearch = 1, $searchKeywordParameters = null, - $searchCategoryParameters = null, $timezone = 'UTC'); + self::createWebsite( + $this->dateTime, + $ecommerce = 0, + $siteName = 'site in UTC', + $siteUrl = false, + $siteSearch = 1, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $timezone = 'UTC' + ); } } diff --git a/tests/PHPUnit/Framework/TestRequest/Collection.php b/tests/PHPUnit/Framework/TestRequest/Collection.php index 2ac1b517833..fa152db0312 100644 --- a/tests/PHPUnit/Framework/TestRequest/Collection.php +++ b/tests/PHPUnit/Framework/TestRequest/Collection.php @@ -245,7 +245,8 @@ protected function generateApiUrlPermutations($parametersToSet) // if no subtable found, throw if (!isset($parametersToSet['idSubtable'])) { throw new Exception( - "Cannot find subtable to load for $apiId in {$this->testConfig->supertableApi}."); + "Cannot find subtable to load for $apiId in {$this->testConfig->supertableApi}." + ); } } diff --git a/tests/PHPUnit/Integration/ArchiveProcessingTest.php b/tests/PHPUnit/Integration/ArchiveProcessingTest.php index fc67079474b..0ad6f76dd4b 100644 --- a/tests/PHPUnit/Integration/ArchiveProcessingTest.php +++ b/tests/PHPUnit/Integration/ArchiveProcessingTest.php @@ -291,10 +291,13 @@ public function testTableInsertBatch() $table = Common::prefixTable('site_url'); $data = $this->_getDataInsert(); try { - $didWeUseBulk = BatchInsert::tableInsertBatch($table, + $didWeUseBulk = BatchInsert::tableInsertBatch( + $table, array('idsite', 'url'), $data, - $throwException = true, 'utf8'); + $throwException = true, + 'utf8' + ); } catch (Exception $e) { $didWeUseBulk = $e->getMessage(); } @@ -362,10 +365,13 @@ public function testTableInsertBatchBlob() $data = $this->_getBlobDataInsert(); try { - $didWeUseBulk = BatchInsert::tableInsertBatch($table, + $didWeUseBulk = BatchInsert::tableInsertBatch( + $table, array('idarchive', 'name', 'idsite', 'date1', 'date2', 'period', 'ts_archived', 'value'), $data, - $throwException = true, $charset = 'latin1'); + $throwException = true, + $charset = 'latin1' + ); } catch (Exception $e) { $didWeUseBulk = $e->getMessage(); } diff --git a/tests/PHPUnit/Integration/ArchiveProcessor/LoaderTest.php b/tests/PHPUnit/Integration/ArchiveProcessor/LoaderTest.php index 08163f26726..1d46fde2d76 100644 --- a/tests/PHPUnit/Integration/ArchiveProcessor/LoaderTest.php +++ b/tests/PHPUnit/Integration/ArchiveProcessor/LoaderTest.php @@ -1635,8 +1635,10 @@ private function insertArchive(Parameters $params, $tsArchived = null, $visits = $archiveWriter->finalizeArchive(); if ($tsArchived) { - Db::query("UPDATE " . ArchiveTableCreator::getNumericTable($params->getPeriod()->getDateStart()) . " SET ts_archived = ?", - [Date::factory($tsArchived)->getDatetime()]); + Db::query( + "UPDATE " . ArchiveTableCreator::getNumericTable($params->getPeriod()->getDateStart()) . " SET ts_archived = ?", + [Date::factory($tsArchived)->getDatetime()] + ); } } @@ -1657,8 +1659,10 @@ private function insertArchiveData($archiveRows) $table = !empty($row['is_blob_data']) ? ArchiveTableCreator::getBlobTable($d) : ArchiveTableCreator::getNumericTable($d); $tsArchived = isset($row['ts_archived']) ? $row['ts_archived'] : Date::now()->getDatetime(); - Db::query("INSERT INTO `$table` (idarchive, idsite, period, date1, date2, `name`, `value`, ts_archived) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - [$row['idarchive'], $row['idsite'], $row['period'], $row['date1'], $row['date2'], $row['name'], $row['value'], $tsArchived]); + Db::query( + "INSERT INTO `$table` (idarchive, idsite, period, date1, date2, `name`, `value`, ts_archived) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", + [$row['idarchive'], $row['idsite'], $row['period'], $row['date1'], $row['date2'], $row['name'], $row['value'], $tsArchived] + ); } if (!empty($archiveRows)) {