diff --git a/core/API/ApiRenderer.php b/core/API/ApiRenderer.php index 4a75f3d6e61..36f84e63c22 100644 --- a/core/API/ApiRenderer.php +++ b/core/API/ApiRenderer.php @@ -28,7 +28,9 @@ final public function __construct($request) $this->init(); } - protected function init() {} + protected function init() + { + } abstract public function sendHeader(); @@ -126,5 +128,4 @@ private static function getFormatFromClass($klassname) return strtolower(end($klass)); } - } diff --git a/core/API/CORSHandler.php b/core/API/CORSHandler.php index aeee2ad39d3..779794dfcc0 100644 --- a/core/API/CORSHandler.php +++ b/core/API/CORSHandler.php @@ -38,4 +38,4 @@ public function handle() } } } -} +} diff --git a/core/API/DataTableGenericFilter.php b/core/API/DataTableGenericFilter.php index 1554703910e..5d4ba49422f 100644 --- a/core/API/DataTableGenericFilter.php +++ b/core/API/DataTableGenericFilter.php @@ -11,7 +11,6 @@ use Exception; use Piwik\Common; use Piwik\DataTable; -use Piwik\Plugin; use Piwik\Plugin\ProcessedMetric; use Piwik\Plugin\Report; @@ -39,7 +38,7 @@ class DataTableGenericFilter * * @param $request */ - function __construct($request, $report) + public function __construct($request, $report) { $this->request = $request; $this->report = $report; @@ -225,4 +224,4 @@ private function containsProcessedMetric($metrics, $name) } return false; } -} \ No newline at end of file +} diff --git a/core/API/DataTableManipulator.php b/core/API/DataTableManipulator.php index 862f2db0878..76c52f49586 100644 --- a/core/API/DataTableManipulator.php +++ b/core/API/DataTableManipulator.php @@ -10,7 +10,6 @@ use Exception; use Piwik\Archive\DataTableFactory; -use Piwik\Common; use Piwik\DataTable\Row; use Piwik\DataTable; use Piwik\Period\Range; @@ -63,7 +62,7 @@ protected function manipulate($dataTable) { if ($dataTable instanceof DataTable\Map) { return $this->manipulateDataTableMap($dataTable); - } else if ($dataTable instanceof DataTable) { + } elseif ($dataTable instanceof DataTable) { return $this->manipulateDataTable($dataTable); } else { return $dataTable; @@ -90,7 +89,7 @@ protected function manipulateDataTableMap($dataTable) * Manipulates a single DataTable instance. Derived classes must define * this function. */ - protected abstract function manipulateDataTable($dataTable); + abstract protected function manipulateDataTable($dataTable); /** * Load the subtable for a row. @@ -136,7 +135,7 @@ protected function loadSubtable($dataTable, $row) * @param $request * @return */ - protected abstract function manipulateSubtableRequest($request); + abstract protected function manipulateSubtableRequest($request); /** * Extract the API method for loading subtables from the meta data diff --git a/core/API/DataTableManipulator/ReportTotalsCalculator.php b/core/API/DataTableManipulator/ReportTotalsCalculator.php index 2631b43d5a8..a77b96d51c0 100644 --- a/core/API/DataTableManipulator/ReportTotalsCalculator.php +++ b/core/API/DataTableManipulator/ReportTotalsCalculator.php @@ -10,7 +10,6 @@ use Piwik\API\DataTableManipulator; use Piwik\DataTable; -use Piwik\DataTable\Row; use Piwik\Metrics; use Piwik\Period; use Piwik\Plugin\Report; @@ -62,7 +61,7 @@ public function calculate($table) try { return $this->manipulate($table); - } catch(\Exception $e) { + } catch (\Exception $e) { // eg. requests with idSubtable may trigger this exception // (where idSubtable was removed in // ?module=API&method=Events.getNameFromCategoryId&idSubtable=1&secondaryDimension=eventName&format=XML&idSite=1&period=day&date=yesterday&flat=0 @@ -89,7 +88,7 @@ protected function manipulateDataTable($dataTable) $metricNames = array(); foreach ($metricsToCalculate as $metricId) { - $metricNames[$metricId] = Metrics::getReadableColumnName($metricId);; + $metricNames[$metricId] = Metrics::getReadableColumnName($metricId); } foreach ($firstLevelTable->getRows() as $row) { diff --git a/core/API/DataTablePostProcessor.php b/core/API/DataTablePostProcessor.php index 24d8cf8b6c9..6c63e5e08b6 100644 --- a/core/API/DataTablePostProcessor.php +++ b/core/API/DataTablePostProcessor.php @@ -432,4 +432,4 @@ public function applyComputeProcessedMetrics(DataTableInterface $dataTable) { $dataTable->filter(array($this, 'computeProcessedMetrics')); } -} \ No newline at end of file +} diff --git a/core/API/Inconsistencies.php b/core/API/Inconsistencies.php index 5d0c20d418d..36c85bb9942 100644 --- a/core/API/Inconsistencies.php +++ b/core/API/Inconsistencies.php @@ -39,4 +39,4 @@ public function getPercentMetricsToFormat() '/goal_.*_conversion_rate/' ); } -} \ No newline at end of file +} diff --git a/core/API/Proxy.php b/core/API/Proxy.php index 0f8667d0d87..1576df9ba07 100644 --- a/core/API/Proxy.php +++ b/core/API/Proxy.php @@ -78,7 +78,7 @@ public function registerClass($className) $this->checkClassIsSingleton($className); $rClass = new ReflectionClass($className); - if(!$this->shouldHideAPIMethod($rClass->getDocComment())) { + if (!$this->shouldHideAPIMethod($rClass->getDocComment())) { foreach ($rClass->getMethods() as $method) { $this->loadMethodMetadata($className, $method); } @@ -388,7 +388,6 @@ private function getRequestParametersArray($requiredParameters, $parametersReque $requestValue = Common::getRequestVar($name, null, null, $parametersRequest); } else { try { - if ($name == 'segment' && !empty($parametersRequest['segment'])) { // segment parameter is an exception: we do not want to sanitize user input or it would break the segment encoding $requestValue = ($parametersRequest['segment']); diff --git a/core/API/Request.php b/core/API/Request.php index a21212e7297..bb0a3235652 100644 --- a/core/API/Request.php +++ b/core/API/Request.php @@ -238,7 +238,6 @@ public function process() $returnedValue = Proxy::getInstance()->call($apiClassName, $method, $this->request); $toReturn = $response->getResponse($returnedValue, $module, $method); - } catch (Exception $e) { Log::debug($e); diff --git a/core/API/ResponseBuilder.php b/core/API/ResponseBuilder.php index f12f1f494bf..3fe13f96319 100644 --- a/core/API/ResponseBuilder.php +++ b/core/API/ResponseBuilder.php @@ -15,7 +15,6 @@ use Piwik\DataTable\DataTableInterface; use Piwik\DataTable\Filter\ColumnDelete; use Piwik\DataTable\Filter\Pattern; -use Piwik\Plugin\Report; /** */ diff --git a/core/Access.php b/core/Access.php index 8a3e89ae447..ba0e6628105 100644 --- a/core/Access.php +++ b/core/Access.php @@ -9,7 +9,6 @@ namespace Piwik; use Exception; -use Piwik\Db; /** * Singleton that manages user access to Piwik resources. @@ -226,7 +225,7 @@ private function loadSitesIfNeeded() } $this->idsitesByAccess['superuser'] = $allSitesId; } - } else if (isset($this->login)) { + } elseif (isset($this->login)) { if (empty($this->idsitesByAccess['view']) && empty($this->idsitesByAccess['admin'])) { diff --git a/core/Application/Environment.php b/core/Application/Environment.php index 0e0e4d36782..854410df8cd 100644 --- a/core/Application/Environment.php +++ b/core/Application/Environment.php @@ -185,4 +185,4 @@ private function getGlobalSettingsProviderOverride() return null; } -} \ No newline at end of file +} diff --git a/core/Application/Kernel/EnvironmentValidator.php b/core/Application/Kernel/EnvironmentValidator.php index c416f189d08..c8960c48eb9 100644 --- a/core/Application/Kernel/EnvironmentValidator.php +++ b/core/Application/Kernel/EnvironmentValidator.php @@ -8,7 +8,6 @@ namespace Piwik\Application\Kernel; -use Piwik\Application\Kernel\GlobalSettingsProvider; use Piwik\Common; use Piwik\Piwik; use Piwik\SettingsServer; @@ -78,4 +77,4 @@ private function checkConfigFileExists($path, $startInstaller = false) throw $exception; } } -} \ No newline at end of file +} diff --git a/core/Application/Kernel/GlobalSettingsProvider.php b/core/Application/Kernel/GlobalSettingsProvider.php index 2e69fa9d780..f459e7939e1 100644 --- a/core/Application/Kernel/GlobalSettingsProvider.php +++ b/core/Application/Kernel/GlobalSettingsProvider.php @@ -108,4 +108,4 @@ public function getPathCommon() { return $this->pathCommon; } -} \ No newline at end of file +} diff --git a/core/Application/Kernel/PluginList.php b/core/Application/Kernel/PluginList.php index 1e9c63dcb4d..a79a974a400 100644 --- a/core/Application/Kernel/PluginList.php +++ b/core/Application/Kernel/PluginList.php @@ -54,4 +54,4 @@ public function getPluginsBundledWithPiwik() $section = $this->settings->getIniFileChain()->getFrom($pathGlobal, 'Plugins'); return $section['Plugins']; } -} \ No newline at end of file +} diff --git a/core/Archive.php b/core/Archive.php index 257aa5315ec..a5d6c296090 100644 --- a/core/Archive.php +++ b/core/Archive.php @@ -8,7 +8,6 @@ */ namespace Piwik; -use Piwik\Archive\Chunk; use Piwik\Archive\Parameters; use Piwik\ArchiveProcessor\Rules; use Piwik\Archive\ArchiveInvalidator; @@ -889,9 +888,9 @@ private static function getPluginForReport($report) if (in_array($report, Metrics::getVisitsMetricNames())) { $report = 'VisitsSummary_CoreMetrics'; } // Goal_* metrics are processed by the Goals plugin (HACK) - else if (strpos($report, 'Goal_') === 0) { + elseif (strpos($report, 'Goal_') === 0) { $report = 'Goals_Metrics'; - } else if (strrpos($report, '_returning') === strlen($report) - strlen('_returning')) { // HACK + } elseif (strrpos($report, '_returning') === strlen($report) - strlen('_returning')) { // HACK $report = 'VisitFrequency_Metrics'; } diff --git a/core/Archive/ArchiveInvalidator.php b/core/Archive/ArchiveInvalidator.php index e9ce777cc49..b4523db9d0d 100644 --- a/core/Archive/ArchiveInvalidator.php +++ b/core/Archive/ArchiveInvalidator.php @@ -13,7 +13,6 @@ use Piwik\DataAccess\ArchiveTableCreator; use Piwik\DataAccess\Model; use Piwik\Date; -use Piwik\Db; use Piwik\Option; use Piwik\Plugins\CoreAdminHome\Tasks\ArchivesToPurgeDistributedList; use Piwik\Plugins\PrivacyManager\PrivacyManager; @@ -193,7 +192,7 @@ private function markArchivesInvalidatedFor($idSites, $period, $datesByMonth) // In each table, invalidate day/week/month/year containing this date $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled(); - $archiveNumericTables = array_filter($archiveTables, function($name) { + $archiveNumericTables = array_filter($archiveTables, function ($name) { return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::NUMERIC_TABLE; }); @@ -287,7 +286,6 @@ private function getDatesByYearMonth($datesToInvalidate) $week = Period\Factory::build('week', $date); $weekAsString = $week->getDateStart()->toString('Y_m'); $datesByMonth[$weekAsString][] = $date->toString(); - } return $datesByMonth; } @@ -346,5 +344,4 @@ private static function getModel() { return new Model(); } - -} \ No newline at end of file +} diff --git a/core/Archive/ArchivePurger.php b/core/Archive/ArchivePurger.php index f326558eb2c..078203cb8ff 100644 --- a/core/Archive/ArchivePurger.php +++ b/core/Archive/ArchivePurger.php @@ -14,7 +14,6 @@ use Piwik\DataAccess\ArchiveTableCreator; use Piwik\DataAccess\Model; use Piwik\Date; -use Piwik\Db; use Piwik\Piwik; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; @@ -270,4 +269,4 @@ public function setNow($now) { $this->now = $now; } -} \ No newline at end of file +} diff --git a/core/Archive/DataCollection.php b/core/Archive/DataCollection.php index 7973d014818..36ba553f527 100644 --- a/core/Archive/DataCollection.php +++ b/core/Archive/DataCollection.php @@ -331,7 +331,7 @@ private function createOrderedIndex($metadataNamesToIndexBy) if ($metadataName == DataTableFactory::TABLE_METADATA_SITE_INDEX) { $indexKeyValues = array_values($this->sitesId); - } else if ($metadataName == DataTableFactory::TABLE_METADATA_PERIOD_INDEX) { + } elseif ($metadataName == DataTableFactory::TABLE_METADATA_PERIOD_INDEX) { $indexKeyValues = array_keys($this->periods); } @@ -342,7 +342,6 @@ private function createOrderedIndex($metadataNamesToIndexBy) $result[$key] = $this->createOrderedIndex($metadataNamesToIndexBy); } } - } return $result; diff --git a/core/Archive/DataTableFactory.php b/core/Archive/DataTableFactory.php index a82b43bb749..e8b17b6731e 100644 --- a/core/Archive/DataTableFactory.php +++ b/core/Archive/DataTableFactory.php @@ -542,4 +542,4 @@ private function makeMergedWithSiteIndex($index, $useSimpleDataTable, $isNumeric return $table; } -} \ No newline at end of file +} diff --git a/core/Archive/Parameters.php b/core/Archive/Parameters.php index ad7bef9eb6f..905166debf0 100644 --- a/core/Archive/Parameters.php +++ b/core/Archive/Parameters.php @@ -57,4 +57,3 @@ public function getIdSites() return $this->idSites; } } - diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php index ccfa939d944..66c0e688063 100644 --- a/core/ArchiveProcessor.php +++ b/core/ArchiveProcessor.php @@ -17,9 +17,6 @@ use Piwik\DataTable\Manager; use Piwik\DataTable\Map; use Piwik\DataTable\Row; -use Piwik\Db; -use Piwik\Period; - /** * Used by {@link Piwik\Plugin\Archiver} instances to insert and aggregate archive data. * @@ -258,7 +255,7 @@ public function aggregateNumericMetrics($columns, $operationToApply = false) { $metrics = $this->getAggregatedNumericMetrics($columns, $operationToApply); - foreach($metrics as $column => $value) { + foreach ($metrics as $column => $value) { $value = Common::forceDotAsSeparatorForDecimalPoint($value); $this->archiveWriter->insertRecord($column, $value); } @@ -432,10 +429,10 @@ protected function enrichWithUniqueVisitorsMetric(Row $row) Metrics::INDEX_NB_USERS ); - if($this->getParams()->isSingleSite()) { + if ($this->getParams()->isSingleSite()) { $uniqueVisitorsMetric = Metrics::INDEX_NB_UNIQ_VISITORS; } else { - if(!SettingsPiwik::isSameFingerprintAcrossWebsites()) { + if (!SettingsPiwik::isSameFingerprintAcrossWebsites()) { throw new Exception("Processing unique visitors across websites is enabled for this instance, but to process this metric you must first set enable_fingerprinting_across_websites=1 in the config file, under the [Tracker] section."); @@ -444,7 +441,7 @@ protected function enrichWithUniqueVisitorsMetric(Row $row) } $metrics[] = $uniqueVisitorsMetric; - $uniques = $this->computeNbUniques( $metrics ); + $uniques = $this->computeNbUniques($metrics); $row->setColumn('nb_uniq_visitors', $uniques[$uniqueVisitorsMetric]); $row->setColumn('nb_users', $uniques[Metrics::INDEX_NB_USERS]); } @@ -573,4 +570,4 @@ protected function getAggregatedNumericMetrics($columns, $operationToApply) return $metrics; } -} \ No newline at end of file +} diff --git a/core/ArchiveProcessor/Loader.php b/core/ArchiveProcessor/Loader.php index b684d8fee1a..f4c139b1ea9 100644 --- a/core/ArchiveProcessor/Loader.php +++ b/core/ArchiveProcessor/Loader.php @@ -7,8 +7,8 @@ * */ namespace Piwik\ArchiveProcessor; + use Piwik\Archive; -use Piwik\ArchiveProcessor; use Piwik\Config; use Piwik\DataAccess\ArchiveSelector; use Piwik\Date; @@ -223,6 +223,4 @@ protected function isArchiveTemporary() return $this->temporaryArchive; } - } - diff --git a/core/ArchiveProcessor/PluginsArchiver.php b/core/ArchiveProcessor/PluginsArchiver.php index 74871287280..fe35aa4f2b8 100644 --- a/core/ArchiveProcessor/PluginsArchiver.php +++ b/core/ArchiveProcessor/PluginsArchiver.php @@ -9,7 +9,6 @@ namespace Piwik\ArchiveProcessor; -use Piwik\Archive; use Piwik\ArchiveProcessor; use Piwik\DataAccess\ArchiveWriter; use Piwik\DataTable\Manager; @@ -130,7 +129,7 @@ public function callAggregateAllPlugins($visits, $visitsConverted) public function finalizeArchive() { - $this->params->logStatusDebug( $this->archiveWriter->isArchiveTemporary ); + $this->params->logStatusDebug($this->archiveWriter->isArchiveTemporary); $this->archiveWriter->finalizeArchive(); return $this->archiveWriter->getIdArchive(); } @@ -212,5 +211,4 @@ protected function aggregateMultipleVisitsMetrics() $metrics = $this->archiveProcessor->aggregateNumericMetrics($toSum); return $metrics; } - } diff --git a/core/ArchiveProcessor/Rules.php b/core/ArchiveProcessor/Rules.php index 4ad2fd1b25b..caa5a627fb4 100644 --- a/core/ArchiveProcessor/Rules.php +++ b/core/ArchiveProcessor/Rules.php @@ -277,4 +277,4 @@ public static function getSelectableDoneFlagValues() return $possibleValues; } -} \ No newline at end of file +} diff --git a/core/AssetManager.php b/core/AssetManager.php index 28f8407b793..a1a1762a4b6 100644 --- a/core/AssetManager.php +++ b/core/AssetManager.php @@ -19,10 +19,8 @@ use Piwik\AssetManager\UIAssetFetcher; use Piwik\AssetManager\UIAssetMerger\JScriptUIAssetMerger; use Piwik\AssetManager\UIAssetMerger\StylesheetUIAssetMerger; -use Piwik\Config as PiwikConfig; use Piwik\Container\StaticContainer; use Piwik\Plugin\Manager; -use Piwik\Translate; /** * AssetManager is the class used to manage the inclusion of UI assets: @@ -67,7 +65,7 @@ class AssetManager extends Singleton */ private $theme; - function __construct() + public function __construct() { $this->cacheBuster = UIAssetCacheBuster::getInstance(); $this->minimalStylesheetFetcher = new StaticUIAssetFetcher(array('plugins/Morpheus/stylesheets/base.less', 'plugins/Morpheus/stylesheets/general/_forms.less'), array(), $this->theme); @@ -122,14 +120,11 @@ public function getJsInclusionDirective() $result = ""; if ($this->isMergedAssetsDisabled()) { - $this->getMergedCoreJSAsset()->delete(); $this->getMergedNonCoreJSAsset()->delete(); $result .= $this->getIndividualJsIncludes(); - } else { - $result .= sprintf(self::JS_IMPORT_DIRECTIVE, self::GET_CORE_JS_MODULE_ACTION); $result .= sprintf(self::JS_IMPORT_DIRECTIVE, self::GET_NON_CORE_JS_MODULE_ACTION); } @@ -202,13 +197,13 @@ public function getLoadedPlugins($core) { $loadedPlugins = array(); - foreach(Manager::getInstance()->getPluginsLoadedAndActivated() as $plugin) { - + foreach (Manager::getInstance()->getPluginsLoadedAndActivated() as $plugin) { $pluginName = $plugin->getPluginName(); $pluginIsCore = Manager::getInstance()->isPluginBundledWithCore($pluginName); - if (($pluginIsCore && $core) || (!$pluginIsCore && !$core)) + if (($pluginIsCore && $core) || (!$pluginIsCore && !$core)) { $loadedPlugins[] = $pluginName; + } } return $loadedPlugins; @@ -222,21 +217,14 @@ public function removeMergedAssets($pluginName = false) $assetsToRemove = array($this->getMergedStylesheetAsset()); if ($pluginName) { - if ($this->pluginContainsJScriptAssets($pluginName)) { - if (Manager::getInstance()->isPluginBundledWithCore($pluginName)) { - $assetsToRemove[] = $this->getMergedCoreJSAsset(); - } else { - $assetsToRemove[] = $this->getMergedNonCoreJSAsset(); } } - } else { - $assetsToRemove[] = $this->getMergedCoreJSAsset(); $assetsToRemove[] = $this->getMergedNonCoreJSAsset(); } @@ -310,7 +298,6 @@ private function getIndividualJsIncludesFromAssetFetcher($assetFetcher) $jsIncludeString = ''; foreach ($assetFetcher->getCatalog()->getAssets() as $jsFile) { - $jsFile->validateFile(); $jsIncludeString = $jsIncludeString . sprintf(self::JS_IMPORT_DIRECTIVE, $jsFile->getRelativeLocation()); } @@ -338,7 +325,7 @@ private function pluginContainsJScriptAssets($pluginName) try { $assets = $fetcher->getCatalog()->getAssets(); - } catch(\Exception $e) { + } catch (\Exception $e) { // This can happen when a plugin is not valid (eg. Piwik 1.x format) // When posting the event to the plugin, it returns an exception "Plugin has not been loaded" return false; @@ -347,13 +334,13 @@ private function pluginContainsJScriptAssets($pluginName) $plugin = Manager::getInstance()->getLoadedPlugin($pluginName); if ($plugin->isTheme()) { - $theme = Manager::getInstance()->getTheme($pluginName); $javaScriptFiles = $theme->getJavaScriptFiles(); - if (!empty($javaScriptFiles)) + if (!empty($javaScriptFiles)) { $assets = array_merge($assets, $javaScriptFiles); + } } return !empty($assets); @@ -364,7 +351,7 @@ private function pluginContainsJScriptAssets($pluginName) */ public function removeAssets($uiAssets) { - foreach($uiAssets as $uiAsset) { + foreach ($uiAssets as $uiAsset) { $uiAsset->delete(); } } diff --git a/core/AssetManager/UIAsset/OnDiskUIAsset.php b/core/AssetManager/UIAsset/OnDiskUIAsset.php index fc4b8343427..cbd702a691d 100644 --- a/core/AssetManager/UIAsset/OnDiskUIAsset.php +++ b/core/AssetManager/UIAsset/OnDiskUIAsset.php @@ -28,7 +28,7 @@ class OnDiskUIAsset extends UIAsset * @param string $baseDirectory * @param string $fileLocation */ - function __construct($baseDirectory, $fileLocation) + public function __construct($baseDirectory, $fileLocation) { $this->baseDirectory = $baseDirectory; $this->relativeLocation = $fileLocation; @@ -51,14 +51,14 @@ public function getBaseDirectory() public function validateFile() { - if (!$this->assetIsReadable()) + if (!$this->assetIsReadable()) { throw new Exception("The ui asset with 'href' = " . $this->getAbsoluteLocation() . " is not readable"); + } } public function delete() { if ($this->exists()) { - try { Filesystem::remove($this->getAbsoluteLocation()); } catch (Exception $e) { @@ -81,8 +81,9 @@ public function writeContent($content) $newFile = @fopen($this->getAbsoluteLocation(), "w"); - if (!$newFile) - throw new Exception ("The file : " . $newFile . " can not be opened in write mode."); + if (!$newFile) { + throw new Exception("The file : " . $newFile . " can not be opened in write mode."); + } fwrite($newFile, $content); diff --git a/core/AssetManager/UIAssetCatalog.php b/core/AssetManager/UIAssetCatalog.php index 826259ecb37..18af99778aa 100644 --- a/core/AssetManager/UIAssetCatalog.php +++ b/core/AssetManager/UIAssetCatalog.php @@ -28,7 +28,7 @@ class UIAssetCatalog /** * @param UIAssetCatalogSorter $catalogSorter */ - function __construct($catalogSorter) + public function __construct($catalogSorter) { $this->catalogSorter = $catalogSorter; } diff --git a/core/AssetManager/UIAssetCatalogSorter.php b/core/AssetManager/UIAssetCatalogSorter.php index b6d00b359a0..fece3da0d8e 100644 --- a/core/AssetManager/UIAssetCatalogSorter.php +++ b/core/AssetManager/UIAssetCatalogSorter.php @@ -18,7 +18,7 @@ class UIAssetCatalogSorter /** * @param string[] $priorityOrder */ - function __construct($priorityOrder) + public function __construct($priorityOrder) { $this->priorityOrder = $priorityOrder; } @@ -31,12 +31,11 @@ public function sortUIAssetCatalog($uiAssetCatalog) { $sortedCatalog = new UIAssetCatalog($this); foreach ($this->priorityOrder as $filePattern) { - - $assetsMatchingPattern = array_filter($uiAssetCatalog->getAssets(), function($uiAsset) use ($filePattern) { + $assetsMatchingPattern = array_filter($uiAssetCatalog->getAssets(), function ($uiAsset) use ($filePattern) { return preg_match('~^' . $filePattern . '~', $uiAsset->getRelativeLocation()); }); - foreach($assetsMatchingPattern as $assetMatchingPattern) { + foreach ($assetsMatchingPattern as $assetMatchingPattern) { $sortedCatalog->addUIAsset($assetMatchingPattern); } } diff --git a/core/AssetManager/UIAssetFetcher.php b/core/AssetManager/UIAssetFetcher.php index 3bd34c118e6..6d710e13870 100644 --- a/core/AssetManager/UIAssetFetcher.php +++ b/core/AssetManager/UIAssetFetcher.php @@ -37,7 +37,7 @@ abstract class UIAssetFetcher * @param string[] $plugins * @param Theme $theme */ - function __construct($plugins, $theme) + public function __construct($plugins, $theme) { $this->plugins = $plugins; $this->theme = $theme; @@ -56,8 +56,9 @@ public function getPlugins() */ public function getCatalog() { - if ($this->catalog == null) + if ($this->catalog == null) { $this->createCatalog(); + } return $this->catalog; } @@ -89,7 +90,6 @@ private function initCatalog() private function populateCatalog() { foreach ($this->fileLocations as $fileLocation) { - $newUIAsset = new OnDiskUIAsset($this->getBaseDirectory(), $fileLocation); $this->catalog->addUIAsset($newUIAsset); } diff --git a/core/AssetManager/UIAssetFetcher/JScriptUIAssetFetcher.php b/core/AssetManager/UIAssetFetcher/JScriptUIAssetFetcher.php index f916772e2ff..d8ec05ca53c 100644 --- a/core/AssetManager/UIAssetFetcher/JScriptUIAssetFetcher.php +++ b/core/AssetManager/UIAssetFetcher/JScriptUIAssetFetcher.php @@ -16,7 +16,6 @@ class JScriptUIAssetFetcher extends UIAssetFetcher protected function retrieveFileLocations() { - if (!empty($this->plugins)) { /** @@ -56,13 +55,10 @@ protected function addThemeFiles() return; } if (in_array($theme->getThemeName(), $this->plugins)) { - $jsInThemes = $this->getTheme()->getJavaScriptFiles(); if (!empty($jsInThemes)) { - - foreach($jsInThemes as $jsFile) { - + foreach ($jsInThemes as $jsFile) { $this->fileLocations[] = $jsFile; } } diff --git a/core/AssetManager/UIAssetFetcher/StaticUIAssetFetcher.php b/core/AssetManager/UIAssetFetcher/StaticUIAssetFetcher.php index 984282e4a76..cdebbb1eb57 100644 --- a/core/AssetManager/UIAssetFetcher/StaticUIAssetFetcher.php +++ b/core/AssetManager/UIAssetFetcher/StaticUIAssetFetcher.php @@ -17,7 +17,7 @@ class StaticUIAssetFetcher extends UIAssetFetcher */ private $priorityOrder; - function __construct($fileLocations, $priorityOrder, $theme) + public function __construct($fileLocations, $priorityOrder, $theme) { parent::__construct(array(), $theme); @@ -27,7 +27,6 @@ function __construct($fileLocations, $priorityOrder, $theme) protected function retrieveFileLocations() { - } protected function getPriorityOrder() diff --git a/core/AssetManager/UIAssetMerger.php b/core/AssetManager/UIAssetMerger.php index 42b5ce0cfee..645f003d7c7 100644 --- a/core/AssetManager/UIAssetMerger.php +++ b/core/AssetManager/UIAssetMerger.php @@ -8,9 +8,6 @@ */ namespace Piwik\AssetManager; -use Piwik\AssetManager\PiwikLessCompiler; -use Piwik\AssetManager\UIAsset\StylesheetUIAsset; -use Piwik\AssetManager; abstract class UIAssetMerger { @@ -39,7 +36,7 @@ abstract class UIAssetMerger * @param UIAssetFetcher $assetFetcher * @param UIAssetCacheBuster $cacheBuster */ - function __construct($mergedAsset, $assetFetcher, $cacheBuster) + public function __construct($mergedAsset, $assetFetcher, $cacheBuster) { $this->mergedAsset = $mergedAsset; $this->assetFetcher = $assetFetcher; @@ -48,8 +45,9 @@ function __construct($mergedAsset, $assetFetcher, $cacheBuster) public function generateFile() { - if (!$this->shouldGenerate()) + if (!$this->shouldGenerate()) { return; + } $this->mergedContent = $this->getMergedAssets(); @@ -107,7 +105,6 @@ private function concatenateAssets() $mergedContent = ''; foreach ($this->getAssetCatalog()->getAssets() as $uiAsset) { - $uiAsset->validateFile(); $content = $this->processFileContent($uiAsset); @@ -182,8 +179,9 @@ private function writeContentToFile() */ protected function getCacheBusterValue() { - if (empty($this->cacheBusterValue)) + if (empty($this->cacheBusterValue)) { $this->cacheBusterValue = $this->generateCacheBuster(); + } return $this->cacheBusterValue; } diff --git a/core/AssetManager/UIAssetMerger/JScriptUIAssetMerger.php b/core/AssetManager/UIAssetMerger/JScriptUIAssetMerger.php index 935018c580b..1b738e8de5d 100644 --- a/core/AssetManager/UIAssetMerger/JScriptUIAssetMerger.php +++ b/core/AssetManager/UIAssetMerger/JScriptUIAssetMerger.php @@ -28,7 +28,7 @@ class JScriptUIAssetMerger extends UIAssetMerger * @param JScriptUIAssetFetcher $assetFetcher * @param UIAssetCacheBuster $cacheBuster */ - function __construct($mergedAsset, $assetFetcher, $cacheBuster) + public function __construct($mergedAsset, $assetFetcher, $cacheBuster) { parent::__construct($mergedAsset, $assetFetcher, $cacheBuster); @@ -81,8 +81,9 @@ protected function processFileContent($uiAsset) { $content = $uiAsset->getContent(); - if (!$this->assetMinifier->isMinifiedJs($content)) + if (!$this->assetMinifier->isMinifiedJs($content)) { $content = $this->assetMinifier->minifyJs($content); + } return $content; } diff --git a/core/AssetManager/UIAssetMerger/StylesheetUIAssetMerger.php b/core/AssetManager/UIAssetMerger/StylesheetUIAssetMerger.php index 232b1ab8258..5161b2f1df3 100644 --- a/core/AssetManager/UIAssetMerger/StylesheetUIAssetMerger.php +++ b/core/AssetManager/UIAssetMerger/StylesheetUIAssetMerger.php @@ -21,7 +21,7 @@ class StylesheetUIAssetMerger extends UIAssetMerger */ private $lessCompiler; - function __construct($mergedAsset, $assetFetcher, $cacheBuster) + public function __construct($mergedAsset, $assetFetcher, $cacheBuster) { parent::__construct($mergedAsset, $assetFetcher, $cacheBuster); @@ -97,7 +97,7 @@ protected function processFileContent($uiAsset) */ private function rewriteCssImagePaths($content, $pathsRewriter) { - $content = preg_replace_callback( "/(url\(['\"]?)([^'\")]*)/", $pathsRewriter, $content ); + $content = preg_replace_callback("/(url\(['\"]?)([^'\")]*)/", $pathsRewriter, $content); return $content; } @@ -110,7 +110,7 @@ private function rewriteCssImagePaths($content, $pathsRewriter) */ private function rewriteCssImportPaths($content, $pathsRewriter) { - $content = preg_replace_callback( "/(@import \")([^\")]*)/", $pathsRewriter, $content ); + $content = preg_replace_callback("/(@import \")([^\")]*)/", $pathsRewriter, $content); return $content; } diff --git a/core/AssetManager/UIAssetMinifier.php b/core/AssetManager/UIAssetMinifier.php index 07dd3c769dc..99eebe0a6c2 100644 --- a/core/AssetManager/UIAssetMinifier.php +++ b/core/AssetManager/UIAssetMinifier.php @@ -59,8 +59,8 @@ public function minifyJs($content) private static function validateDependency() { - if (!class_exists("JShrink\\Minifier")) + if (!class_exists("JShrink\\Minifier")) { throw new Exception("JShrink could not be found, maybe you are using Piwik from git and need to update Composer. $ php composer.phar update"); + } } - } diff --git a/core/Auth.php b/core/Auth.php index 45bc22062b8..0ea9503a2b1 100644 --- a/core/Auth.php +++ b/core/Auth.php @@ -218,4 +218,4 @@ public function wasAuthenticationSuccessful() { return $this->code > self::FAILURE; } -} \ No newline at end of file +} diff --git a/core/BaseFactory.php b/core/BaseFactory.php index 0bc8716eb2c..24425c8fee4 100644 --- a/core/BaseFactory.php +++ b/core/BaseFactory.php @@ -12,13 +12,13 @@ /** * Base class for all factory types. - * + * * Factory types are base classes that contain a **factory** method. This method is used to instantiate * concrete instances by a specified string ID. Fatal errors do not occur if a class does not exist. * Instead an exception is thrown. * * Derived classes should override the **getClassNameFromClassId** and **getInvalidClassIdExceptionMessage** - * static methods. + * static methods. */ abstract class BaseFactory { @@ -57,4 +57,4 @@ protected static function getInvalidClassIdExceptionMessage($id) { return "Invalid class ID '$id' for " . get_called_class() . "::factory()."; } -} \ No newline at end of file +} diff --git a/core/CacheId.php b/core/CacheId.php index e445424009c..cc346bee54c 100644 --- a/core/CacheId.php +++ b/core/CacheId.php @@ -8,7 +8,6 @@ */ namespace Piwik; -use Piwik\Translate; use Piwik\Plugin\Manager; class CacheId diff --git a/core/CliMulti.php b/core/CliMulti.php index 6b463aec0de..bd310dcddc3 100644 --- a/core/CliMulti.php +++ b/core/CliMulti.php @@ -16,7 +16,8 @@ /** * Class CliMulti. */ -class CliMulti { +class CliMulti +{ /** * If set to true or false it will overwrite whether async is supported or not. @@ -70,11 +71,11 @@ public function request(array $piwikUrls) { $chunks = array($piwikUrls); if ($this->concurrentProcessesLimit) { - $chunks = array_chunk( $piwikUrls, $this->concurrentProcessesLimit); + $chunks = array_chunk($piwikUrls, $this->concurrentProcessesLimit); } $results = array(); - foreach($chunks as $urlsChunk) { + foreach ($chunks as $urlsChunk) { $results = array_merge($results, $this->requestUrls($urlsChunk)); } @@ -159,7 +160,6 @@ private function hasFinished() // ==> declare the process as finished $process->finishProcess(); continue; - } elseif (!$hasStarted) { return false; } @@ -236,7 +236,7 @@ public static function cleanupNotRemovedFiles() if (file_exists($file)) { $timeLastModified = filemtime($file); - if ($timeLastModified !== FALSE && $timeOneWeekAgo > $timeLastModified) { + if ($timeLastModified !== false && $timeOneWeekAgo > $timeLastModified) { unlink($file); } } @@ -344,7 +344,7 @@ private static function getSuperUserTokenAuths() /** * Used to be in CronArchive, moved to CliMulti. - * + * * @ignore */ Piwik::postEvent('CronArchive.getTokenAuth', array(&$tokens)); diff --git a/core/CliMulti/CliPhp.php b/core/CliMulti/CliPhp.php index 101f9277c6c..c405d66abab 100644 --- a/core/CliMulti/CliPhp.php +++ b/core/CliMulti/CliPhp.php @@ -7,7 +7,6 @@ */ namespace Piwik\CliMulti; -use Piwik\CliMulti; use Piwik\Common; class CliPhp @@ -16,7 +15,6 @@ class CliPhp public function findPhpBinary() { if (defined('PHP_BINARY')) { - if ($this->isHhvmBinary(PHP_BINARY)) { return PHP_BINARY . ' --php'; } diff --git a/core/CliMulti/Output.php b/core/CliMulti/Output.php index e4feb1a8055..b97df74692a 100644 --- a/core/CliMulti/Output.php +++ b/core/CliMulti/Output.php @@ -10,7 +10,8 @@ use Piwik\CliMulti; use Piwik\Filesystem; -class Output { +class Output +{ private $tmpFile = ''; private $outputId = null; @@ -64,5 +65,4 @@ public function destroy() { Filesystem::deleteFileIfExists($this->tmpFile); } - } diff --git a/core/CliMulti/Process.php b/core/CliMulti/Process.php index 58d3b0978dc..e1d702fdf12 100644 --- a/core/CliMulti/Process.php +++ b/core/CliMulti/Process.php @@ -243,15 +243,15 @@ private static function isProcFSMounted() /** * @return int[] The ids of the currently running processes */ - static function getRunningProcesses() - { - $ids = explode("\n", trim(`ps ex 2>/dev/null | awk '{print $1}' 2>/dev/null`)); + public static function getRunningProcesses() + { + $ids = explode("\n", trim(`ps ex 2>/dev/null | awk '{print $1}' 2>/dev/null`)); - $ids = array_map('intval', $ids); - $ids = array_filter($ids, function ($id) { + $ids = array_map('intval', $ids); + $ids = array_filter($ids, function ($id) { return $id > 0; }); - return $ids; - } + return $ids; + } } diff --git a/core/CliMulti/RequestCommand.php b/core/CliMulti/RequestCommand.php index 36c5b89c756..d2dbb1eafb9 100644 --- a/core/CliMulti/RequestCommand.php +++ b/core/CliMulti/RequestCommand.php @@ -10,13 +10,11 @@ use Piwik\Application\Environment; use Piwik\Access; -use Piwik\Config; use Piwik\Container\StaticContainer; use Piwik\Db; use Piwik\Log; use Piwik\Option; use Piwik\Plugin\ConsoleCommand; -use Piwik\Tests\Framework\Mock\TestConfig; use Piwik\Url; use Piwik\UrlHelper; use Symfony\Component\Console\Input\InputArgument; diff --git a/core/Columns/Dimension.php b/core/Columns/Dimension.php index e760a090832..8da3822fa99 100644 --- a/core/Columns/Dimension.php +++ b/core/Columns/Dimension.php @@ -15,7 +15,6 @@ use Piwik\Plugin\Dimension\ConversionDimension; use Piwik\Plugin\Dimension\VisitDimension; use Piwik\Plugin\Segment; -use Piwik\Translate; /** * @api @@ -240,4 +239,4 @@ public function getModule() $parts = explode('.', $id); return reset($parts); } -} \ No newline at end of file +} diff --git a/core/Columns/Updater.php b/core/Columns/Updater.php index e1345a2dc2b..f6121165bb3 100644 --- a/core/Columns/Updater.php +++ b/core/Columns/Updater.php @@ -226,7 +226,7 @@ public static function wasDimensionMovedFromCoreToPlugin($name, $version) // maps names of core dimension columns that were part of the original dimension refactor with their // initial "version" strings. The '1' that is sometimes appended to the end of the string (sometimes seen as // NULL1) is from individual dimension "versioning" logic (eg, see VisitDimension::getVersion()) - $initialCoreDimensionVersions = array ( + $initialCoreDimensionVersions = array( 'log_visit.config_resolution' => 'VARCHAR(9) NOT NULL', 'log_visit.config_device_brand' => 'VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL', 'log_visit.config_device_model' => 'VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL', @@ -339,4 +339,4 @@ private static function getCachedDimensionFileChanges() return array(); } -} \ No newline at end of file +} diff --git a/core/Common.php b/core/Common.php index 22f8cac2f13..64213d13188 100644 --- a/core/Common.php +++ b/core/Common.php @@ -13,7 +13,6 @@ use Piwik\Intl\Data\Provider\LanguageDataProvider; use Piwik\Intl\Data\Provider\RegionDataProvider; use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider; -use Piwik\Tracker; use Piwik\Tracker\Cache as TrackerCache; /** @@ -269,8 +268,9 @@ public static function sanitizeInputValues($value, $alreadyStripslashed = false) } elseif (is_string($value)) { $value = self::sanitizeString($value); - if (!$alreadyStripslashed) // a JSON array was already stripslashed, don't do it again for each value - { + if (!$alreadyStripslashed) { + // a JSON array was already stripslashed, don't do it again for each value + $value = self::undoMagicQuotes($value); } } elseif (is_array($value)) { @@ -480,20 +480,25 @@ public static function getRequestVar($varName, $varDefault = null, $varType = nu if ($varType === 'string') { if (is_string($value) || is_int($value)) { $ok = true; - } else if (is_float($value)) { + } elseif (is_float($value)) { $value = Common::forceDotAsSeparatorForDecimalPoint($value); $ok = true; } - } elseif ($varType === 'integer') { - if ($value == (string)(int)$value) $ok = true; + if ($value == (string)(int)$value) { + $ok = true; + } } elseif ($varType === 'float') { $valueToCompare = (string)(float)$value; $valueToCompare = Common::forceDotAsSeparatorForDecimalPoint($valueToCompare); - if ($value == $valueToCompare) $ok = true; + if ($value == $valueToCompare) { + $ok = true; + } } elseif ($varType === 'array') { - if (is_array($value)) $ok = true; + if (is_array($value)) { + $ok = true; + } } else { throw new Exception("\$varType specified is not known. It should be one of the following: array, int, integer, float, string"); } @@ -552,7 +557,6 @@ public static function hash($str, $raw_output = false) if ($hashAlgorithm) { $hash = @hash($hashAlgorithm, $str, $raw_output); if ($hash !== false) { - return $hash; } } @@ -818,7 +822,6 @@ public static function getSearchEngineUrls() $searchEngines = $cache->fetch($cacheId); if (empty($searchEngines)) { - require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/SearchEngines.php'; $searchEngines = $GLOBALS['Piwik_SearchEngines']; @@ -845,7 +848,6 @@ public static function getSearchEngineNames() $nameToUrl = $cache->fetch($cacheId); if (empty($nameToUrl)) { - $searchEngines = self::getSearchEngineUrls(); $nameToUrl = array(); @@ -874,7 +876,6 @@ public static function getSocialUrls() $socialUrls = $cache->fetch($cacheId); if (empty($socialUrls)) { - require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/Socials.php'; $socialUrls = $GLOBALS['Piwik_socialUrl']; @@ -1025,12 +1026,12 @@ public static function extractLanguageCodeFromBrowserLanguage($browserLanguage, $validLanguages = self::checkValidLanguagesIsSet($validLanguages); $languageRegionCode = self::extractLanguageAndRegionCodeFromBrowserLanguage($browserLanguage, $validLanguages); - if(strlen($languageRegionCode) == 2) { + if (strlen($languageRegionCode) == 2) { $languageCode = $languageRegionCode; } else { $languageCode = substr($languageRegionCode, 0, 2); } - if(in_array($languageCode, $validLanguages)) { + if (in_array($languageCode, $validLanguages)) { return $languageCode; } return self::LANGUAGE_CODE_INVALID; @@ -1045,16 +1046,16 @@ public static function extractLanguageCodeFromBrowserLanguage($browserLanguage, * @param array $validLanguages array of valid language codes. Note that if the array includes "fr" then it will consider all regional variants of this language valid, such as "fr-ca" etc. * @return string 2 letter ISO 639 code 'es' (Spanish) or if found, includes the region as well: 'es-ar' */ - public static function extractLanguageAndRegionCodeFromBrowserLanguage($browserLanguage, $validLanguages = array() ) + public static function extractLanguageAndRegionCodeFromBrowserLanguage($browserLanguage, $validLanguages = array()) { $validLanguages = self::checkValidLanguagesIsSet($validLanguages); - if(!preg_match_all('/(?:^|,)([a-z]{2,3})([-][a-z]{2})?/', $browserLanguage, $matches, PREG_SET_ORDER)) { + if (!preg_match_all('/(?:^|,)([a-z]{2,3})([-][a-z]{2})?/', $browserLanguage, $matches, PREG_SET_ORDER)) { return self::LANGUAGE_CODE_INVALID; } foreach ($matches as $parts) { $langIso639 = $parts[1]; - if(empty($langIso639)) { + if (empty($langIso639)) { continue; } @@ -1219,7 +1220,6 @@ public static function sendResponseCode($code) && strlen($_SERVER['SERVER_PROTOCOL']) > 1) { $key = $_SERVER['SERVER_PROTOCOL']; } - } else { // FastCGI $key = 'Status:'; @@ -1261,11 +1261,10 @@ public static function destroy(&$var) * @todo This method is weird, it's debugging statements but seem to only work for the tracker, maybe it * should be moved elsewhere */ - public static function printDebug($info = '') + public static function printDebug($info = '') { if (isset($GLOBALS['PIWIK_TRACKER_DEBUG']) && $GLOBALS['PIWIK_TRACKER_DEBUG']) { - - if(!headers_sent()) { + if (!headers_sent()) { // prevent XSS in tracker debug output header('Content-type: text/plain'); } diff --git a/core/Concurrency/DistributedList.php b/core/Concurrency/DistributedList.php index 723fda6c761..572b25d6ff0 100644 --- a/core/Concurrency/DistributedList.php +++ b/core/Concurrency/DistributedList.php @@ -167,4 +167,4 @@ protected function getListOptionValue() } return $result; } -} \ No newline at end of file +} diff --git a/core/Config/IniFileChain.php b/core/Config/IniFileChain.php index 3f6f076cd8d..e8384a4f3a2 100644 --- a/core/Config/IniFileChain.php +++ b/core/Config/IniFileChain.php @@ -175,12 +175,12 @@ public function dumpChanges($header = '') if ($lhsIndexInFile == $rhsIndexInFile) { return 0; - } else if ($lhsIndexInFile < $rhsIndexInFile) { + } elseif ($lhsIndexInFile < $rhsIndexInFile) { return -1; } else { return 1; } - } else if ($lhsIndex < $rhsIndex) { + } elseif ($lhsIndex < $rhsIndex) { return -1; } else { return 1; @@ -219,7 +219,7 @@ public function reload($defaultSettingsFiles = array(), $userSettingsFile = null } $this->mergedSettings = $this->mergeFileSettings(); - } + } private function resetSettingsChain($defaultSettingsFiles, $userSettingsFile) { @@ -355,12 +355,12 @@ public function arrayUnmerge($original, $modified) * @author Daniel * @author Gabriel Sobrinho */ - private function array_merge_recursive_distinct ( array &$array1, array &$array2 ) + private function array_merge_recursive_distinct(array &$array1, array &$array2) { $merged = $array1; - foreach ( $array2 as $key => &$value ) { - if ( is_array ( $value ) && isset ( $merged [$key] ) && is_array ( $merged [$key] ) ) { - $merged [$key] = $this->array_merge_recursive_distinct ( $merged [$key], $value ); + foreach ($array2 as $key => &$value) { + if (is_array($value) && isset($merged [$key]) && is_array($merged [$key])) { + $merged [$key] = $this->array_merge_recursive_distinct($merged [$key], $value); } else { $merged [$key] = $value; } @@ -451,4 +451,4 @@ private function dumpSettings($values, $header) $writer = new IniWriter(); return $writer->writeToString($values, $header); } -} \ No newline at end of file +} diff --git a/core/Console.php b/core/Console.php index 988034362ff..5a3ff2f5415 100644 --- a/core/Console.php +++ b/core/Console.php @@ -82,7 +82,7 @@ private function addCommandIfExists($command) { if (!class_exists($command)) { Log::warning(sprintf('Cannot add command %s, class does not exist', $command)); - } else if (!is_subclass_of($command, 'Piwik\Plugin\ConsoleCommand')) { + } elseif (!is_subclass_of($command, 'Piwik\Plugin\ConsoleCommand')) { Log::warning(sprintf('Cannot add command %s, class does not extend Piwik\Plugin\ConsoleCommand', $command)); } else { /** @var Command $commandInstance */ @@ -144,7 +144,7 @@ private function setServerArgsIfPhpCgi() } if (!defined('STDIN')) { - define('STDIN', fopen('php://stdin','r')); + define('STDIN', fopen('php://stdin', 'r')); } } } @@ -213,5 +213,4 @@ private function getDefaultPiwikCommands() return $commands; } - } diff --git a/core/Container/ContainerDoesNotExistException.php b/core/Container/ContainerDoesNotExistException.php index 9577d516245..4d1d33ed1de 100644 --- a/core/Container/ContainerDoesNotExistException.php +++ b/core/Container/ContainerDoesNotExistException.php @@ -15,4 +15,4 @@ */ class ContainerDoesNotExistException extends RuntimeException { -} \ No newline at end of file +} diff --git a/core/Container/ContainerFactory.php b/core/Container/ContainerFactory.php index bc15fe9e6fe..0c36e3ba82f 100644 --- a/core/Container/ContainerFactory.php +++ b/core/Container/ContainerFactory.php @@ -13,7 +13,6 @@ use Doctrine\Common\Cache\ArrayCache; use Piwik\Application\Kernel\GlobalSettingsProvider; use Piwik\Application\Kernel\PluginList; -use Piwik\Config\IniFileChainFactory; use Piwik\Development; use Piwik\Plugin\Manager; diff --git a/core/Cookie.php b/core/Cookie.php index 39c0de95e48..24f8a3f6c16 100644 --- a/core/Cookie.php +++ b/core/Cookie.php @@ -143,7 +143,9 @@ protected function setCookie($Name, $Value, $Expires, $Path = '', $Domain = '', // Remove port information. $Port = strpos($Domain, ':'); - if ($Port !== false) $Domain = substr($Domain, 0, $Port); + if ($Port !== false) { + $Domain = substr($Domain, 0, $Port); + } } $header = 'Set-Cookie: ' . rawurlencode($Name) . '=' . rawurlencode($Value) diff --git a/core/CronArchive.php b/core/CronArchive.php index 2904586ac4e..ee103e8aa37 100644 --- a/core/CronArchive.php +++ b/core/CronArchive.php @@ -493,7 +493,7 @@ private function archiveSingleSite($idSite, $requestsBefore) try { $shouldProceed = $this->processArchiveDays($idSite, $lastTimestampWebsiteProcessedDay, $shouldArchivePeriods, $timerWebsite); - } catch(UnexpectedWebsiteFoundException $e) { + } catch (UnexpectedWebsiteFoundException $e) { // this website was deleted in the meantime $shouldProceed = false; $this->logger->info("Skipped website id $idSite, got: UnexpectedWebsiteFoundException, " . $timerWebsite->__toString()); @@ -519,9 +519,9 @@ private function archiveSingleSite($idSite, $requestsBefore) Option::set($this->lastRunKey($idSite, "periods"), time()); } - if(!$success) { + if (!$success) { // cancel marking the site as reprocessed - if($websiteInvalidatedShouldReprocess) { + if ($websiteInvalidatedShouldReprocess) { $store = new SitesToReprocessDistributedList(); $store->add($idSite); } @@ -550,7 +550,6 @@ private function processArchiveForPeriods($idSite, $lastTimestampWebsiteProcesse $success = true; foreach (array('week', 'month', 'year') as $period) { - if (!$this->shouldProcessPeriod($period)) { // if any period was skipped, we do not mark the Periods archiving as successful $success = false; @@ -578,8 +577,9 @@ private function processArchiveForPeriods($idSite, $lastTimestampWebsiteProcesse private function getVisitsRequestUrl($idSite, $period, $date, $segment = false) { $request = "?module=API&method=API.get&idSite=$idSite&period=$period&date=" . $date . "&format=php"; - if($segment) { - $request .= '&segment=' . urlencode($segment);; + if ($segment) { + $request .= '&segment=' . urlencode($segment); + ; } return $request; } @@ -649,7 +649,7 @@ protected function processArchiveDays($idSite, $lastTimestampWebsiteProcessedDay Option::set($this->lastRunKey($idSite, "day"), 0); // cancel marking the site as reprocessed - if($websiteInvalidatedShouldReprocess) { + if ($websiteInvalidatedShouldReprocess) { $store = new SitesToReprocessDistributedList(); $store->add($idSite); } @@ -731,7 +731,7 @@ private function archiveReportsFor($idSite, $period, $date, $archiveSegments) } $segmentRequestsCount = 0; - if($archiveSegments) { + if ($archiveSegments) { $urlsWithSegment = $this->getUrlsWithSegment($idSite, $period, $date); $urls = array_merge($urls, $urlsWithSegment); $segmentRequestsCount = count($urlsWithSegment); @@ -753,13 +753,12 @@ private function archiveReportsFor($idSite, $period, $date, $archiveSegments) $success = $success && $this->checkResponse($content, $url); if ($noSegmentUrl === $url && $success) { - $stats = @unserialize($content); if (!is_array($stats)) { $this->logError("Error unserializing the following response from $url: " . $content); } - if($period == 'range') { + if ($period == 'range') { // range returns one dataset (the sum of data between the two dates), // whereas other periods return lastN which is N datasets in an array. Here we make our period=range dataset look like others: $stats = array($stats); @@ -826,14 +825,12 @@ private function request($url) } try { - $cliMulti = new CliMulti(); $cliMulti->setAcceptInvalidSSLCertificate($this->acceptInvalidSSLCertificate); $cliMulti->runAsSuperUser(); $responses = $cliMulti->request(array($url)); $response = !empty($responses) ? array_shift($responses) : null; - } catch (Exception $e) { return $this->logNetworkError($url, $e->getMessage()); } @@ -874,7 +871,7 @@ private function initStateFromParameters() // there was a previous successful run $this->shouldArchiveOnlySitesWithTrafficSince = time() - $this->lastSuccessRunTimestamp; } - } else { + } else { // force-all-periods is set here $this->archiveAndRespectTTL = false; @@ -996,7 +993,7 @@ private function addWebsiteIdsWithVisitsSinceLastRun() { $sitesIdWithVisits = APISitesManager::getInstance()->getSitesIdWithVisits(time() - $this->shouldArchiveOnlySitesWithTrafficSince); $websiteIds = !empty($sitesIdWithVisits) ? ", IDs: " . implode(", ", $sitesIdWithVisits) : ""; - $prettySeconds = $this->formatter->getPrettyTimeFromSeconds( $this->shouldArchiveOnlySitesWithTrafficSince, true); + $prettySeconds = $this->formatter->getPrettyTimeFromSeconds($this->shouldArchiveOnlySitesWithTrafficSince, true); $this->logger->info("- Will process " . count($sitesIdWithVisits) . " websites with new visits since " . $prettySeconds . " " @@ -1155,7 +1152,7 @@ private function getVisitsFromApiResponse($stats) } $visits = 0; - foreach($stats as $metrics) { + foreach ($stats as $metrics) { if (empty($metrics['nb_visits'])) { continue; } @@ -1344,10 +1341,10 @@ private function sanitiseTimestamp($timestamp) private function getCustomDateRangeToPreProcess($idSite) { static $cache = null; - if(is_null($cache)) { + if (is_null($cache)) { $cache = $this->loadCustomDateRangeToPreProcess(); } - if(empty($cache[$idSite])) { + if (empty($cache[$idSite])) { return array(); } $dates = array_unique($cache[$idSite]); @@ -1370,7 +1367,6 @@ private function loadCustomDateRangeToPreProcess() )); foreach ($allUsersPreferences as $userLogin => $userPreferences) { - if (!isset($userPreferences[APIUsersManager::PREFERENCE_DEFAULT_REPORT_DATE])) { continue; } @@ -1458,7 +1454,7 @@ private function createSitesToArchiveQueue($websitesIds) } return new SharedSiteIds($websitesIds); - } + } /** * @param $idSite @@ -1473,4 +1469,4 @@ private function logArchiveWebsite($idSite, $period) )); $this->logger->info('- pre-processing all visits'); } -} \ No newline at end of file +} diff --git a/core/CronArchive/FixedSiteIds.php b/core/CronArchive/FixedSiteIds.php index 8a48fb24ccd..685d7ebe10c 100644 --- a/core/CronArchive/FixedSiteIds.php +++ b/core/CronArchive/FixedSiteIds.php @@ -8,7 +8,6 @@ */ namespace Piwik\CronArchive; -use Piwik\CronArchive; class FixedSiteIds { @@ -63,6 +62,4 @@ public function getNextSiteId() return null; } - } - diff --git a/core/CronArchive/SegmentArchivingRequestUrlProvider.php b/core/CronArchive/SegmentArchivingRequestUrlProvider.php index e2c9c3a5705..f60b7e073a7 100644 --- a/core/CronArchive/SegmentArchivingRequestUrlProvider.php +++ b/core/CronArchive/SegmentArchivingRequestUrlProvider.php @@ -102,7 +102,7 @@ private function getOldestDateToProcessForNewSegment(Date $segmentCreatedTime) $this->logger->debug("process_new_segments_from set to segment_creation_time, oldest date to process is {time}", array('time' => $segmentCreatedTime)); return $segmentCreatedTime; - } else if (preg_match("/^last([0-9]+)$/", $this->processNewSegmentsFrom, $matches)) { + } elseif (preg_match("/^last([0-9]+)$/", $this->processNewSegmentsFrom, $matches)) { $lastN = $matches[1]; list($lastDate, $lastPeriod) = Range::getDateXPeriodsAgo($lastN, $segmentCreatedTime, 'day'); @@ -166,4 +166,4 @@ private function isSegmentForSite($segment, $idSite) return $segment['enable_only_idsite'] == 0 || $segment['enable_only_idsite'] == $idSite; } -} \ No newline at end of file +} diff --git a/core/CronArchive/SharedSiteIds.php b/core/CronArchive/SharedSiteIds.php index facc331a6dd..f77f3d3fdc3 100644 --- a/core/CronArchive/SharedSiteIds.php +++ b/core/CronArchive/SharedSiteIds.php @@ -181,6 +181,4 @@ public static function isSupported() { return Process::isSupported(); } - } - diff --git a/core/CronArchive/SitesToReprocessDistributedList.php b/core/CronArchive/SitesToReprocessDistributedList.php index 0257d987027..ad58cc3a144 100644 --- a/core/CronArchive/SitesToReprocessDistributedList.php +++ b/core/CronArchive/SitesToReprocessDistributedList.php @@ -37,4 +37,4 @@ public function setAll($items) parent::setAll($items); } -} \ No newline at end of file +} diff --git a/core/DataAccess/Actions.php b/core/DataAccess/Actions.php index 9efc4fc2a59..1a47a70549d 100644 --- a/core/DataAccess/Actions.php +++ b/core/DataAccess/Actions.php @@ -31,4 +31,4 @@ public function delete($idActions) $sql = "DELETE FROM $table WHERE idaction IN (" . implode(",", $idActions) . ")"; Db::query($sql); } -} \ No newline at end of file +} diff --git a/core/DataAccess/ArchiveSelector.php b/core/DataAccess/ArchiveSelector.php index a500ef66e60..7be972bdb84 100644 --- a/core/DataAccess/ArchiveSelector.php +++ b/core/DataAccess/ArchiveSelector.php @@ -80,7 +80,6 @@ public static function getArchiveIdAndVisits(ArchiveProcessor\Parameters $params list($visits, $visitsConverted) = self::getVisitsMetricsFromResults($idArchive, $idArchiveVisitsSummary, $results); if (false === $visits && false === $idArchive) { - return false; } @@ -236,7 +235,6 @@ public static function getArchiveData($archiveIds, $recordNames, $archiveDataTyp // create the SQL to select archive data $loadAllSubtables = $idSubtable == Archive::ID_SUBTABLE_LOAD_ALL_SUBTABLES; if ($loadAllSubtables) { - $name = reset($recordNames); // select blobs w/ name like "$name_[0-9]+" w/o using RLIKE @@ -252,7 +250,6 @@ public static function getArchiveData($archiveIds, $recordNames, $archiveDataTyp $whereNameIs = "(name = ? OR (name LIKE ? AND ( $checkForChunkBlob OR $checkForSubtableId ) ))"; $bind = array($name, $name . '%'); } else { - if ($idSubtable === null) { // select root table or specific record names $bind = array_values($recordNames); @@ -279,7 +276,6 @@ public static function getArchiveData($archiveIds, $recordNames, $archiveDataTyp // get data from every table we're querying $rows = array(); foreach ($archiveIds as $period => $ids) { - if (empty($ids)) { throw new Exception("Unexpected: id archive not found for period '$period' '"); } @@ -301,7 +297,6 @@ public static function getArchiveData($archiveIds, $recordNames, $archiveDataTyp if ($isNumeric) { $rows[] = $row; } else { - $row['value'] = self::uncompress($row['value']); if ($chunk->isRecordNameAChunk($row['name'])) { @@ -371,6 +366,4 @@ private static function getNameCondition(array $plugins, Segment $segment) // create the SQL to find archives that are DONE return "((name IN ($allDoneFlags)) AND (value IN (" . implode(',', $possibleValues) . ")))"; } - - } diff --git a/core/DataAccess/ArchiveTableCreator.php b/core/DataAccess/ArchiveTableCreator.php index 230c7da05a0..c6b958449b9 100644 --- a/core/DataAccess/ArchiveTableCreator.php +++ b/core/DataAccess/ArchiveTableCreator.php @@ -11,7 +11,6 @@ use Piwik\Common; use Piwik\Date; -use Piwik\Db; use Piwik\DbHelper; class ArchiveTableCreator diff --git a/core/DataAccess/ArchiveWriter.php b/core/DataAccess/ArchiveWriter.php index 56c0927496c..2ef614990f8 100644 --- a/core/DataAccess/ArchiveWriter.php +++ b/core/DataAccess/ArchiveWriter.php @@ -86,7 +86,6 @@ public function __construct(ArchiveProcessor\Parameters $params, $isArchiveTempo public function insertBlobRecord($name, $values) { if (is_array($values)) { - $clean = array(); if (isset($values[0])) { diff --git a/core/DataAccess/LogAggregator.php b/core/DataAccess/LogAggregator.php index 8b8d5175ff4..ec6748040d5 100644 --- a/core/DataAccess/LogAggregator.php +++ b/core/DataAccess/LogAggregator.php @@ -447,8 +447,8 @@ protected function getSelectAliasAs($metricId) protected function isMetricRequested($metricId, $metricsRequested) { // do not process INDEX_NB_UNIQ_FINGERPRINTS unless specifically asked for - if($metricsRequested === false) { - if($metricId == Metrics::INDEX_NB_UNIQ_FINGERPRINTS) { + if ($metricsRequested === false) { + if ($metricId == Metrics::INDEX_NB_UNIQ_FINGERPRINTS) { return false; } return true; diff --git a/core/DataAccess/LogQueryBuilder.php b/core/DataAccess/LogQueryBuilder.php index a6486520b37..3417c1d5455 100644 --- a/core/DataAccess/LogQueryBuilder.php +++ b/core/DataAccess/LogQueryBuilder.php @@ -9,7 +9,6 @@ namespace Piwik\DataAccess; - use Exception; use Piwik\Common; use Piwik\Segment\SegmentExpression; @@ -27,7 +26,7 @@ public function getSelectQueryString($select, $from, $where, $bind, $groupBy, $o $from = array($from); } - if(!$this->segmentExpression->isEmpty()) { + if (!$this->segmentExpression->isEmpty()) { $this->segmentExpression->parseSubExpressionsIntoSqlExpressions($from); $segmentSql = $this->segmentExpression->getSql(); $where = $this->getWhereMatchBoth($where, $segmentSql['where']); @@ -105,18 +104,18 @@ private function generateJoinsString($tables) // have actions, need conversions => join on idlink_va $join = "log_conversion.idlink_va = log_link_visit_action.idlink_va " . "AND log_conversion.idsite = log_link_visit_action.idsite"; - } else if ($actionsAvailable && $table == "log_visit") { + } elseif ($actionsAvailable && $table == "log_visit") { // have actions, need visits => join on idvisit $join = "log_visit.idvisit = log_link_visit_action.idvisit"; - } else if ($visitsAvailable && $table == "log_link_visit_action") { + } elseif ($visitsAvailable && $table == "log_link_visit_action") { // have visits, need actions => we have to use a more complex join // we don't hande this here, we just return joinWithSubSelect=true in this case $joinWithSubSelect = true; $join = "log_link_visit_action.idvisit = log_visit.idvisit"; - } else if ($conversionsAvailable && $table == "log_link_visit_action") { + } elseif ($conversionsAvailable && $table == "log_link_visit_action") { // have conversions, need actions => join on idlink_va $join = "log_conversion.idlink_va = log_link_visit_action.idlink_va"; - } else if (($visitsAvailable && $table == "log_conversion") + } elseif (($visitsAvailable && $table == "log_conversion") || ($conversionsAvailable && $table == "log_visit") ) { // have visits, need conversion (or vice versa) => join on idvisit @@ -154,7 +153,6 @@ private function generateJoinsString($tables) 'joinWithSubSelect' => $joinWithSubSelect ); return $return; - } @@ -188,11 +186,11 @@ private function buildWrappedSelectQuery($select, $from, $where, $groupBy, $orde $innerLimit = $limit; $innerGroupBy = "log_visit.idvisit"; $innerOrderBy = "NULL"; - if($innerLimit && $orderBy) { + if ($innerLimit && $orderBy) { // only When LIMITing we can apply to the inner query the same ORDER BY as the parent query $innerOrderBy = $orderBy; } - if($innerLimit) { + if ($innerLimit) { // When LIMITing, no need to GROUP BY (GROUPing by is done before the LIMIT which is super slow when large amount of rows is matched) $innerGroupBy = false; } @@ -296,5 +294,4 @@ protected function getWhereMatchBoth($where, $segmentWhere) AND ($segmentWhere)"; } - -} \ No newline at end of file +} diff --git a/core/DataAccess/Model.php b/core/DataAccess/Model.php index 8df49d16a31..2a5bfa5f863 100644 --- a/core/DataAccess/Model.php +++ b/core/DataAccess/Model.php @@ -223,7 +223,6 @@ public function createArchiveTable($tableName, $tableNamePrefix) $sequence->create(); } } catch (Exception $e) { - } } @@ -233,7 +232,7 @@ public function allocateNewArchiveId($numericTable) try { $idarchive = $sequence->getNextId(); - } catch(Exception $e) { + } catch (Exception $e) { // edge case: sequence was not found, create it now $sequence->create(); @@ -312,5 +311,4 @@ protected function releaseArchiveTableLock($dbLockName) { Db::releaseDbLock($dbLockName); } - } diff --git a/core/DataAccess/RawLogDao.php b/core/DataAccess/RawLogDao.php index 28f2a07978d..0105a1047f9 100644 --- a/core/DataAccess/RawLogDao.php +++ b/core/DataAccess/RawLogDao.php @@ -106,4 +106,4 @@ protected function update($sql, array $values, $idVisit) { return Db::query($sql, array_merge(array_values($values), array($idVisit))); } -} \ No newline at end of file +} diff --git a/core/DataAccess/TableMetadata.php b/core/DataAccess/TableMetadata.php index 92e1e8b34eb..a07d378058f 100644 --- a/core/DataAccess/TableMetadata.php +++ b/core/DataAccess/TableMetadata.php @@ -53,4 +53,4 @@ public function getIdActionColumnNames($table) return array_values($columns); } -} \ No newline at end of file +} diff --git a/core/DataArray.php b/core/DataArray.php index 2eab0bbab5d..386eae29a31 100644 --- a/core/DataArray.php +++ b/core/DataArray.php @@ -100,7 +100,7 @@ protected function doSumVisitsMetrics($newRowToAdd, &$oldRowToUpdate, $onlyMetri } // Edge case fail safe - if(!isset($oldRowToUpdate[Metrics::INDEX_NB_VISITS])) { + if (!isset($oldRowToUpdate[Metrics::INDEX_NB_VISITS])) { return; } @@ -121,7 +121,7 @@ protected function doSumVisitsMetrics($newRowToAdd, &$oldRowToUpdate, $onlyMetri Metrics::INDEX_BOUNCE_COUNT, Metrics::INDEX_NB_VISITS_CONVERTED ); - foreach($toZero as $metric) { + foreach ($toZero as $metric) { $oldRowToUpdate[$metric] = 0; } } diff --git a/core/DataFiles/SearchEngines.php b/core/DataFiles/SearchEngines.php index 084c00e5e19..c72a6503cd2 100644 --- a/core/DataFiles/SearchEngines.php +++ b/core/DataFiles/SearchEngines.php @@ -190,7 +190,7 @@ 'search.tb.ask.com' => array('Ask'), 'nortonsafe.search.ask.com' => array('Ask'), 'safesearch.avira.com' => array('Ask'), - 'avira.search.ask.com' => array('Ask'), + 'avira.search.ask.com' => array('Ask'), // Atlas 'searchatlas.centrum.cz' => array('Atlas', 'q', '?q={k}'), @@ -285,7 +285,7 @@ // DasOertliche 'www.dasoertliche.de' => array('DasOertliche', 'kw'), - 'www2.dasoertliche.de' => array('DasOertliche', array('ph', 'kw')), + 'www2.dasoertliche.de' => array('DasOertliche', array('ph', 'kw')), // DasTelefonbuch 'www1.dastelefonbuch.de' => array('DasTelefonbuch', 'kw'), @@ -456,7 +456,7 @@ 'suche.gmx.net' => array('Google', 'q', 'web?q={k}'), 'search.incredibar.com' => array('Google', 'q', 'search.php?q={k}'), 'www.delta-search.com' => array('Google', 'q'), - 'www1.delta-search.com' => array('Google', 'q'), + 'www1.delta-search.com' => array('Google', 'q'), 'search.1und1.de' => array('Google', 'q', 'web?q={k}'), 'search.zonealarm.com' => array('Google'), 'start.lenovo.com' => array('Google', 'q', 'search/index.php?q={k}'), @@ -621,7 +621,7 @@ 's8-eu.ixquick.com' => array('Ixquick'), 's1-eu.ixquick.de' => array('Ixquick'), 's2-eu4.ixquick.com' => array('Ixquick'), - 's5-eu4.ixquick.com' => array('Ixquick'), + 's5-eu4.ixquick.com' => array('Ixquick'), // Jyxo 'jyxo.1188.cz' => array('Jyxo', 'q', 's?q={k}'), @@ -683,7 +683,7 @@ // Metager 'meta.rrzn.uni-hannover.de' => array('Metager', 'eingabe', 'meta/cgi-bin/meta.ger1?eingabe={k}'), 'www.metager.de' => array('Metager'), - 'metager.de' => array('Metager'), + 'metager.de' => array('Metager'), // Metager2 'metager2.de' => array('Metager2', 'q', 'search/index.php?q={k}'), @@ -760,9 +760,9 @@ // PeoplePC 'search.peoplepc.com' => array('PeoplePC', 'q', 'search?q={k}'), - // PeopleCheck + // PeopleCheck 'extern.peoplecheck.de' => array('PeopleCheck', 'q', 'link.php?q={k}'), - + // Picsearch 'www.picsearch.com' => array('Picsearch', 'q', 'index.cgi?q={k}'), @@ -784,7 +784,7 @@ 'www.qualigo.de' => array('Qualigo'), 'www.qualigo.nl' => array('Qualigo'), - // Qwant + // Qwant 'www.qwant.com' => array('Qwant', 'q'), // Rakuten diff --git a/core/DataTable.php b/core/DataTable.php index 884100b53a6..f55bc42a1a4 100644 --- a/core/DataTable.php +++ b/core/DataTable.php @@ -392,7 +392,6 @@ public function sort($functionCallback, $columnSortedBy) if ($this->isSortRecursiveEnabled()) { foreach ($this->getRowsWithoutSummaryRow() as $row) { - $subTable = $row->getSubtable(); if ($subTable) { $subTable->enableRecursiveSort(); @@ -772,8 +771,9 @@ public function addRow(Row $row) if ($this->maximumAllowedRows > 0 && $this->getRowsCount() >= $this->maximumAllowedRows - 1 ) { - if ($this->summaryRow === null) // create the summary row if necessary - { + if ($this->summaryRow === null) { + // create the summary row if necessary + $columns = array('label' => self::LABEL_SUMMARY_ROW) + $row->getColumns(); $this->addSummaryRow(new Row(array(Row::COLUMNS => $columns))); } else { @@ -1657,15 +1657,17 @@ public function walkPath($path, $missingRowColumns = false, $maxSubtableRows = 0 // if there is no table to advance to, and we're not adding missing rows, return false if ($missingRowColumns === false) { return array(false, $i); - } else // if we're adding missing rows, add a new row - { + } else { + // if we're adding missing rows, add a new row + $row = new DataTableSummaryRow(); $row->setColumns(array('label' => $segment) + $missingRowColumns); $next = $table->addRow($row); - if ($next !== $row) // if the row wasn't added, the table is full - { + if ($next !== $row) { + // if the row wasn't added, the table is full + // Summary row, has no metadata $next->deleteMetadata(); return array($next, $i); @@ -1679,8 +1681,9 @@ public function walkPath($path, $missingRowColumns = false, $maxSubtableRows = 0 // missing rows, return false if ($missingRowColumns === false) { return array(false, $i); - } else if ($i != $pathLength - 1) // create subtable if missing, but only if not on the last segment - { + } elseif ($i != $pathLength - 1) { + // create subtable if missing, but only if not on the last segment + $table = new DataTable(); $table->setMaximumAllowedRows($maxSubtableRows); $table->metadata[self::COLUMN_AGGREGATION_OPS_METADATA_NAME] @@ -1829,7 +1832,6 @@ protected function aggregateRowFromSimpleTable($row) { if ($row === false) { return; - } $thisRow = $this->getFirstRow(); if ($thisRow === false) { @@ -1850,7 +1852,8 @@ public function clearQueuedFilters() /** * @return \ArrayIterator|Row[] */ - public function getIterator() { + public function getIterator() + { return new \ArrayIterator($this->getRows()); } diff --git a/core/DataTable/BaseFilter.php b/core/DataTable/BaseFilter.php index 52a4863d0cd..ce423112ff2 100644 --- a/core/DataTable/BaseFilter.php +++ b/core/DataTable/BaseFilter.php @@ -9,7 +9,6 @@ namespace Piwik\DataTable; use Piwik\DataTable; -use Piwik\DataTable\Row; /** * A filter is set of logic that manipulates a DataTable. Existing filters do things like, diff --git a/core/DataTable/Bridges.php b/core/DataTable/Bridges.php index 6b3e722fcee..ccc25736fc2 100644 --- a/core/DataTable/Bridges.php +++ b/core/DataTable/Bridges.php @@ -32,4 +32,3 @@ class Piwik_DataTable_SerializedRow } } - diff --git a/core/DataTable/Filter/AddColumnsProcessedMetrics.php b/core/DataTable/Filter/AddColumnsProcessedMetrics.php index a3a9bd9776e..de4b1320dc2 100644 --- a/core/DataTable/Filter/AddColumnsProcessedMetrics.php +++ b/core/DataTable/Filter/AddColumnsProcessedMetrics.php @@ -9,7 +9,6 @@ namespace Piwik\DataTable\Filter; use Piwik\DataTable\BaseFilter; -use Piwik\DataTable\Row; use Piwik\DataTable; use Piwik\Plugin\Metric; use Piwik\Plugins\CoreHome\Columns\Metrics\ActionsPerVisit; @@ -93,4 +92,4 @@ private function deleteRowsWithNoVisit(DataTable $table) } } } -} \ No newline at end of file +} diff --git a/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php b/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php index d63d9b9bc54..7bdb7c79851 100644 --- a/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php +++ b/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php @@ -10,7 +10,6 @@ use Piwik\Archive\DataTableFactory; use Piwik\DataTable; -use Piwik\DataTable\Row; use Piwik\Piwik; use Piwik\Plugin\Metric; use Piwik\Plugins\Goals\Columns\Metrics\GoalSpecific\AverageOrderRevenue; @@ -163,4 +162,4 @@ private function getGoalsInTable(DataTable $table) } return array_unique($result); } -} \ No newline at end of file +} diff --git a/core/DataTable/Filter/AddSegmentByLabel.php b/core/DataTable/Filter/AddSegmentByLabel.php index d13eef97c5b..1eacd4f72fa 100644 --- a/core/DataTable/Filter/AddSegmentByLabel.php +++ b/core/DataTable/Filter/AddSegmentByLabel.php @@ -64,19 +64,17 @@ public function filter($table) $segment = reset($this->segments); foreach ($table->getRowsWithoutSummaryRow() as $key => $row) { - $label = $row->getColumn('label'); if (!empty($label)) { $row->setMetadata('segment', $segment . '==' . urlencode($label)); } } - } else if (!empty($this->delimiter)) { + } elseif (!empty($this->delimiter)) { $numSegments = count($this->segments); $conditionAnd = ';'; foreach ($table->getRowsWithoutSummaryRow() as $key => $row) { - $label = $row->getColumn('label'); if (!empty($label)) { $parts = explode($this->delimiter, $label); diff --git a/core/DataTable/Filter/AddSegmentValue.php b/core/DataTable/Filter/AddSegmentValue.php index 857bf02ce33..886db60df83 100644 --- a/core/DataTable/Filter/AddSegmentValue.php +++ b/core/DataTable/Filter/AddSegmentValue.php @@ -29,5 +29,4 @@ public function __construct($table, $callback = null) { parent::__construct($table, 'label', 'segmentValue', $callback, null, false); } - } diff --git a/core/DataTable/Filter/BeautifyTimeRangeLabels.php b/core/DataTable/Filter/BeautifyTimeRangeLabels.php index aed7af7d8dc..7cc21699e4a 100644 --- a/core/DataTable/Filter/BeautifyTimeRangeLabels.php +++ b/core/DataTable/Filter/BeautifyTimeRangeLabels.php @@ -70,7 +70,7 @@ public function getSingleUnitLabel($oldLabel, $lowerBound) { if ($lowerBound < 60) { return sprintf($this->labelSecondsPlural, $lowerBound, $lowerBound); - } else if ($lowerBound == 60) { + } elseif ($lowerBound == 60) { return $this->labelSingular; } else { return sprintf($this->labelPlural, ceil($lowerBound / 60)); diff --git a/core/DataTable/Filter/CalculateEvolutionFilter.php b/core/DataTable/Filter/CalculateEvolutionFilter.php index a8bd04d08d6..5af658bad6d 100755 --- a/core/DataTable/Filter/CalculateEvolutionFilter.php +++ b/core/DataTable/Filter/CalculateEvolutionFilter.php @@ -102,7 +102,9 @@ protected function getDividend($row) protected function getDivisor($row) { $pastRow = $this->getPastRowFromCurrent($row); - if (!$pastRow) return 0; + if (!$pastRow) { + return 0; + } return $pastRow->getColumn($this->columnNameUsedAsDivisor); } diff --git a/core/DataTable/Filter/ColumnCallbackAddColumnQuotient.php b/core/DataTable/Filter/ColumnCallbackAddColumnQuotient.php index 81d8eadf047..57451675871 100644 --- a/core/DataTable/Filter/ColumnCallbackAddColumnQuotient.php +++ b/core/DataTable/Filter/ColumnCallbackAddColumnQuotient.php @@ -136,7 +136,7 @@ protected function getDivisor($row) { if (!is_null($this->totalValueUsedAsDivisor)) { return $this->totalValueUsedAsDivisor; - } else if ($this->getDivisorFromSummaryRow) { + } elseif ($this->getDivisorFromSummaryRow) { $summaryRow = $this->table->getRowFromId(DataTable::ID_SUMMARY_ROW); return $summaryRow->getColumn($this->columnNameUsedAsDivisor); } else { diff --git a/core/DataTable/Filter/ColumnCallbackAddMetadata.php b/core/DataTable/Filter/ColumnCallbackAddMetadata.php index a241cf4b5da..d302e641fac 100644 --- a/core/DataTable/Filter/ColumnCallbackAddMetadata.php +++ b/core/DataTable/Filter/ColumnCallbackAddMetadata.php @@ -70,7 +70,6 @@ public function filter($table) } foreach ($rows as $key => $row) { - $parameters = array(); foreach ($this->columnsToRead as $columnsToRead) { $parameters[] = $row->getColumn($columnsToRead); @@ -89,4 +88,4 @@ public function filter($table) } } } -} \ No newline at end of file +} diff --git a/core/DataTable/Filter/ColumnCallbackReplace.php b/core/DataTable/Filter/ColumnCallbackReplace.php index 84397d7a2cd..b850b7a6adc 100644 --- a/core/DataTable/Filter/ColumnCallbackReplace.php +++ b/core/DataTable/Filter/ColumnCallbackReplace.php @@ -74,7 +74,6 @@ public function __construct($table, $columnsToFilter, $functionToApply, $functio public function filter($table) { foreach ($table->getRows() as $row) { - $extraColumnParameters = array(); foreach ($this->extraColumnParameters as $columnName) { $extraColumnParameters[] = $row->getColumn($columnName); diff --git a/core/DataTable/Filter/ColumnDelete.php b/core/DataTable/Filter/ColumnDelete.php index 743f5afd863..a0fba5a9639 100644 --- a/core/DataTable/Filter/ColumnDelete.php +++ b/core/DataTable/Filter/ColumnDelete.php @@ -121,7 +121,6 @@ public function filter($table) if (!empty($this->columnsToKeep)) { foreach ($table as $index => $row) { foreach ($row as $name => $value) { - $keep = false; // @see self::APPEND_TO_COLUMN_NAME_TO_KEEP foreach ($this->columnsToKeep as $nameKeep => $true) { diff --git a/core/DataTable/Filter/ExcludeLowPopulation.php b/core/DataTable/Filter/ExcludeLowPopulation.php index cf54c5c7ebc..27d19fa86b9 100644 --- a/core/DataTable/Filter/ExcludeLowPopulation.php +++ b/core/DataTable/Filter/ExcludeLowPopulation.php @@ -10,7 +10,6 @@ use Piwik\DataTable; use Piwik\DataTable\BaseFilter; -use Piwik\Plugin\Metric; /** * Deletes all rows for which a specific column has a value that is lower than diff --git a/core/DataTable/Filter/GroupBy.php b/core/DataTable/Filter/GroupBy.php index 07597fe6b58..b00c66142be 100755 --- a/core/DataTable/Filter/GroupBy.php +++ b/core/DataTable/Filter/GroupBy.php @@ -77,12 +77,11 @@ public function filter($table) $nonGroupByRowIds = array(); foreach ($table->getRowsWithoutSummaryRow() as $rowId => $row) { - $groupByColumnValue = $row->getColumn($this->groupByColumn); $groupByValue = $groupByColumnValue; // reduce the group by column of this row - if($this->reduceFunction) { + if ($this->reduceFunction) { $parameters = array_merge(array($groupByColumnValue), $this->parameters); $groupByValue = call_user_func_array($this->reduceFunction, $parameters); } diff --git a/core/DataTable/Filter/PatternRecursive.php b/core/DataTable/Filter/PatternRecursive.php index f383a132609..62a8b26bd9a 100644 --- a/core/DataTable/Filter/PatternRecursive.php +++ b/core/DataTable/Filter/PatternRecursive.php @@ -8,10 +8,8 @@ */ namespace Piwik\DataTable\Filter; -use Exception; use Piwik\DataTable\BaseFilter; use Piwik\DataTable; -use Piwik\DataTable\Manager; /** * Deletes rows that do not contain a column that matches a regex pattern and do not contain a @@ -63,7 +61,7 @@ public function filter($table) $patternNotFoundInChildren = false; $subTable = $row->getSubtable(); - if(!$subTable) { + if (!$subTable) { $patternNotFoundInChildren = true; } else { // we delete the row if we couldn't find the pattern in any row in the diff --git a/core/DataTable/Filter/PivotByDimension.php b/core/DataTable/Filter/PivotByDimension.php index 3eeff39b44e..b7f5ca1cf22 100644 --- a/core/DataTable/Filter/PivotByDimension.php +++ b/core/DataTable/Filter/PivotByDimension.php @@ -547,4 +547,4 @@ private static function areDimensionsNotEqualAndNotNull($lhs, $rhs) { return !empty($lhs) && !empty($rhs) && $lhs->getId() != $rhs->getId(); } -} \ No newline at end of file +} diff --git a/core/DataTable/Filter/ReplaceSummaryRowLabel.php b/core/DataTable/Filter/ReplaceSummaryRowLabel.php index 168794d0973..3256fe9603b 100644 --- a/core/DataTable/Filter/ReplaceSummaryRowLabel.php +++ b/core/DataTable/Filter/ReplaceSummaryRowLabel.php @@ -10,7 +10,6 @@ use Piwik\DataTable\BaseFilter; use Piwik\DataTable; -use Piwik\DataTable\Manager; use Piwik\Piwik; /** diff --git a/core/DataTable/Filter/Sort.php b/core/DataTable/Filter/Sort.php index 7f590607cd0..8f2df8c9f66 100644 --- a/core/DataTable/Filter/Sort.php +++ b/core/DataTable/Filter/Sort.php @@ -99,7 +99,7 @@ public function numberSort($rowA, $rowB) * @param mixed $valB * @return int */ - function naturalSort($valA, $valB) + public function naturalSort($valA, $valB) { return !isset($valA) && !isset($valB) @@ -123,7 +123,7 @@ function naturalSort($valA, $valB) * @param mixed $valB * @return int */ - function sortString($valA, $valB) + public function sortString($valA, $valB) { return !isset($valA) && !isset($valB) @@ -279,7 +279,6 @@ private function sort(DataTable $table, $functionCallback) if ($table->isSortRecursiveEnabled()) { foreach ($table->getRowsWithoutSummaryRow() as $row) { - $subTable = $row->getSubtable(); if ($subTable) { $subTable->enableRecursiveSort(); @@ -287,7 +286,5 @@ private function sort(DataTable $table, $functionCallback) } } } - } - } diff --git a/core/DataTable/Manager.php b/core/DataTable/Manager.php index c823293c769..228f13da183 100644 --- a/core/DataTable/Manager.php +++ b/core/DataTable/Manager.php @@ -28,8 +28,8 @@ class Manager extends \ArrayObject private static $instance; - public static function getInstance() { - + public static function getInstance() + { if (!isset(self::$instance)) { self::$instance = new Manager(); } diff --git a/core/DataTable/Renderer.php b/core/DataTable/Renderer.php index f825739611c..e8796aea926 100644 --- a/core/DataTable/Renderer.php +++ b/core/DataTable/Renderer.php @@ -194,7 +194,6 @@ public static function formatValueXml($value) $htmlentities = array(" ", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ", "€"); $xmlentities = array("¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ", "€"); $value = str_replace($htmlentities, $xmlentities, $value); - } elseif ($value === false) { $value = 0; } diff --git a/core/DataTable/Renderer/Console.php b/core/DataTable/Renderer/Console.php index a4fcbff0c5a..bd16e93c4fa 100644 --- a/core/DataTable/Renderer/Console.php +++ b/core/DataTable/Renderer/Console.php @@ -8,7 +8,6 @@ */ namespace Piwik\DataTable\Renderer; -use Piwik\DataTable\Manager; use Piwik\DataTable; use Piwik\DataTable\Renderer; @@ -72,8 +71,9 @@ protected function renderDataTableMap(DataTable\Map $map, $prefix) */ protected function renderTable($table, $prefix = "") { - if (is_array($table)) // convert array to DataTable - { + if (is_array($table)) { + // convert array to DataTable + $table = DataTable::makeFromSimpleArray($table); } @@ -97,8 +97,11 @@ protected function renderTable($table, $prefix = "") $dataTableMapBreak = true; break; } - if (is_string($value)) $value = "'$value'"; - elseif (is_array($value)) $value = var_export($value, true); + if (is_string($value)) { + $value = "'$value'"; + } elseif (is_array($value)) { + $value = var_export($value, true); + } $columns[] = "'$column' => $value"; } @@ -109,8 +112,11 @@ protected function renderTable($table, $prefix = "") $metadata = array(); foreach ($row->getMetadata() as $name => $value) { - if (is_string($value)) $value = "'$value'"; - elseif (is_array($value)) $value = var_export($value, true); + if (is_string($value)) { + $value = "'$value'"; + } elseif (is_array($value)) { + $value = var_export($value, true); + } $metadata[] = "'$name' => $value"; } $metadata = implode(", ", $metadata); diff --git a/core/DataTable/Renderer/Csv.php b/core/DataTable/Renderer/Csv.php index 6f37a660bdc..4eee1949b7a 100644 --- a/core/DataTable/Renderer/Csv.php +++ b/core/DataTable/Renderer/Csv.php @@ -117,8 +117,9 @@ public function setSeparator($separator) */ protected function renderTable($table, &$allColumns = array()) { - if (is_array($table)) // convert array to DataTable - { + if (is_array($table)) { + // convert array to DataTable + $table = DataTable::makeFromSimpleArray($table); } @@ -264,11 +265,12 @@ protected function renderHeader() $period = Common::getRequestVar('period', false); $date = Common::getRequestVar('date', false); - if ($period || $date) // in test cases, there are no request params set - { + if ($period || $date) { + // in test cases, there are no request params set + if ($period == 'range') { $period = new Range($period, $date); - } else if (strpos($date, ',') !== false) { + } elseif (strpos($date, ',') !== false) { $period = new Range('range', $date); } else { $period = Period\Factory::build($period, Date::factory($date)); diff --git a/core/DataTable/Renderer/Html.php b/core/DataTable/Renderer/Html.php index e193ebfdc5f..f27dc517685 100644 --- a/core/DataTable/Renderer/Html.php +++ b/core/DataTable/Renderer/Html.php @@ -56,8 +56,9 @@ public function render() */ protected function renderTable($table) { - if (is_array($table)) // convert array to DataTable - { + if (is_array($table)) { + // convert array to DataTable + $table = DataTable::makeFromSimpleArray($table); } @@ -67,8 +68,9 @@ protected function renderTable($table) $this->buildTableStructure($subtable, '_' . $table->getKeyName(), $date); } } - } else // Simple - { + } else { + // Simple + if ($table->getRowsCount()) { $this->buildTableStructure($table); } @@ -113,7 +115,9 @@ protected function buildTableStructure($table, $columnToAdd = null, $valueToAdd $metadata = array(); foreach ($row->getMetadata() as $name => $value) { - if (is_string($value)) $value = "'$value'"; + if (is_string($value)) { + $value = "'$value'"; + } $metadata[] = "'$name' => $value"; } diff --git a/core/DataTable/Renderer/Json.php b/core/DataTable/Renderer/Json.php index b5d2ebf9793..36079aadf49 100644 --- a/core/DataTable/Renderer/Json.php +++ b/core/DataTable/Renderer/Json.php @@ -54,7 +54,6 @@ protected function renderTable($table) } } } - } else { $array = $this->convertDataTableToArray($table); } diff --git a/core/DataTable/Renderer/Php.php b/core/DataTable/Renderer/Php.php index eb6d32a3e3e..9a121bc6283 100644 --- a/core/DataTable/Renderer/Php.php +++ b/core/DataTable/Renderer/Php.php @@ -9,7 +9,6 @@ namespace Piwik\DataTable\Renderer; use Exception; -use Piwik\DataTable\Manager; use Piwik\DataTable\Renderer; use Piwik\DataTable\Simple; use Piwik\DataTable; @@ -111,7 +110,7 @@ public function flatRender($dataTable = null) if (self::shouldWrapArrayBeforeRendering($flatArray)) { $flatArray = array($flatArray); } - } else if ($dataTable instanceof DataTable\Map) { + } elseif ($dataTable instanceof DataTable\Map) { $flatArray = array(); foreach ($dataTable->getDataTables() as $keyName => $table) { $serializeSave = $this->serialize; @@ -119,7 +118,7 @@ public function flatRender($dataTable = null) $flatArray[$keyName] = $this->flatRender($table); $this->serialize = $serializeSave; } - } else if ($dataTable instanceof Simple) { + } elseif ($dataTable instanceof Simple) { $flatArray = $this->renderSimpleTable($dataTable); // if we return only one numeric value then we print out the result in a simple tag diff --git a/core/DataTable/Renderer/Rss.php b/core/DataTable/Renderer/Rss.php index 8adda661be9..fd18b443714 100644 --- a/core/DataTable/Renderer/Rss.php +++ b/core/DataTable/Renderer/Rss.php @@ -29,7 +29,7 @@ class Rss extends Renderer * * @return string */ - function render() + public function render() { return $this->renderTable($this->table); } diff --git a/core/DataTable/Renderer/Tsv.php b/core/DataTable/Renderer/Tsv.php index cfffbf24a0b..af45a62d991 100644 --- a/core/DataTable/Renderer/Tsv.php +++ b/core/DataTable/Renderer/Tsv.php @@ -20,7 +20,7 @@ class Tsv extends Csv /** * Constructor */ - function __construct() + public function __construct() { parent::__construct(); $this->setSeparator("\t"); @@ -31,7 +31,7 @@ function __construct() * * @return string */ - function render() + public function render() { return parent::render(); } diff --git a/core/DataTable/Renderer/Xml.php b/core/DataTable/Renderer/Xml.php index 7cd10d9367d..b01f5596a25 100644 --- a/core/DataTable/Renderer/Xml.php +++ b/core/DataTable/Renderer/Xml.php @@ -160,7 +160,7 @@ private function renderArray($array, $prefixLines) $prefix = ""; $suffix = ""; $emptyNode = ""; - } else if (!self::isValidXmlTagName($key)) { + } elseif (!self::isValidXmlTagName($key)) { $prefix = ""; $suffix = ""; $emptyNode = ""; @@ -180,7 +180,7 @@ private function renderArray($array, $prefixLines) $result .= $prefixLines . $prefix . "\n"; $result .= $this->renderArray($value, $prefixLines . "\t"); $result .= $prefixLines . $suffix . "\n"; - } else if ($value instanceof DataTable + } elseif ($value instanceof DataTable || $value instanceof Map ) { if ($value->getRowsCount() == 0) { @@ -189,7 +189,7 @@ private function renderArray($array, $prefixLines) $result .= $prefixLines . $prefix . "\n"; if ($value instanceof Map) { $result .= $this->renderDataTableMap($value, $this->getArrayFromDataTable($value), $prefixLines); - } else if ($value instanceof Simple) { + } elseif ($value instanceof Simple) { $result .= $this->renderDataTableSimple($this->getArrayFromDataTable($value), $prefixLines); } else { $result .= $this->renderDataTable($this->getArrayFromDataTable($value), $prefixLines); @@ -461,4 +461,4 @@ private function getTagStartAndEndFor($keyName, $columnsHaveInvalidChars) return array($tagStart, $tagEnd); } -} \ No newline at end of file +} diff --git a/core/DataTable/Row.php b/core/DataTable/Row.php index 4b5547cf8b4..973974033c9 100644 --- a/core/DataTable/Row.php +++ b/core/DataTable/Row.php @@ -118,15 +118,21 @@ public function __toString() { $columns = array(); foreach ($this->getColumns() as $column => $value) { - if (is_string($value)) $value = "'$value'"; - elseif (is_array($value)) $value = var_export($value, true); + if (is_string($value)) { + $value = "'$value'"; + } elseif (is_array($value)) { + $value = var_export($value, true); + } $columns[] = "'$column' => $value"; } $columns = implode(", ", $columns); $metadata = array(); foreach ($this->getMetadata() as $name => $value) { - if (is_string($value)) $value = "'$value'"; - elseif (is_array($value)) $value = var_export($value, true); + if (is_string($value)) { + $value = "'$value'"; + } elseif (is_array($value)) { + $value = var_export($value, true); + } $metadata[] = "'$name' => $value"; } $metadata = implode(", ", $metadata); @@ -247,7 +253,7 @@ public function getSubtable() if ($this->isSubtableLoaded) { try { return Manager::getInstance()->getTable($this->subtableId); - } catch(TableNotFoundException $e) { + } catch (TableNotFoundException $e) { // edge case } } @@ -491,7 +497,7 @@ private function getColumnValuesMerged($operation, $thisColumnValue, $columnToSu case 'min': if (!$thisColumnValue) { $newValue = $columnToSumValue; - } else if (!$columnToSumValue) { + } elseif (!$columnToSumValue) { $newValue = $thisColumnValue; } else { $newValue = min($thisColumnValue, $columnToSumValue); @@ -598,11 +604,13 @@ public static function compareElements($elem1, $elem2) } return 1; } - if (is_array($elem2)) + if (is_array($elem2)) { return -1; + } - if ((string)$elem1 === (string)$elem2) + if ((string)$elem1 === (string)$elem2) { return 0; + } return ((string)$elem1 > (string)$elem2) ? 1 : -1; } @@ -679,7 +687,8 @@ public function offsetUnset($offset) $this->deleteColumn($offset); } - public function getIterator() { + public function getIterator() + { return new \ArrayIterator($this->columns); } @@ -706,5 +715,4 @@ protected function warnWhenSummingTwoStrings($thisColumnValue, $columnToSumValue ); } } - -} \ No newline at end of file +} diff --git a/core/DataTable/TableNotFoundException.php b/core/DataTable/TableNotFoundException.php index a8e181deaf2..4286405b5b3 100644 --- a/core/DataTable/TableNotFoundException.php +++ b/core/DataTable/TableNotFoundException.php @@ -10,5 +10,4 @@ class TableNotFoundException extends \Exception { - } diff --git a/core/Date.php b/core/Date.php index a046f4e27ac..d229cfdb46c 100644 --- a/core/Date.php +++ b/core/Date.php @@ -420,7 +420,6 @@ public function compareYear(Date $date) return 0; } if ($currentYear < $toCompareYear) { - return -1; } return 1; diff --git a/core/Db.php b/core/Db.php index 4d579605b27..bf24a37a41a 100644 --- a/core/Db.php +++ b/core/Db.php @@ -11,7 +11,6 @@ use Exception; use Piwik\DataAccess\TableMetadata; use Piwik\Db\Adapter; -use Piwik\Tracker; /** * Contains SQL related helper functions for Piwik's MySQL database. diff --git a/core/Db/Adapter.php b/core/Db/Adapter.php index b75690bc08d..4e245c84d31 100644 --- a/core/Db/Adapter.php +++ b/core/Db/Adapter.php @@ -62,7 +62,7 @@ public static function factory($adapterName, & $dbInfos, $connect = true) private static function getAdapterClassName($adapterName) { $className = 'Piwik\Db\Adapter\\' . str_replace(' ', '\\', ucwords(str_replace(array('_', '\\'), ' ', strtolower($adapterName)))); - if(!class_exists($className)) { + if (!class_exists($className)) { throw new \Exception("Adapter $adapterName is not valid."); } return $className; diff --git a/core/Db/BatchInsert.php b/core/Db/BatchInsert.php index 2fbd6674ad0..16041241820 100644 --- a/core/Db/BatchInsert.php +++ b/core/Db/BatchInsert.php @@ -9,7 +9,6 @@ namespace Piwik\Db; use Exception; -use Piwik\AssetManager; use Piwik\Common; use Piwik\Config; use Piwik\Container\StaticContainer; @@ -92,7 +91,6 @@ public static function tableInsertBatch($tableName, $fields, $values, $throwExce return true; } } catch (Exception $e) { - if ($throwException) { throw $e; } @@ -157,17 +155,17 @@ public static function createTableFromCSVFile($tableName, $fields, $filePath, $f "; /* - * First attempt: assume web server and MySQL server are on the same machine; - * this requires that the db user have the FILE privilege; however, since this is - * a global privilege, it may not be granted due to security concerns - */ + * First attempt: assume web server and MySQL server are on the same machine; + * this requires that the db user have the FILE privilege; however, since this is + * a global privilege, it may not be granted due to security concerns + */ $keywords = array(''); /* - * Second attempt: using the LOCAL keyword means the client reads the file and sends it to the server; - * the LOCAL keyword may trigger a known PHP PDO\MYSQL bug when MySQL not built with --enable-local-infile - * @see http://bugs.php.net/bug.php?id=54158 - */ + * Second attempt: using the LOCAL keyword means the client reads the file and sends it to the server; + * the LOCAL keyword may trigger a known PHP PDO\MYSQL bug when MySQL not built with --enable-local-infile + * @see http://bugs.php.net/bug.php?id=54158 + */ $openBaseDir = ini_get('open_basedir'); $safeMode = ini_get('safe_mode'); diff --git a/core/Db/Schema/Mysql.php b/core/Db/Schema/Mysql.php index 8f0eea8a26d..1e674f2decc 100644 --- a/core/Db/Schema/Mysql.php +++ b/core/Db/Schema/Mysql.php @@ -346,7 +346,6 @@ public function getTablesInstalled($forceReload = true) if (is_null($this->tablesInstalled) || $forceReload === true ) { - $db = $this->getDb(); $prefixTables = $this->getTablePrefixEscaped(); @@ -483,7 +482,8 @@ private function getTableEngine() return $this->getDbSettings()->getEngine(); } - private function getDb(){ + private function getDb() + { return Db::get(); } diff --git a/core/Db/Settings.php b/core/Db/Settings.php index afb06abc2f0..e324e8feaa5 100644 --- a/core/Db/Settings.php +++ b/core/Db/Settings.php @@ -7,6 +7,7 @@ * */ namespace Piwik\Db; + use Piwik\Db; /** diff --git a/core/DbHelper.php b/core/DbHelper.php index fdc1597cf69..25b1f56455d 100644 --- a/core/DbHelper.php +++ b/core/DbHelper.php @@ -9,7 +9,6 @@ namespace Piwik; use Exception; -use Piwik\Db\Adapter; use Piwik\Db\Schema; use Piwik\DataAccess\ArchiveTableCreator; @@ -187,4 +186,4 @@ public static function deleteArchiveTables() ArchiveTableCreator::refreshTableList($forceReload = true); } -} \ No newline at end of file +} diff --git a/core/Development.php b/core/Development.php index a2dd44c673d..3b44eba71de 100644 --- a/core/Development.php +++ b/core/Development.php @@ -168,7 +168,7 @@ public static function getMethodSourceCode($className, $methodName) $fileIterator = new \LimitIterator($file, $offset, $count); $methodCode = "\n " . $method->getDocComment() . "\n"; - foreach($fileIterator as $line) { + foreach ($fileIterator as $line) { $methodCode .= $line; } $methodCode .= "\n"; @@ -185,7 +185,7 @@ public static function getUseStatements($className) $fileIterator = new \LimitIterator($file, 0, $class->getStartLine()); $uses = array(); - foreach($fileIterator as $line) { + foreach ($fileIterator as $line) { if (preg_match('/(\s*)use (.+)/', $line, $match)) { $uses[] = trim($match[2]); } diff --git a/core/DeviceDetectorCache.php b/core/DeviceDetectorCache.php index 7cf2a152261..543769fc542 100644 --- a/core/DeviceDetectorCache.php +++ b/core/DeviceDetectorCache.php @@ -9,7 +9,6 @@ namespace Piwik; use Piwik\Cache as PiwikCache; -use Exception; /** * Caching class used for DeviceDetector caching @@ -93,5 +92,4 @@ public function flushAll() { return $this->cache->flushAll(); } - } diff --git a/core/DeviceDetectorFactory.php b/core/DeviceDetectorFactory.php index c7962a96f05..896132e7928 100644 --- a/core/DeviceDetectorFactory.php +++ b/core/DeviceDetectorFactory.php @@ -22,7 +22,6 @@ class DeviceDetectorFactory public static function getInstance($userAgent) { if (array_key_exists($userAgent, self::$deviceDetectorInstances)) { - return self::$deviceDetectorInstances[$userAgent]; } @@ -35,5 +34,4 @@ public static function getInstance($userAgent) return $deviceDetector; } - } diff --git a/core/EventDispatcher.php b/core/EventDispatcher.php index d9c6b0374c9..5795200c2fc 100644 --- a/core/EventDispatcher.php +++ b/core/EventDispatcher.php @@ -10,7 +10,6 @@ namespace Piwik; use Piwik\Container\StaticContainer; -use Piwik\Plugin; /** * This class allows code to post events from anywhere in Piwik and for @@ -190,10 +189,11 @@ private function getCallbackFunctionAndGroupNumber($hookInfo) $pluginFunction = $hookInfo['function']; if (!empty($hookInfo['before'])) { $callbackGroup = self::EVENT_CALLBACK_GROUP_FIRST; - } else if (!empty($hookInfo['after'])) { + } elseif (!empty($hookInfo['after'])) { $callbackGroup = self::EVENT_CALLBACK_GROUP_THIRD; } else { - $callbackGroup = self::EVENT_CALLBACK_GROUP_SECOND; } + $callbackGroup = self::EVENT_CALLBACK_GROUP_SECOND; + } } else { $pluginFunction = $hookInfo; $callbackGroup = self::EVENT_CALLBACK_GROUP_SECOND; @@ -201,4 +201,4 @@ private function getCallbackFunctionAndGroupNumber($hookInfo) return array($pluginFunction, $callbackGroup); } -} \ No newline at end of file +} diff --git a/core/Exception/AuthenticationFailedException.php b/core/Exception/AuthenticationFailedException.php index ca3efc25c17..4091979f909 100644 --- a/core/Exception/AuthenticationFailedException.php +++ b/core/Exception/AuthenticationFailedException.php @@ -10,4 +10,4 @@ class AuthenticationFailedException extends Exception { -} \ No newline at end of file +} diff --git a/core/Exception/DatabaseSchemaIsNewerThanCodebaseException.php b/core/Exception/DatabaseSchemaIsNewerThanCodebaseException.php index accc4ce5d50..7c78b26ce0c 100644 --- a/core/Exception/DatabaseSchemaIsNewerThanCodebaseException.php +++ b/core/Exception/DatabaseSchemaIsNewerThanCodebaseException.php @@ -10,5 +10,4 @@ class DatabaseSchemaIsNewerThanCodebaseException extends Exception { - -} \ No newline at end of file +} diff --git a/core/Exception/Exception.php b/core/Exception/Exception.php index 106034bf5a9..66d95eb4177 100644 --- a/core/Exception/Exception.php +++ b/core/Exception/Exception.php @@ -27,4 +27,4 @@ public function isHtmlMessage() { return $this->isHtmlMessage; } -} \ No newline at end of file +} diff --git a/core/Exception/InvalidRequestParameterException.php b/core/Exception/InvalidRequestParameterException.php index 13ead2e7164..4ea468c3f02 100644 --- a/core/Exception/InvalidRequestParameterException.php +++ b/core/Exception/InvalidRequestParameterException.php @@ -10,4 +10,4 @@ class InvalidRequestParameterException extends Exception { -} \ No newline at end of file +} diff --git a/core/Exception/MissingFilePermissionException.php b/core/Exception/MissingFilePermissionException.php index 268725c70bc..e54cce3e57b 100644 --- a/core/Exception/MissingFilePermissionException.php +++ b/core/Exception/MissingFilePermissionException.php @@ -10,4 +10,4 @@ class MissingFilePermissionException extends Exception { -} \ No newline at end of file +} diff --git a/core/Exception/NoPrivilegesException.php b/core/Exception/NoPrivilegesException.php index 3ee8c9ce2be..d7ccfcfc1ab 100644 --- a/core/Exception/NoPrivilegesException.php +++ b/core/Exception/NoPrivilegesException.php @@ -10,4 +10,4 @@ class NoPrivilegesException extends Exception { -} \ No newline at end of file +} diff --git a/core/Exception/NoWebsiteFoundException.php b/core/Exception/NoWebsiteFoundException.php index eb97cad37a9..748c7a4e9dd 100644 --- a/core/Exception/NoWebsiteFoundException.php +++ b/core/Exception/NoWebsiteFoundException.php @@ -10,4 +10,4 @@ class NoWebsiteFoundException extends Exception { -} \ No newline at end of file +} diff --git a/core/Exception/UnexpectedWebsiteFoundException.php b/core/Exception/UnexpectedWebsiteFoundException.php index 68178d85994..d9804bae74e 100644 --- a/core/Exception/UnexpectedWebsiteFoundException.php +++ b/core/Exception/UnexpectedWebsiteFoundException.php @@ -10,4 +10,4 @@ class UnexpectedWebsiteFoundException extends Exception { -} \ No newline at end of file +} diff --git a/core/Filechecks.php b/core/Filechecks.php index d673ccc2502..94340afdedc 100644 --- a/core/Filechecks.php +++ b/core/Filechecks.php @@ -40,7 +40,6 @@ public static function checkDirectoriesWritable($directoriesToCheck) { $resultCheck = array(); foreach ($directoriesToCheck as $directoryToCheck) { - if (!preg_match('/^' . preg_quote(PIWIK_USER_PATH, '/') . '/', $directoryToCheck)) { $directoryToCheck = PIWIK_USER_PATH . $directoryToCheck; } @@ -139,7 +138,7 @@ public static function getFileIntegrityInformation() if (!file_exists($file) || !is_readable($file)) { $messages[] = Piwik::translate('General_ExceptionMissingFile', $file); - } else if (filesize($file) != $props[0]) { + } elseif (filesize($file) != $props[0]) { if (!$hasMd5 || in_array(substr($path, -4), array('.gif', '.ico', '.jpg', '.png', '.swf'))) { // files that contain binary data (e.g., images) must match the file size $messages[] = Piwik::translate('General_ExceptionFilesizeMismatch', array($file, $props[0], filesize($file))); @@ -153,7 +152,7 @@ public static function getFileIntegrityInformation() $messages[] = Piwik::translate('General_ExceptionFilesizeMismatch', array($file, $props[0], filesize($file))); } } - } else if ($hasMd5file && (@md5_file($file) !== $props[1])) { + } elseif ($hasMd5file && (@md5_file($file) !== $props[1])) { $messages[] = Piwik::translate('General_ExceptionFileIntegrity', $file); } } diff --git a/core/Filesystem.php b/core/Filesystem.php index 850b44da638..d50c2d8e28a 100644 --- a/core/Filesystem.php +++ b/core/Filesystem.php @@ -118,8 +118,9 @@ public static function checkIfFileSystemIsNFS() // and the return code 1. if NFS, it will return 0 and at least 2 lines of text. $command = "df -T -t nfs \"$sessionsPath\" 2>&1"; - if (function_exists('exec')) // use exec - { + if (function_exists('exec')) { + // use exec + $output = $returnCode = null; @exec($command, $output, $returnCode); @@ -129,13 +130,15 @@ public static function checkIfFileSystemIsNFS() ) { return true; } - } else if (function_exists('shell_exec')) // use shell_exec - { + } elseif (function_exists('shell_exec')) { + // use shell_exec + $output = @shell_exec($command); if ($output) { $output = explode("\n", $output); - if (count($output) > 1) // check if filesystem is NFS - { + if (count($output) > 1) { + // check if filesystem is NFS + return true; } } @@ -318,7 +321,6 @@ private static function hasPHPExtension($file) if (!empty($path_parts['extension']) && in_array($path_parts['extension'], $phpExtensions)) { - return true; } @@ -464,7 +466,6 @@ public static function clearPhpCaches() } if (function_exists('xcache_clear_cache') && defined('XC_TYPE_VAR')) { - if (ini_get('xcache.admin.enable_auth')) { // XCache will not be cleared because "xcache.admin.enable_auth" is enabled in php.ini. } else { @@ -476,7 +477,6 @@ public static function clearPhpCaches() private static function havePhpFilesSameContent($file1, $file2) { if (self::hasPHPExtension($file1)) { - $sourceMd5 = md5_file($file1); $destMd5 = md5_file($file2); @@ -503,5 +503,4 @@ private static function tryToCopyFileAndVerifyItWasCopied($source, $dest) return true; } - } diff --git a/core/FrontController.php b/core/FrontController.php index 31a447da362..4b47d9024ba 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -11,15 +11,12 @@ use Exception; use Piwik\API\Request; -use Piwik\API\ResponseBuilder; use Piwik\Container\StaticContainer; use Piwik\Exception\AuthenticationFailedException; use Piwik\Exception\DatabaseSchemaIsNewerThanCodebaseException; use Piwik\Http\ControllerResolver; use Piwik\Http\Router; -use Piwik\Plugin\Report; use Piwik\Plugins\CoreAdminHome\CustomLogo; -use Piwik\Session; /** * This singleton dispatches requests to the appropriate plugin Controller. @@ -170,7 +167,7 @@ public static function shouldRethrowException() public static function setUpSafeMode() { - register_shutdown_function(array('\\Piwik\\FrontController','triggerSafeModeWhenError')); + register_shutdown_function(array('\\Piwik\\FrontController', 'triggerSafeModeWhenError')); } public static function triggerSafeModeWhenError() diff --git a/core/Http.php b/core/Http.php index 668a9dbe107..91956c9f29c 100644 --- a/core/Http.php +++ b/core/Http.php @@ -144,8 +144,7 @@ public static function sendHttpRequestBy( $httpMethod = 'GET', $httpUsername = null, $httpPassword = null - ) - { + ) { if ($followDepth > 5) { throw new Exception('Too many redirects (' . $followDepth . ')'); } @@ -388,7 +387,7 @@ public static function sendHttpRequestBy( // determine success or failure @fclose(@$fsock); - } else if ($method == 'fopen') { + } elseif ($method == 'fopen') { $response = false; // we make sure the request takes less than a few seconds to fail @@ -456,7 +455,7 @@ public static function sendHttpRequestBy( if (!empty($default_socket_timeout)) { @ini_set('default_socket_timeout', $default_socket_timeout); } - } else if ($method == 'curl') { + } elseif ($method == 'curl') { if (!self::isCurlEnabled()) { // can be triggered in tests throw new Exception("CURL is not enabled in php.ini, but is being used."); @@ -501,7 +500,7 @@ public static function sendHttpRequestBy( @curl_setopt($ch, CURLOPT_NOBODY, true); } - if(!empty($httpUsername) && !empty($httpPassword)) { + if (!empty($httpUsername) && !empty($httpPassword)) { $curl_options += array( CURLOPT_USERPWD => $httpUsername . ':' . $httpPassword, ); @@ -537,7 +536,7 @@ public static function sendHttpRequestBy( if ($response === true) { $response = ''; - } else if ($response === false) { + } elseif ($response === false) { $errstr = curl_error($ch); if ($errstr != '') { throw new Exception('curl_exec: ' . $errstr @@ -824,4 +823,4 @@ public static function getModifiedSinceHeader() } return $modifiedSince; } -} \ No newline at end of file +} diff --git a/core/Http/ControllerResolver.php b/core/Http/ControllerResolver.php index 8d58f0ed733..569fbee49ef 100644 --- a/core/Http/ControllerResolver.php +++ b/core/Http/ControllerResolver.php @@ -13,7 +13,6 @@ use Piwik\Plugin\Controller; use Piwik\Plugin\Report; use Piwik\Plugin\Widgets; -use Piwik\Session; /** * Resolves the controller that will handle the request. diff --git a/core/Mail.php b/core/Mail.php index 9825eb3378c..2c5405cf461 100644 --- a/core/Mail.php +++ b/core/Mail.php @@ -116,7 +116,7 @@ private function initSmtpTransport() @ini_set("smtp_port", $mailConfig['port']); } - public function send($transport = NULL) + public function send($transport = null) { if (defined('PIWIK_TEST_MODE')) { // hack Piwik::postTestEvent("Test.Mail.send", array($this)); diff --git a/core/Menu/Group.php b/core/Menu/Group.php index 90e063e2648..a13da035b3f 100644 --- a/core/Menu/Group.php +++ b/core/Menu/Group.php @@ -21,7 +21,7 @@ public function add($subTitleMenu, $url, $tooltip = false) 'name' => $subTitleMenu, 'url' => $url, 'tooltip' => $tooltip - );; + ); } public function getItems() diff --git a/core/Menu/MenuAbstract.php b/core/Menu/MenuAbstract.php index 539cbac7e70..4e9e090dad5 100644 --- a/core/Menu/MenuAbstract.php +++ b/core/Menu/MenuAbstract.php @@ -240,8 +240,7 @@ private function applyEdits() private function applyRemoves() { - foreach($this->menuEntriesToRemove as $menuToDelete) { - + foreach ($this->menuEntriesToRemove as $menuToDelete) { if (empty($menuToDelete[1])) { // Delete Main Menu if (isset($this->menu[$menuToDelete[0]])) { @@ -275,7 +274,7 @@ private function applyRenames() $this->menu[$mainMenuRenamed][$subMenuRenamed] = $save; } } // Changing a first-level element - else if (isset($this->menu[$mainMenuOriginal])) { + elseif (isset($this->menu[$mainMenuOriginal])) { $save = $this->menu[$mainMenuOriginal]; $save['_name'] = $mainMenuRenamed; unset($this->menu[$mainMenuOriginal]); @@ -299,7 +298,7 @@ private function applyOrdering() foreach ($this->menu as $key => &$element) { if (is_null($element)) { unset($this->menu[$key]); - } else if ($element['_hasSubmenu']) { + } elseif ($element['_hasSubmenu']) { uasort($element, array($this, 'menuCompare')); } } diff --git a/core/Menu/MenuReporting.php b/core/Menu/MenuReporting.php index ac35151bcb7..598a7576334 100644 --- a/core/Menu/MenuReporting.php +++ b/core/Menu/MenuReporting.php @@ -7,6 +7,7 @@ * */ namespace Piwik\Menu; + use Piwik\Piwik; use Piwik\Plugin\Report; @@ -135,7 +136,6 @@ public function getMenu() foreach ($this->getAllMenus() as $menu) { $menu->configureReportingMenu($this); } - } return parent::getMenu(); diff --git a/core/Menu/MenuTop.php b/core/Menu/MenuTop.php index 87ccb3c5f8d..687b1b46cf2 100644 --- a/core/Menu/MenuTop.php +++ b/core/Menu/MenuTop.php @@ -7,6 +7,7 @@ * */ namespace Piwik\Menu; + use Piwik\Piwik; /** diff --git a/core/Metrics.php b/core/Metrics.php index 4b48bf13f2c..ffaa26a4a3b 100644 --- a/core/Metrics.php +++ b/core/Metrics.php @@ -304,7 +304,7 @@ public static function getDefaultMetricTranslations() */ Piwik::postEvent('Metrics.getDefaultMetricTranslations', array(&$translations)); - $translations = array_map(array('\\Piwik\\Piwik','translate'), $translations); + $translations = array_map(array('\\Piwik\\Piwik', 'translate'), $translations); $cache->save($cacheId, $translations); @@ -326,7 +326,7 @@ public static function getDefaultMetrics() 'nb_actions' => 'General_ColumnNbActions', 'nb_users' => 'General_ColumnNbUsers', ); - $translations = array_map(array('\\Piwik\\Piwik','translate'), $translations); + $translations = array_map(array('\\Piwik\\Piwik', 'translate'), $translations); $cache->save($cacheId, $translations); @@ -349,7 +349,7 @@ public static function getDefaultProcessedMetrics() 'bounce_rate' => 'General_ColumnBounceRate', 'conversion_rate' => 'General_ColumnConversionRate', ); - $translations = array_map(array('\\Piwik\\Piwik','translate'), $translations); + $translations = array_map(array('\\Piwik\\Piwik', 'translate'), $translations); $cache->save($cacheId, $translations); @@ -361,7 +361,6 @@ public static function getReadableColumnName($columnIdRaw) $mappingIdToName = self::$mappingFromIdToName; if (array_key_exists($columnIdRaw, $mappingIdToName)) { - return $mappingIdToName[$columnIdRaw]; } @@ -417,7 +416,7 @@ public static function getDefaultMetricsDocumentation() */ Piwik::postEvent('Metrics.getDefaultMetricDocumentationTranslations', array(&$translations)); - $translations = array_map(array('\\Piwik\\Piwik','translate'), $translations); + $translations = array_map(array('\\Piwik\\Piwik', 'translate'), $translations); $cache->save($cacheId, $translations); diff --git a/core/Metrics/Formatter.php b/core/Metrics/Formatter.php index bce37e3be44..0e54dd959b6 100644 --- a/core/Metrics/Formatter.php +++ b/core/Metrics/Formatter.php @@ -321,4 +321,4 @@ private function getMetricsToFormat(DataTable $dataTable, Report $report = null) { return Report::getMetricsForTable($dataTable, $report, $baseType = 'Piwik\\Plugin\\Metric'); } -} \ No newline at end of file +} diff --git a/core/Metrics/Formatter/Html.php b/core/Metrics/Formatter/Html.php index c4f9e05664e..60c2f43c149 100644 --- a/core/Metrics/Formatter/Html.php +++ b/core/Metrics/Formatter/Html.php @@ -40,4 +40,4 @@ private function replaceSpaceWithNonBreakingSpace($value) { return str_replace(' ', ' ', $value); } -} \ No newline at end of file +} diff --git a/core/Period/Factory.php b/core/Period/Factory.php index 2da4bd9f55a..88c29a92e28 100644 --- a/core/Period/Factory.php +++ b/core/Period/Factory.php @@ -9,7 +9,6 @@ namespace Piwik\Period; use Exception; -use Piwik\Config; use Piwik\Date; use Piwik\Period; use Piwik\Piwik; diff --git a/core/Period/Month.php b/core/Period/Month.php index 9acf63b1b20..68d97e1d5fa 100644 --- a/core/Period/Month.php +++ b/core/Period/Month.php @@ -82,7 +82,6 @@ protected function processOptimalSubperiods($startDate, $endDate) { while ($startDate->isEarlier($endDate) || $startDate == $endDate) { - $week = new Week($startDate); $startOfWeek = $week->getDateStart(); $endOfWeek = $week->getDateEnd(); @@ -112,5 +111,4 @@ private function fillDayPeriods($startDate, $endDate) $startDate = $startDate->addDay(1); } } - } diff --git a/core/Period/Range.php b/core/Period/Range.php index 77d7afdcbdc..9e14565517b 100644 --- a/core/Period/Range.php +++ b/core/Period/Range.php @@ -241,7 +241,6 @@ protected function generate() } $startDate = $endDate->addPeriod(-1 * $lastN, $period); - } elseif ($dateRange = Range::parseDateRange($this->strDate)) { $strDateStart = $dateRange[1]; $strDateEnd = $dateRange[2]; @@ -338,7 +337,7 @@ protected function processOptimalSubperiods($startDate, $endDate) ) { $this->addSubperiod($year); $endOfPeriod = $endOfYear; - } else if ($startDate == $startOfMonth + } elseif ($startDate == $startOfMonth && ($endOfMonth->isEarlier($endDate) || $endOfMonth == $endDate || $endOfMonth->isLater($this->today) @@ -460,8 +459,9 @@ public static function getDateXPeriodsAgo($subXPeriods, $date = false, $period = $strLastDate = false; $lastPeriod = false; if ($period != 'range' && !preg_match('/(last|previous)([0-9]*)/', $date, $regs)) { - if (strpos($date, ',')) // date in the form of 2011-01-01,2011-02-02 - { + if (strpos($date, ',')) { + // date in the form of 2011-01-01,2011-02-02 + $rangePeriod = new Range($period, $date); $lastStartDate = $rangePeriod->getDateStart()->subPeriod($subXPeriods, $period); diff --git a/core/Period/Year.php b/core/Period/Year.php index cb2d202ff7f..ccd9c2e2b3b 100644 --- a/core/Period/Year.php +++ b/core/Period/Year.php @@ -76,7 +76,7 @@ protected function generate() * @param string $format * @return array */ - function toString($format = 'ignored') + public function toString($format = 'ignored') { $this->generate(); diff --git a/core/Piwik.php b/core/Piwik.php index fa2392a14b9..cfc1d995bdd 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -9,16 +9,7 @@ namespace Piwik; use Exception; -use Piwik\Container\StaticContainer; -use Piwik\Db\Adapter; -use Piwik\Db\Schema; -use Piwik\Db; -use Piwik\Plugin; -use Piwik\Plugins\UsersManager\API as APIUsersManager; -use Piwik\Session; -use Piwik\Tracker; -use Piwik\Translation\Translator; -use Piwik\View; +use Piwik\Container\StaticContainer;use Piwik\Plugins\UsersManager\API as APIUsersManager;use Piwik\Translation\Translator; /** * @see core/Translate.php @@ -203,7 +194,7 @@ public static function getCurrentUserLogin() { $login = Access::getInstance()->getLogin(); - if(empty($login)) { + if (empty($login)) { return 'anonymous'; } return $login; @@ -301,7 +292,6 @@ public static function hasUserSuperUserAccess() $hasAccess = Access::getInstance()->hasSuperUserAccess(); return $hasAccess; - } catch (Exception $e) { return false; } @@ -635,8 +625,9 @@ public static function isAssociativeArray($array) reset($array); if (!is_numeric(key($array)) || key($array) != 0 - ) // first key must be 0 - { + ) { + // first key must be 0 + return true; } @@ -649,7 +640,7 @@ public static function isAssociativeArray($array) if ($next === null) { break; - } else if ($current + 1 != $next) { + } elseif ($current + 1 != $next) { return true; } } diff --git a/core/Plugin.php b/core/Plugin.php index bb361b5bb5e..1cdbefdc7f1 100644 --- a/core/Plugin.php +++ b/core/Plugin.php @@ -335,7 +335,6 @@ public function findComponent($componentName, $expectedSubclass) if (file_exists($componentFile)) { include_once $componentFile; } - } else { $this->cache->save($cacheId, false); // prevent from trying to load over and over again for instance if there is no Menu for a plugin diff --git a/core/Plugin/API.php b/core/Plugin/API.php index 40bd334f951..c54e10a82bb 100644 --- a/core/Plugin/API.php +++ b/core/Plugin/API.php @@ -50,7 +50,8 @@ abstract class API * * @return static */ - public static function getInstance() { + public static function getInstance() + { $class = get_called_class(); if (!isset(self::$instances[$class])) { diff --git a/core/Plugin/AggregatedMetric.php b/core/Plugin/AggregatedMetric.php index 7df15357270..6324390ee3c 100644 --- a/core/Plugin/AggregatedMetric.php +++ b/core/Plugin/AggregatedMetric.php @@ -7,7 +7,6 @@ */ namespace Piwik\Plugin; -use Piwik\DataTable\Row; /** * Base type for metric metadata classes that describe aggregated metrics. These metrics are @@ -19,4 +18,4 @@ abstract class AggregatedMetric extends Metric { // stub, to be filled out later -} \ No newline at end of file +} diff --git a/core/Plugin/ComponentFactory.php b/core/Plugin/ComponentFactory.php index 751f1157d47..c0b3c7bff51 100644 --- a/core/Plugin/ComponentFactory.php +++ b/core/Plugin/ComponentFactory.php @@ -128,4 +128,4 @@ private static function getActivatedPlugin($function, $pluginName) return null; } } -} \ No newline at end of file +} diff --git a/core/Plugin/Controller.php b/core/Plugin/Controller.php index e7f96a490c2..3e710608ebe 100644 --- a/core/Plugin/Controller.php +++ b/core/Plugin/Controller.php @@ -778,7 +778,7 @@ public static function setHostValidationVariablesView($view) $validHost, '' )); - } else if (Piwik::isUserIsAnonymous()) { + } elseif (Piwik::isUserIsAnonymous()) { $view->invalidHostMessage = $warningStart . ' ' . Piwik::translate('CoreHome_InjectedHostNonSuperUserWarning', array( "
", @@ -860,7 +860,7 @@ public function redirectToIndex($moduleToRedirect, $actionToRedirect, $websiteId { try { $this->doRedirectToUrl($moduleToRedirect, $actionToRedirect, $websiteId, $defaultPeriod, $defaultDate, $parameters); - } catch(Exception $e) { + } catch (Exception $e) { // no website ID to default to, so could not redirect } @@ -926,8 +926,9 @@ protected function checkTokenInUrl() */ public static function getCalendarPrettyDate($period) { - if ($period instanceof Month) // show month name when period is for a month - { + if ($period instanceof Month) { + // show month name when period is for a month + return $period->getLocalizedLongString(); } else { return $period->getPrettyString(); @@ -976,7 +977,7 @@ protected function getEvolutionHtml($date, $currentValue, $pastDate, $pastValue) if ($evolutionPercent < 0) { $class = "negative-evolution"; $img = "arrow_down.png"; - } else if ($evolutionPercent == 0) { + } elseif ($evolutionPercent == 0) { $class = "neutral-evolution"; $img = "stop.png"; } else { @@ -1008,7 +1009,7 @@ protected function checkSitePermission() { if (!empty($this->idSite) && empty($this->site)) { throw new NoAccessException(Piwik::translate('General_ExceptionPrivilegeAccessWebsite', array("'view'", $this->idSite))); - } else if (empty($this->site) || empty($this->idSite)) { + } elseif (empty($this->site) || empty($this->idSite)) { throw new Exception("The requested website idSite is not found in the request, or is invalid. Please check that you are logged in Piwik and have permission to access the specified website."); } diff --git a/core/Plugin/ControllerAdmin.php b/core/Plugin/ControllerAdmin.php index b0c86a6b1a0..c82fcaf92bf 100644 --- a/core/Plugin/ControllerAdmin.php +++ b/core/Plugin/ControllerAdmin.php @@ -221,5 +221,4 @@ private static function isPhpVersion53() { return strpos(PHP_VERSION, '5.3') === 0; } - } diff --git a/core/Plugin/Dependency.php b/core/Plugin/Dependency.php index 7e87324612b..bcade2b3cac 100644 --- a/core/Plugin/Dependency.php +++ b/core/Plugin/Dependency.php @@ -51,12 +51,11 @@ public function getMissingDependencies($requires) public function getMissingVersions($currentVersion, $requiredVersion) { $currentVersion = trim($currentVersion); - $requiredVersions = explode(',' , (string) $requiredVersion); + $requiredVersions = explode(',', (string) $requiredVersion); $missingVersions = array(); foreach ($requiredVersions as $required) { - $comparison = '>='; $required = trim($required); @@ -98,7 +97,8 @@ private function getCurrentVersion($name) if (!empty($plugin)) { return $plugin->getVersion(); } - } catch (\Exception $e) {} + } catch (\Exception $e) { + } } return ''; diff --git a/core/Plugin/Dimension/ActionDimension.php b/core/Plugin/Dimension/ActionDimension.php index d12e7b45a79..3c697641a36 100644 --- a/core/Plugin/Dimension/ActionDimension.php +++ b/core/Plugin/Dimension/ActionDimension.php @@ -19,7 +19,6 @@ use Piwik\Tracker\Action; use Piwik\Tracker\Request; use Piwik\Tracker\Visitor; -use Piwik\Translate; use Exception; /** @@ -218,7 +217,6 @@ public static function getAllDimensions() $cache = PiwikCache::getTransientCache(); if (!$cache->contains($cacheId)) { - $plugins = PluginManager::getInstance()->getPluginsLoadedAndActivated(); $instances = array(); @@ -251,5 +249,4 @@ public static function getDimensions(Plugin $plugin) return $instances; } - } diff --git a/core/Plugin/Dimension/ConversionDimension.php b/core/Plugin/Dimension/ConversionDimension.php index 34a80061119..e20f1eeeaf4 100644 --- a/core/Plugin/Dimension/ConversionDimension.php +++ b/core/Plugin/Dimension/ConversionDimension.php @@ -18,7 +18,6 @@ use Piwik\Tracker\GoalManager; use Piwik\Tracker\Request; use Piwik\Tracker\Visitor; -use Piwik\Translate; use Piwik\Plugin\Segment; use Piwik\Plugin; use Exception; @@ -160,7 +159,6 @@ public static function getAllDimensions() $cache = PiwikCache::getTransientCache(); if (!$cache->contains($cacheId)) { - $plugins = PluginManager::getInstance()->getPluginsLoadedAndActivated(); $instances = array(); @@ -244,5 +242,4 @@ public function onGoalConversion(Request $request, Visitor $visitor, $action, Go { return false; } - } diff --git a/core/Plugin/Dimension/VisitDimension.php b/core/Plugin/Dimension/VisitDimension.php index 97dfd6f57b2..b93ca041b6b 100644 --- a/core/Plugin/Dimension/VisitDimension.php +++ b/core/Plugin/Dimension/VisitDimension.php @@ -19,7 +19,6 @@ use Piwik\Tracker\Visitor; use Piwik\Tracker\Action; use Piwik\Tracker; -use Piwik\Translate; use Piwik\Plugin; use Exception; @@ -299,7 +298,6 @@ public static function getAllDimensions() $cache = PiwikCache::getTransientCache(); if (!$cache->contains($cacheId)) { - $plugins = PluginManager::getInstance()->getPluginsLoadedAndActivated(); $instances = array(); @@ -352,5 +350,4 @@ public static function getDimensions(Plugin $plugin) return $instances; } - } diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index 341f2f3c475..8790175128b 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -15,7 +15,6 @@ use Piwik\Config as PiwikConfig; use Piwik\Config; use Piwik\Container\StaticContainer; -use Piwik\Db; use Piwik\EventDispatcher; use Piwik\Filesystem; use Piwik\Log; @@ -141,7 +140,6 @@ public function loadTrackerPlugins() if ($cache->contains($cacheId)) { $pluginsTracker = $cache->fetch($cacheId); } else { - $this->unloadPlugins(); $this->loadActivatedPlugins(); @@ -196,7 +194,7 @@ public function getTrackerPluginsNotToLoad() public function getCorePluginsDisabledByDefault() { - return array_merge( $this->corePluginsDisabledByDefault, $this->coreThemesDisabledByDefault); + return array_merge($this->corePluginsDisabledByDefault, $this->coreThemesDisabledByDefault); } // If a plugin hooks onto at least an event starting with "Tracker.", we load the plugin during tracker @@ -244,7 +242,7 @@ private function updatePluginsInstalledConfig($plugins) public function clearPluginsInstalledConfig() { - $this->updatePluginsInstalledConfig( array() ); + $this->updatePluginsInstalledConfig(array()); PiwikConfig::getInstance()->forceSave(); } @@ -1309,7 +1307,7 @@ protected function getPluginsFromGlobalIniConfigFile() protected function isPluginEnabledByDefault($name) { $pluginsBundledWithPiwik = $this->getPluginsFromGlobalIniConfigFile(); - if(empty($pluginsBundledWithPiwik)) { + if (empty($pluginsBundledWithPiwik)) { return false; } return in_array($name, $pluginsBundledWithPiwik); @@ -1333,7 +1331,7 @@ private function makePluginsToLoad(array $pluginsToLoad) private function sortPluginsSameOrderAsGlobalConfig(array $plugins) { $global = $this->getPluginsFromGlobalIniConfigFile(); - if(empty($global)) { + if (empty($global)) { return $plugins; } $global = array_values($global); diff --git a/core/Plugin/Menu.php b/core/Plugin/Menu.php index 10d7945bf5b..dd1dcaf7f31 100644 --- a/core/Plugin/Menu.php +++ b/core/Plugin/Menu.php @@ -268,5 +268,4 @@ private function checkisValidCallable($module, $action) Development::error($prefix . 'The defined action "' . $action . '" is not callable on "' . $controllerClass . '". Make sure the method is public.'); } } - } diff --git a/core/Plugin/MetadataLoader.php b/core/Plugin/MetadataLoader.php index e75bc583383..703cf6ba5fa 100644 --- a/core/Plugin/MetadataLoader.php +++ b/core/Plugin/MetadataLoader.php @@ -9,7 +9,6 @@ namespace Piwik\Plugin; use Exception; -use Piwik\Common; use Piwik\Piwik; use Piwik\Version; diff --git a/core/Plugin/Metric.php b/core/Plugin/Metric.php index 4122dfeedf8..6349ca69998 100644 --- a/core/Plugin/Metric.php +++ b/core/Plugin/Metric.php @@ -112,7 +112,6 @@ public static function getMetric($row, $columnName, $mappingNameToId = null) $value = $row->getColumn($columnName); if ($value === false) { - if (empty($mappingNameToId)) { $mappingNameToId = Metrics::getMappingFromNameToId(); } @@ -123,14 +122,10 @@ public static function getMetric($row, $columnName, $mappingNameToId = null) } return $value; - } elseif (!empty($row)) { - if (array_key_exists($columnName, $row)) { return $row[$columnName]; - } else { - if (empty($mappingNameToId)) { $mappingNameToId = Metrics::getMappingFromNameToId(); } @@ -191,4 +186,4 @@ public static function getActualMetricColumn(DataTable $table, $columnName, $map } return $columnName; } -} \ No newline at end of file +} diff --git a/core/Plugin/ProcessedMetric.php b/core/Plugin/ProcessedMetric.php index 20201d08877..108612c805c 100644 --- a/core/Plugin/ProcessedMetric.php +++ b/core/Plugin/ProcessedMetric.php @@ -67,4 +67,4 @@ public function beforeCompute($report, DataTable $table) { return true; } -} \ No newline at end of file +} diff --git a/core/Plugin/Report.php b/core/Plugin/Report.php index a1c54e59d1d..75d76fca33d 100644 --- a/core/Plugin/Report.php +++ b/core/Plugin/Report.php @@ -297,7 +297,7 @@ public function getDefaultTypeViewDataTable() * Defaults to false * @return bool */ - public function alwaysUseDefaultViewDataTable () + public function alwaysUseDefaultViewDataTable() { return false; } @@ -312,7 +312,6 @@ public function alwaysUseDefaultViewDataTable () */ public function configureView(ViewDataTable $view) { - } /** @@ -433,7 +432,7 @@ public function getMetricsRequiredForReport($allMetrics = null, $restrictToColum foreach ($restrictToColumns as $column) { if (isset($processedMetricsById[$column])) { $metrics = array_merge($metrics, $processedMetricsById[$column]->getDependentMetrics()); - } else if (isset($metricsSet[$column])) { + } elseif (isset($metricsSet[$column])) { $metrics[] = $column; } } @@ -498,7 +497,6 @@ protected function getMetricsDocumentation() if (is_string($processedMetric) && !empty($translations[$processedMetric])) { $documentation[$processedMetric] = $translations[$processedMetric]; } elseif ($processedMetric instanceof ProcessedMetric) { - $name = $processedMetric->getName(); $metricDocs = $processedMetric->getDocumentation(); if (empty($metricDocs)) { @@ -509,7 +507,6 @@ protected function getMetricsDocumentation() $documentation[$processedMetric->getName()] = $metricDocs; } } - } return $documentation; @@ -990,4 +987,4 @@ public static function getProcessedMetricsForTable(DataTable $dataTable, Report { return self::getMetricsForTable($dataTable, $report, 'Piwik\\Plugin\\ProcessedMetric'); } -} \ No newline at end of file +} diff --git a/core/Plugin/Segment.php b/core/Plugin/Segment.php index 2f0c84db632..8553703b08f 100644 --- a/core/Plugin/Segment.php +++ b/core/Plugin/Segment.php @@ -67,7 +67,6 @@ final public function __construct() */ protected function init() { - } /** @@ -201,7 +200,8 @@ public function getSegment() * * @param callable $suggestedValuesCallback */ - public function setSuggestedValuesCallback($suggestedValuesCallback) { + public function setSuggestedValuesCallback($suggestedValuesCallback) + { $this->suggestedValuesCallback = $suggestedValuesCallback; } @@ -253,4 +253,4 @@ public function toArray() return $segment; } -} \ No newline at end of file +} diff --git a/core/Plugin/Settings.php b/core/Plugin/Settings.php index 8a674ae3708..1066ea6aff0 100644 --- a/core/Plugin/Settings.php +++ b/core/Plugin/Settings.php @@ -64,7 +64,6 @@ public function __construct($pluginName = null) if (!empty($pluginName)) { $this->pluginName = $pluginName; } else { - $classname = get_class($this); $parts = explode('\\', $classname); diff --git a/core/Plugin/Tasks.php b/core/Plugin/Tasks.php index 2d131d86c4e..19f9e5bb39a 100644 --- a/core/Plugin/Tasks.php +++ b/core/Plugin/Tasks.php @@ -151,4 +151,4 @@ private function checkIsValidTask($objectOrClassName, $methodName) { Development::checkMethodIsCallable($objectOrClassName, $methodName, 'The registered task is not valid as the method'); } -} \ No newline at end of file +} diff --git a/core/Plugin/ViewDataTable.php b/core/Plugin/ViewDataTable.php index a49358e48b2..eb733265ff1 100644 --- a/core/Plugin/ViewDataTable.php +++ b/core/Plugin/ViewDataTable.php @@ -347,7 +347,7 @@ public static function getViewDataTableId() throw new \Exception($message); } - return $id; + return $id; } /** @@ -514,5 +514,4 @@ private function overrideViewPropertiesWithParams($overrideParams) } } } - } diff --git a/core/Plugin/Visualization.php b/core/Plugin/Visualization.php index 6e6b4802a0f..ceccc4ab135 100644 --- a/core/Plugin/Visualization.php +++ b/core/Plugin/Visualization.php @@ -508,7 +508,7 @@ private function getClientSidePropertiesToSet() foreach ($this->config->clientSideProperties as $name) { if (property_exists($this->requestConfig, $name)) { $result[$name] = $this->getIntIfValueIsBool($this->requestConfig->$name); - } else if (property_exists($this->config, $name)) { + } elseif (property_exists($this->config, $name)) { $result[$name] = $this->getIntIfValueIsBool($this->config->$name); } } @@ -562,7 +562,7 @@ protected function getClientSideParametersToSet() if (property_exists($this->requestConfig, $name)) { $valueToConvert = $this->requestConfig->$name; - } else if (property_exists($this->config, $name)) { + } elseif (property_exists($this->config, $name)) { $valueToConvert = $this->config->$name; } @@ -719,7 +719,7 @@ private function makeSureArrayContainsOnlyStrings($array) /** * @internal - * + * * @return array */ public function buildApiRequestArray() diff --git a/core/Plugin/Widgets.php b/core/Plugin/Widgets.php index 2c86fe045f7..10566a9a7a8 100644 --- a/core/Plugin/Widgets.php +++ b/core/Plugin/Widgets.php @@ -106,7 +106,6 @@ public function getWidgets() */ public function configureWidgetsList(WidgetsList $widgetsList) { - } /** diff --git a/core/Profiler.php b/core/Profiler.php index e3bbfb47e3a..c1b0875fa64 100644 --- a/core/Profiler.php +++ b/core/Profiler.php @@ -9,7 +9,6 @@ namespace Piwik; use Exception; -use Piwik\Container\StaticContainer; use XHProfRuns_Default; /** @@ -228,7 +227,8 @@ public static function setupProfilerXHProf($mainRun = false, $setupDuringTrackin } if (!function_exists('xhprof_error')) { - function xhprof_error($out) { + function xhprof_error($out) + { echo substr($out, 0, 300) . '...'; } } @@ -245,7 +245,7 @@ function xhprof_error($out) { xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); - register_shutdown_function(function () use($profilerNamespace, $mainRun) { + register_shutdown_function(function () use ($profilerNamespace, $mainRun) { $xhprofData = xhprof_disable(); $xhprofRuns = new XHProfRuns_Default(); $runId = $xhprofRuns->save_run($xhprofData, $profilerNamespace); @@ -324,13 +324,13 @@ public static function aggregateXhprofRuns($runIds, $profilerNamespace, $saveToR public static function setProfilingRunIds($ids) { - file_put_contents( self::getPathToXHProfRunIds(), json_encode($ids) ); + file_put_contents(self::getPathToXHProfRunIds(), json_encode($ids)); @chmod(self::getPathToXHProfRunIds(), 0777); } public static function getProfilingRunIds() { - $runIds = file_get_contents( self::getPathToXHProfRunIds() ); + $runIds = file_get_contents(self::getPathToXHProfRunIds()); $array = json_decode($runIds, $assoc = true); if (!is_array($array)) { $array = array(); diff --git a/core/ProxyHttp.php b/core/ProxyHttp.php index b2939e9a399..790d62229d6 100644 --- a/core/ProxyHttp.php +++ b/core/ProxyHttp.php @@ -234,7 +234,7 @@ private static function getCompressionEncodingAcceptedByClient() if (preg_match(self::DEFLATE_ENCODING_REGEX, $acceptEncoding, $matches)) { return array('deflate', '.deflate'); - } else if (preg_match(self::GZIP_ENCODING_REGEX, $acceptEncoding, $matches)) { + } elseif (preg_match(self::GZIP_ENCODING_REGEX, $acceptEncoding, $matches)) { return array('gzip', '.gz'); } else { return array(false, false); @@ -262,7 +262,7 @@ private static function compressFile($fileToCompress, $compressedFilePath, $comp if ($compressionEncoding == 'deflate') { $data = gzdeflate($data, 9); - } else if ($compressionEncoding == 'gzip' || $compressionEncoding == 'x-gzip') { + } elseif ($compressionEncoding == 'gzip' || $compressionEncoding == 'x-gzip') { $data = gzencode($data, 9); } diff --git a/core/QuickForm2.php b/core/QuickForm2.php index e2ecbf5b3cc..49b21672897 100644 --- a/core/QuickForm2.php +++ b/core/QuickForm2.php @@ -27,7 +27,7 @@ abstract class QuickForm2 extends HTML_QuickForm2 { protected $a_formElements = array(); - function __construct($id, $method = 'post', $attributes = null, $trackSubmit = false) + public function __construct($id, $method = 'post', $attributes = null, $trackSubmit = false) { if (!isset($attributes['action'])) { $attributes['action'] = Url::getCurrentQueryString(); @@ -43,7 +43,7 @@ function __construct($id, $method = 'post', $attributes = null, $trackSubmit = f /** * Class specific initialization */ - abstract function init(); + abstract public function init(); /** * The elements in this form @@ -77,7 +77,7 @@ public function addElement($elementOrType, $name = null, $attributes = null, return parent::addElement($elementOrType, $name, $attributes, $data); } - function setChecked($nameElement) + public function setChecked($nameElement) { foreach ($this->_elements as $key => $value) { if ($value->_attributes['name'] == $nameElement) { @@ -86,7 +86,7 @@ function setChecked($nameElement) } } - function setSelected($nameElement, $value) + public function setSelected($nameElement, $value) { foreach ($this->_elements as $key => $value) { if ($value->_attributes['name'] == $nameElement) { @@ -101,7 +101,7 @@ function setSelected($nameElement, $value) * @param string $elementName * @return mixed */ - function getSubmitValue($elementName) + public function getSubmitValue($elementName) { $value = $this->getValue(); return isset($value[$elementName]) ? $value[$elementName] : null; diff --git a/core/ReportRenderer.php b/core/ReportRenderer.php index 443c16df76a..a693d1b7f33 100644 --- a/core/ReportRenderer.php +++ b/core/ReportRenderer.php @@ -13,9 +13,7 @@ use Piwik\Container\StaticContainer; use Piwik\DataTable\Row; use Piwik\DataTable\Simple; -use Piwik\DataTable; use Piwik\Plugins\ImageGraph\API; -use Piwik\BaseFactory; /** * A Report Renderer produces user friendly renderings of any given Piwik report. @@ -164,7 +162,7 @@ protected static function writeFile($filename, $extension, $content) $bytesWritten = file_put_contents($outputFilename, $content); if ($bytesWritten === false) { - throw new Exception ("ReportRenderer: Could not write to file '" . $outputFilename . "'."); + throw new Exception("ReportRenderer: Could not write to file '" . $outputFilename . "'."); } return $outputFilename; diff --git a/core/ReportRenderer/Html.php b/core/ReportRenderer/Html.php index 6c0e950c3ef..3ff0fd0d40e 100644 --- a/core/ReportRenderer/Html.php +++ b/core/ReportRenderer/Html.php @@ -172,7 +172,6 @@ public function getAttachments($report, $processedReports, $prettyDate) foreach ($processedReports as $processedReport) { if ($processedReport['displayGraph']) { - $additionalFiles[] = $this->getAttachment($report, $processedReport, $prettyDate); } } diff --git a/core/ReportRenderer/Pdf.php b/core/ReportRenderer/Pdf.php index 4f0ee97bdc4..8c1dbcf2b52 100644 --- a/core/ReportRenderer/Pdf.php +++ b/core/ReportRenderer/Pdf.php @@ -196,7 +196,6 @@ public function renderFrontPage($reportTitle, $prettyDate, $description, $report // segment if ($segment != null) { - $this->TCPDF->Ln(); $this->TCPDF->Ln(); $this->TCPDF->SetFont($this->reportFont, '', $this->reportHeaderFontSize - 2); @@ -472,7 +471,7 @@ private function paintReportTableHeader() && $columnsCount <= 3 ) { $totalWidth = $this->reportWidthPortrait * 2 / 3; - } else if ($this->orientation == self::LANDSCAPE) { + } elseif ($this->orientation == self::LANDSCAPE) { $totalWidth = $this->reportWidthLandscape; } else { $totalWidth = $this->reportWidthPortrait; diff --git a/core/Scheduler/Schedule/Daily.php b/core/Scheduler/Schedule/Daily.php index 7b1248f1873..e459fbfe96c 100644 --- a/core/Scheduler/Schedule/Daily.php +++ b/core/Scheduler/Schedule/Daily.php @@ -51,6 +51,6 @@ public function getRescheduledTime() */ public function setDay($_day) { - throw new Exception ("Method not supported"); + throw new Exception("Method not supported"); } } diff --git a/core/Scheduler/Schedule/Hourly.php b/core/Scheduler/Schedule/Hourly.php index 5830d378ed3..199e5a0f152 100644 --- a/core/Scheduler/Schedule/Hourly.php +++ b/core/Scheduler/Schedule/Hourly.php @@ -45,7 +45,7 @@ public function getRescheduledTime() */ public function setHour($_hour) { - throw new Exception ("Method not supported"); + throw new Exception("Method not supported"); } /** @@ -56,6 +56,6 @@ public function setHour($_hour) */ public function setDay($_day) { - throw new Exception ("Method not supported"); + throw new Exception("Method not supported"); } } diff --git a/core/Scheduler/Schedule/Monthly.php b/core/Scheduler/Schedule/Monthly.php index 64a96f69dd3..48b0e287c7d 100644 --- a/core/Scheduler/Schedule/Monthly.php +++ b/core/Scheduler/Schedule/Monthly.php @@ -85,8 +85,9 @@ public function getRescheduledTime() && $this->week !== null ) { $newTime = $rescheduledTime + $this->week * 7 * 86400; - while (date("w", $newTime) != $this->dayOfWeek % 7) // modulus for sanity check - { + while (date("w", $newTime) != $this->dayOfWeek % 7) { + // modulus for sanity check + $newTime += 86400; } $scheduledDay = ($newTime - $rescheduledTime) / 86400 + 1; @@ -114,7 +115,7 @@ public function getRescheduledTime() public function setDay($_day) { if (!($_day >= 1 && $_day < 32)) { - throw new Exception ("Invalid day parameter, must be >=1 and < 32"); + throw new Exception("Invalid day parameter, must be >=1 and < 32"); } $this->day = $_day; diff --git a/core/Scheduler/Schedule/Schedule.php b/core/Scheduler/Schedule/Schedule.php index 4642389b442..a150850c8db 100644 --- a/core/Scheduler/Schedule/Schedule.php +++ b/core/Scheduler/Schedule/Schedule.php @@ -107,7 +107,7 @@ abstract public function setDay($_day); public function setHour($hour) { if (!($hour >= 0 && $hour < 24)) { - throw new Exception ("Invalid hour parameter, must be >=0 and < 24"); + throw new Exception("Invalid hour parameter, must be >=0 and < 24"); } $this->hour = $hour; diff --git a/core/Scheduler/Schedule/Weekly.php b/core/Scheduler/Schedule/Weekly.php index 2f984c2db61..09fb5ec77a3 100644 --- a/core/Scheduler/Schedule/Weekly.php +++ b/core/Scheduler/Schedule/Weekly.php @@ -64,7 +64,7 @@ public function setDay($day) } if (!($day >= 1 && $day < 8)) { - throw new Exception ("Invalid day parameter, must be >=1 and < 8"); + throw new Exception("Invalid day parameter, must be >=1 and < 8"); } $this->day = $day; diff --git a/core/Scheduler/TaskLoader.php b/core/Scheduler/TaskLoader.php index 44ec80c54b6..60b9e328b60 100644 --- a/core/Scheduler/TaskLoader.php +++ b/core/Scheduler/TaskLoader.php @@ -27,7 +27,6 @@ public function loadTasks() $pluginTasks = PluginManager::getInstance()->findComponents('Tasks', 'Piwik\Plugin\Tasks'); foreach ($pluginTasks as $pluginTask) { - $pluginTask->schedule(); foreach ($pluginTask->getScheduledTasks() as $task) { diff --git a/core/Segment.php b/core/Segment.php index d3cde673b77..511d4fca108 100644 --- a/core/Segment.php +++ b/core/Segment.php @@ -171,7 +171,6 @@ protected function getCleanedExpression($expression) if ($matchType != SegmentExpression::MATCH_IS_NOT_NULL_NOR_EMPTY && $matchType != SegmentExpression::MATCH_IS_NULL_OR_EMPTY) { - if (isset($segment['sqlFilterValue'])) { $value = call_user_func($segment['sqlFilterValue'], $value); } @@ -261,5 +260,4 @@ public function __toString() { return (string) $this->getString(); } - -} \ No newline at end of file +} diff --git a/core/Segment/SegmentExpression.php b/core/Segment/SegmentExpression.php index 10cf0294e3d..3fcf232a142 100644 --- a/core/Segment/SegmentExpression.php +++ b/core/Segment/SegmentExpression.php @@ -40,7 +40,7 @@ class SegmentExpression const INDEX_BOOL_OPERATOR = 0; const INDEX_OPERAND = 1; - function __construct($string) + public function __construct($string) { $this->string = $string; $this->tree = $this->parseTree(); diff --git a/core/Session.php b/core/Session.php index 97335932056..965553b521a 100644 --- a/core/Session.php +++ b/core/Session.php @@ -86,7 +86,7 @@ public static function start($options = false) @ini_set('session.save_handler', 'files'); @ini_set('session.save_path', $sessionPath); - } else if ($config->General['session_save_handler'] === 'dbtable' + } elseif ($config->General['session_save_handler'] === 'dbtable' || in_array($currentSaveHandler, array('user', 'mm')) ) { // We consider these to be misconfigurations, in that: diff --git a/core/Session/SaveHandler/DbTable.php b/core/Session/SaveHandler/DbTable.php index 74fc5e388b6..03b4afa8628 100644 --- a/core/Session/SaveHandler/DbTable.php +++ b/core/Session/SaveHandler/DbTable.php @@ -25,7 +25,7 @@ class DbTable implements Zend_Session_SaveHandler_Interface /** * @param array $config */ - function __construct($config) + public function __construct($config) { $this->config = $config; $this->maxLifetime = ini_get('session.gc_maxlifetime'); diff --git a/core/Settings/Manager.php b/core/Settings/Manager.php index f3862989e10..e757e44d600 100644 --- a/core/Settings/Manager.php +++ b/core/Settings/Manager.php @@ -37,7 +37,6 @@ public static function getAllPluginSettings() } if (empty(static::$settings)) { - $settings = PluginManager::getInstance()->findComponents('Settings', 'Piwik\\Plugin\\Settings'); $byPluginName = array(); @@ -155,5 +154,4 @@ public static function hasSystemPluginsSettingsForCurrentUser() return !empty($settings); } - } diff --git a/core/Settings/Setting.php b/core/Settings/Setting.php index 4b1b36e5a14..51e79421467 100644 --- a/core/Settings/Setting.php +++ b/core/Settings/Setting.php @@ -8,6 +8,7 @@ */ namespace Piwik\Settings; + use Piwik\Piwik; use Piwik\SettingsServer; diff --git a/core/Settings/Storage.php b/core/Settings/Storage.php index 09525cb6d3f..5e3b8fc7932 100644 --- a/core/Settings/Storage.php +++ b/core/Settings/Storage.php @@ -8,6 +8,7 @@ */ namespace Piwik\Settings; + use Piwik\Option; /** @@ -71,7 +72,6 @@ public function getValue(Setting $setting) $this->loadSettingsIfNotDoneYet(); if (array_key_exists($setting->getKey(), $this->settingsValues)) { - return $this->settingsValues[$setting->getKey()]; } @@ -140,5 +140,4 @@ protected function loadSettings() return array(); } - } diff --git a/core/Settings/Storage/Factory.php b/core/Settings/Storage/Factory.php index c007e30e9f7..87d54ad3b14 100644 --- a/core/Settings/Storage/Factory.php +++ b/core/Settings/Storage/Factory.php @@ -25,5 +25,4 @@ public static function make($pluginName) return $storage; } - } diff --git a/core/Settings/Storage/StaticStorage.php b/core/Settings/Storage/StaticStorage.php index ada437fa1c5..d8a43b6c9aa 100644 --- a/core/Settings/Storage/StaticStorage.php +++ b/core/Settings/Storage/StaticStorage.php @@ -8,6 +8,7 @@ */ namespace Piwik\Settings\Storage; + use Piwik\Settings\Storage; /** @@ -30,5 +31,4 @@ protected function loadSettings() public function save() { } - } diff --git a/core/Settings/UserSetting.php b/core/Settings/UserSetting.php index 60f63e3037b..aa3a08c400e 100644 --- a/core/Settings/UserSetting.php +++ b/core/Settings/UserSetting.php @@ -8,6 +8,7 @@ */ namespace Piwik\Settings; + use Piwik\Common; use Piwik\Piwik; @@ -130,16 +131,13 @@ public static function removeAllUserSettingsForUser($userLogin) $pluginsSettings = Manager::getAllPluginSettings(); foreach ($pluginsSettings as $pluginSettings) { - $settings = $pluginSettings->getSettings(); foreach ($settings as $setting) { - if ($setting instanceof UserSetting) { $setting->setUserLogin($userLogin); $setting->removeValue(); } - } $pluginSettings->save(); diff --git a/core/SettingsPiwik.php b/core/SettingsPiwik.php index 7a731b9b985..614950d5f55 100644 --- a/core/SettingsPiwik.php +++ b/core/SettingsPiwik.php @@ -224,7 +224,6 @@ public static function isPiwikInstalled() return false; } return true; - } /** @@ -437,5 +436,4 @@ public static function isSameFingerprintAcrossWebsites() { return (bool)Config::getInstance()->Tracker['enable_fingerprinting_across_websites']; } - } diff --git a/core/Singleton.php b/core/Singleton.php index 1dff87db5f2..499fb28e526 100644 --- a/core/Singleton.php +++ b/core/Singleton.php @@ -20,9 +20,13 @@ class Singleton { protected static $instances; - protected function __construct() { } + protected function __construct() + { + } - final private function __clone() { } + final private function __clone() + { + } /** * Returns the singleton instance for the derived class. If the singleton instance @@ -30,7 +34,8 @@ final private function __clone() { } * * @return Singleton */ - public static function getInstance() { + public static function getInstance() + { $class = get_called_class(); if (!isset(self::$instances[$class])) { diff --git a/core/Site.php b/core/Site.php index 9312fd53558..cbf554d9812 100644 --- a/core/Site.php +++ b/core/Site.php @@ -80,7 +80,7 @@ public static function setSites($sites) { self::triggerSetSitesEvent($sites); - foreach($sites as $idsite => $site) { + foreach ($sites as $idsite => $site) { self::setSite($idsite, $site); } } diff --git a/core/TCPDF.php b/core/TCPDF.php index f9a4baae99b..fbbadbb3150 100644 --- a/core/TCPDF.php +++ b/core/TCPDF.php @@ -25,7 +25,7 @@ class TCPDF extends \TCPDF * * @see TCPDF::Footer() */ - function Footer() + public function Footer() { //Don't show footer on the frontPage if ($this->currentPageNo > 1) { @@ -40,7 +40,7 @@ function Footer() * @param $msg * @throws Exception */ - function Error($msg) + public function Error($msg) { $this->_destroy(true); throw new Exception($msg); @@ -49,7 +49,7 @@ function Error($msg) /** * Set current page number */ - function setCurrentPageNo() + public function setCurrentPageNo() { if (empty($this->currentPageNo)) { $this->currentPageNo = 1; @@ -68,7 +68,7 @@ function setCurrentPageNo() * @param bool $keepmargins * @param bool $tocpage */ - function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) + public function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { parent::AddPage($orientation); $this->setCurrentPageNo(); @@ -79,7 +79,7 @@ function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage * * @param string $footerContent */ - function SetFooterContent($footerContent) + public function SetFooterContent($footerContent) { $this->footerContent = $footerContent; } diff --git a/core/Theme.php b/core/Theme.php index f7f85a52919..8965a2687cf 100644 --- a/core/Theme.php +++ b/core/Theme.php @@ -67,7 +67,7 @@ public function getJavaScriptFiles() if (!is_array($jsFiles)) { $jsFiles = array($jsFiles); } - foreach($jsFiles as &$jsFile) { + foreach ($jsFiles as &$jsFile) { $jsFile = 'plugins/' . $this->theme->getPluginName() . '/' . $jsFile; } return $jsFiles; @@ -97,7 +97,7 @@ public function rewriteAssetsPathToTheme($output) // rewrites images in JS files '~(=)[\s]?[\'"]([^\'"]+[.jpg|.png|.gif|svg]?)[\'"]~', ); - return preg_replace_callback($pattern, array($this,'rewriteAssetPathIfOverridesFound'), $output); + return preg_replace_callback($pattern, array($this, 'rewriteAssetPathIfOverridesFound'), $output); } private function rewriteAssetPathIfOverridesFound($src) @@ -107,7 +107,7 @@ private function rewriteAssetPathIfOverridesFound($src) // Basic health check, we dont replace if not starting with plugins/ $posPluginsInPath = strpos($pathAsset, 'plugins'); - if ( $posPluginsInPath !== 0) { + if ($posPluginsInPath !== 0) { return $source; } @@ -133,7 +133,7 @@ private function rewriteAssetPathIfOverridesFound($src) // Strip trailing query string $fileToCheck = $overridingAsset; $queryStringPos = strpos($fileToCheck, '?'); - if ( $queryStringPos !== false) { + if ($queryStringPos !== false) { $fileToCheck = substr($fileToCheck, 0, $queryStringPos); } diff --git a/core/Timer.php b/core/Timer.php index c7401677bfe..3aea3db1b9c 100644 --- a/core/Timer.php +++ b/core/Timer.php @@ -7,6 +7,7 @@ * */ namespace Piwik; + use Piwik\Metrics\Formatter; /** diff --git a/core/Tracker.php b/core/Tracker.php index 9c22ab804da..ffe64f980c3 100644 --- a/core/Tracker.php +++ b/core/Tracker.php @@ -227,7 +227,7 @@ protected function disconnectDatabase() public static function disconnectCachedDbConnection() { // code redundancy w/ above is on purpose; above disconnectDatabase depends on method that can potentially be overridden - if (!is_null(self::$db)) { + if (!is_null(self::$db)) { self::$db->disconnect(); self::$db = null; } @@ -243,7 +243,7 @@ public static function setTestEnvironment($args = null, $requestMethod = null) if (is_null($requestMethod) && array_key_exists('REQUEST_METHOD', $_SERVER)) { $requestMethod = $_SERVER['REQUEST_METHOD']; - } else if (is_null($requestMethod)) { + } elseif (is_null($requestMethod)) { $requestMethod = 'GET'; } @@ -278,7 +278,6 @@ public static function setTestEnvironment($args = null, $requestMethod = null) // Tests can force the enabling of IP anonymization if (Common::getRequestVar('forceIpAnonymization', false, null, $args) == 1) { - self::getDatabase(); // make sure db is initialized $privacyConfig = new PrivacyManagerConfig(); @@ -326,7 +325,7 @@ private static function isDebugEnabled() if ($debugOnDemand) { return (bool) Common::getRequestVar('debug', false); } - } catch(Exception $e) { + } catch (Exception $e) { } return false; diff --git a/core/Tracker/Action.php b/core/Tracker/Action.php index 0b88aed2133..c4c33148a0f 100644 --- a/core/Tracker/Action.php +++ b/core/Tracker/Action.php @@ -248,7 +248,6 @@ public function getIdActionNameForEntryAndExitIds() public function getIdActionName() { if (!isset($this->actionIdsCached['idaction_name'])) { - return false; } @@ -302,7 +301,6 @@ public function loadIdsFromLogActionTable() $value = $dimension->onLookupAction($this->request, $this); if (false !== $value) { - if (is_float($value)) { $value = Common::forceDotAsSeparatorForDecimalPoint($value); } @@ -359,7 +357,6 @@ public function record(Visitor $visitor, $idReferrerActionUrl, $idReferrerAction $value = $dimension->onNewAction($this->request, $visitor, $this); if ($value !== false) { - if (is_float($value)) { $value = Common::forceDotAsSeparatorForDecimalPoint($value); } diff --git a/core/Tracker/ActionPageview.php b/core/Tracker/ActionPageview.php index 9088fc543a1..eb98dd4b232 100644 --- a/core/Tracker/ActionPageview.php +++ b/core/Tracker/ActionPageview.php @@ -10,7 +10,6 @@ namespace Piwik\Tracker; use Piwik\Config; -use Piwik\Tracker; /** * This class represents a page view, tracking URL, page title and generation time. @@ -20,7 +19,7 @@ class ActionPageview extends Action { protected $timeGeneration = false; - function __construct(Request $request) + public function __construct(Request $request) { parent::__construct(Action::TYPE_PAGE_URL, $request); @@ -88,5 +87,4 @@ private function getActionCategoryDelimiter() return Config::getInstance()->General['action_url_category_delimiter']; } - } diff --git a/core/Tracker/Cache.php b/core/Tracker/Cache.php index 1c333069eb1..b18003aaa9e 100644 --- a/core/Tracker/Cache.php +++ b/core/Tracker/Cache.php @@ -15,8 +15,6 @@ use Piwik\Config; use Piwik\Option; use Piwik\Piwik; -use Piwik\Plugin; -use Piwik\SettingsServer; use Piwik\Tracker; /** @@ -56,7 +54,7 @@ private static function getTtl() * @param int $idSite * @return array */ - static function getCacheWebsiteAttributes($idSite) + public static function getCacheWebsiteAttributes($idSite) { if ('all' == $idSite) { return array(); diff --git a/core/Tracker/Db/Mysqli.php b/core/Tracker/Db/Mysqli.php index e1922e11e5d..1482add1d3a 100644 --- a/core/Tracker/Db/Mysqli.php +++ b/core/Tracker/Db/Mysqli.php @@ -39,7 +39,7 @@ public function __construct($dbInfo, $driverName = 'mysql') $this->host = null; $this->port = null; $this->socket = $dbInfo['unix_socket']; - } else if ($dbInfo['port'][0] == '/') { + } elseif ($dbInfo['port'][0] == '/') { $this->host = null; $this->port = null; $this->socket = $dbInfo['port']; @@ -239,7 +239,7 @@ private function prepare($query, $parameters) { if (!$parameters) { $parameters = array(); - } else if (!is_array($parameters)) { + } elseif (!is_array($parameters)) { $parameters = array($parameters); } @@ -295,7 +295,7 @@ public function beginTransaction() return; } - if ( $this->connection->autocommit(false)) { + if ($this->connection->autocommit(false)) { $this->activeTransaction = uniqid(); return $this->activeTransaction; } @@ -310,13 +310,12 @@ public function beginTransaction() public function commit($xid) { if ($this->activeTransaction != $xid || $this->activeTransaction === false) { - return; } $this->activeTransaction = false; - if (!$this->connection->commit() ) { + if (!$this->connection->commit()) { throw new DbException("Commit failed"); } @@ -337,7 +336,7 @@ public function rollBack($xid) $this->activeTransaction = false; - if (!$this->connection->rollback() ) { + if (!$this->connection->rollback()) { throw new DbException("Rollback failed"); } diff --git a/core/Tracker/Db/Pdo/Mysql.php b/core/Tracker/Db/Pdo/Mysql.php index 4d6094b4786..826d400c3e6 100644 --- a/core/Tracker/Db/Pdo/Mysql.php +++ b/core/Tracker/Db/Pdo/Mysql.php @@ -42,7 +42,7 @@ public function __construct($dbInfo, $driverName = 'mysql') { if (isset($dbInfo['unix_socket']) && $dbInfo['unix_socket'][0] == '/') { $this->dsn = $driverName . ':dbname=' . $dbInfo['dbname'] . ';unix_socket=' . $dbInfo['unix_socket']; - } else if (!empty($dbInfo['port']) && $dbInfo['port'][0] == '/') { + } elseif (!empty($dbInfo['port']) && $dbInfo['port'][0] == '/') { $this->dsn = $driverName . ':dbname=' . $dbInfo['dbname'] . ';unix_socket=' . $dbInfo['port']; } else { $this->dsn = $driverName . ':dbname=' . $dbInfo['dbname'] . ';host=' . $dbInfo['host'] . ';port=' . $dbInfo['port']; @@ -252,11 +252,11 @@ public function rowCount($queryResult) */ public function beginTransaction() { - if (!$this->activeTransaction === false ) { + if (!$this->activeTransaction === false) { return; } - if ( $this->connection->beginTransaction() ) { + if ($this->connection->beginTransaction()) { $this->activeTransaction = uniqid(); return $this->activeTransaction; } diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php index 2b9de403a27..87fb80ecc4d 100644 --- a/core/Tracker/GoalManager.php +++ b/core/Tracker/GoalManager.php @@ -767,12 +767,11 @@ protected function isUrlMatchingGoal($goal, $pattern_type, $url) $match = $this->isGoalPatternMatchingUrl($goal, $pattern_type, $url); - if(!$match) { + if (!$match) { // Users may set Goal matching URL as URL encoded $goal['pattern'] = urldecode($goal['pattern']); $match = $this->isGoalPatternMatchingUrl($goal, $pattern_type, $url); - } return $match; } @@ -792,7 +791,6 @@ private function triggerHookOnDimensions($dimensions, $hook, $visitor, $action, $value = $dimension->$hook($this->request, $visitor, $action, $this); if (false !== $value) { - if (is_float($value)) { $value = Common::forceDotAsSeparatorForDecimalPoint($value); } diff --git a/core/Tracker/Handler.php b/core/Tracker/Handler.php index 3970b910d17..ed75104efe2 100644 --- a/core/Tracker/Handler.php +++ b/core/Tracker/Handler.php @@ -114,5 +114,4 @@ protected function redirectIfNeeded(RequestSet $requestSet) Url::redirectToUrl($redirectUrl); } } - } diff --git a/core/Tracker/Handler/Factory.php b/core/Tracker/Handler/Factory.php index c15def0fe46..6333374748d 100644 --- a/core/Tracker/Handler/Factory.php +++ b/core/Tracker/Handler/Factory.php @@ -39,5 +39,4 @@ public static function make() return $handler; } - } diff --git a/core/Tracker/Model.php b/core/Tracker/Model.php index ce725db995a..e9b67d6c6a9 100644 --- a/core/Tracker/Model.php +++ b/core/Tracker/Model.php @@ -75,7 +75,7 @@ public function updateConversion($idVisit, $idGoal, $newConversion) try { $this->getDb()->query($sql, $sqlBind); - } catch(Exception $e){ + } catch (Exception $e) { Common::printDebug("There was an error while updating the Conversion: " . $e->getMessage()); return false; @@ -120,7 +120,6 @@ public function createEcommerceItems($ecommerceItems) $bind = array(); foreach ($ecommerceItems as $item) { - if ($i === 0) { $fields = implode(', ', array_keys($item)); $sql .= ' (' . $fields . ') VALUES '; @@ -334,15 +333,10 @@ public function findVisitor($idSite, $configId, $idVisitor, $fieldsToRead, $numC ); if ($shouldMatchOneFieldOnly && $isVisitorIdToLookup) { - $visitRow = $this->findVisitorByVisitorId($idVisitor, $select, $from, $whereCommon, $bindSql); - } elseif ($shouldMatchOneFieldOnly) { - $visitRow = $this->findVisitorByConfigId($configId, $select, $from, $whereCommon, $bindSql); - } else { - $visitRow = $this->findVisitorByVisitorId($idVisitor, $select, $from, $whereCommon, $bindSql); if (empty($visitRow)) { diff --git a/core/Tracker/PageUrl.php b/core/Tracker/PageUrl.php index 9f956c51962..1ff3e529afb 100644 --- a/core/Tracker/PageUrl.php +++ b/core/Tracker/PageUrl.php @@ -50,7 +50,6 @@ public static function excludeQueryParametersFromUrl($originalUrl, $idSite) if (empty($parsedUrl['query'])) { if (empty($parsedUrl['fragment'])) { - return UrlHelper::getParseUrlReverse($parsedUrl); } @@ -97,11 +96,11 @@ public static function getQueryParametersToExclude($idSite) * * @param array &$parametersToExclude An array of parameters to exclude from the tracking url. */ - Piwik::postEvent('Tracker.PageUrl.getQueryParametersToExclude', array(&$parametersToExclude)); + Piwik::postEvent('Tracker.PageUrl.getQueryParametersToExclude', array(&$parametersToExclude)); - if (!empty($parametersToExclude)) { - Common::printDebug('Excluding parameters "' . implode(',', $parametersToExclude) . '" from URL'); - } + if (!empty($parametersToExclude)) { + Common::printDebug('Excluding parameters "' . implode(',', $parametersToExclude) . '" from URL'); + } $parametersToExclude = array_map('strtolower', $parametersToExclude); return $parametersToExclude; @@ -332,7 +331,6 @@ public static function normalizeUrl($url) { foreach (self::$urlPrefixMap as $prefix => $id) { if (strtolower(substr($url, 0, strlen($prefix))) == $prefix) { - return array( 'url' => substr($url, strlen($prefix)), 'prefixId' => $id @@ -375,4 +373,4 @@ public static function urldecodeValidUtf8($value) } return $value; } -} \ No newline at end of file +} diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php index 7eed4104e0e..b0ecacc701c 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -112,7 +112,6 @@ protected function authenticateTrackingApi($tokenAuth) $shouldAuthenticate = TrackerConfig::getConfigValue('tracking_requests_require_authentication'); if ($shouldAuthenticate) { - try { $idSite = $this->getIdSite(); } catch (Exception $e) { @@ -143,7 +142,6 @@ protected function authenticateTrackingApi($tokenAuth) if ($this->isAuthenticated) { Common::printDebug("token_auth is authenticated!"); } - } else { $this->isAuthenticated = true; Common::printDebug("token_auth authentication not required"); @@ -429,7 +427,7 @@ protected function getCustomTimestamp() $isTimestampRecent = $timeFromNow < self::CUSTOM_TIMESTAMP_DOES_NOT_REQUIRE_TOKENAUTH_WHEN_NEWER_THAN; if (!$isTimestampRecent) { - if(!$this->isAuthenticated()) { + if (!$this->isAuthenticated()) { Common::printDebug(sprintf("Custom timestamp is %s seconds old, requires &token_auth...", $timeFromNow)); Common::printDebug("WARN: Tracker API 'cdt' was used with invalid token_auth"); return false; @@ -739,7 +737,7 @@ private function truncateIdAsVisitorId($idVisitor) */ public function getUserIdHashed($userId) { - return substr( sha1( $userId ), 0, 16); + return substr(sha1($userId), 0, 16); } /** diff --git a/core/Tracker/RequestSet.php b/core/Tracker/RequestSet.php index 4d8771dc79f..3d3c626e17c 100644 --- a/core/Tracker/RequestSet.php +++ b/core/Tracker/RequestSet.php @@ -36,7 +36,6 @@ public function setRequests($requests) $this->requests = array(); foreach ($requests as $request) { - if (empty($request) && !is_array($request)) { continue; } @@ -253,6 +252,4 @@ private function getCurrentEnvironment() 'server' => $_SERVER ); } - - } diff --git a/core/Tracker/Response.php b/core/Tracker/Response.php index e4f2f7d5ae5..2b4a6f3b497 100644 --- a/core/Tracker/Response.php +++ b/core/Tracker/Response.php @@ -146,7 +146,7 @@ private function outputApiResponse(Tracker $tracker) $this->outputTransparentGif(); } - private function outputTransparentGif () + private function outputTransparentGif() { $transGifBase64 = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="; Common::sendHeader('Content-Type: image/gif'); @@ -179,5 +179,4 @@ protected function logExceptionToErrorLog(Exception $e) { error_log(sprintf("Error in Piwik (tracker): %s", str_replace("\n", " ", $this->getMessageFromException($e)))); } - } diff --git a/core/Tracker/ScheduledTasksRunner.php b/core/Tracker/ScheduledTasksRunner.php index 8513c8e98f4..c8e8b89ce34 100644 --- a/core/Tracker/ScheduledTasksRunner.php +++ b/core/Tracker/ScheduledTasksRunner.php @@ -9,14 +9,10 @@ namespace Piwik\Tracker; - use Piwik\CliMulti; use Piwik\Common; -use Piwik\Config; -use Piwik\CronArchive; use Piwik\Option; use Piwik\Piwik; -use Piwik\SettingsPiwik; use Piwik\Tracker; class ScheduledTasksRunner diff --git a/core/Tracker/Settings.php b/core/Tracker/Settings.php index 9b3fd7b2e56..a7a945c5171 100644 --- a/core/Tracker/Settings.php +++ b/core/Tracker/Settings.php @@ -17,7 +17,7 @@ class Settings { const OS_BOT = 'BOT'; - function __construct(Request $request, $ip, $isSameFingerprintsAcrossWebsites) + public function __construct(Request $request, $ip, $isSameFingerprintsAcrossWebsites) { $this->request = $request; $this->ipAddress = $ip; @@ -25,7 +25,7 @@ function __construct(Request $request, $ip, $isSameFingerprintsAcrossWebsites) $this->configId = null; } - function getConfigId() + public function getConfigId() { if (empty($this->configId)) { $this->loadInfo(); @@ -114,7 +114,7 @@ protected function getConfigHash($os, $browserName, $browserVersion, $plugin_Fla . $browserLang . $salt; - if(!$this->isSameFingerprintsAcrossWebsites) { + if (!$this->isSameFingerprintsAcrossWebsites) { $configString .= $this->request->getIdSite(); } @@ -122,5 +122,4 @@ protected function getConfigHash($os, $browserName, $browserVersion, $plugin_Fla return substr($hash, 0, Tracker::LENGTH_BINARY_ID); } - -} \ No newline at end of file +} diff --git a/core/Tracker/SettingsStorage.php b/core/Tracker/SettingsStorage.php index 7ffb3de8727..a69e03553f5 100644 --- a/core/Tracker/SettingsStorage.php +++ b/core/Tracker/SettingsStorage.php @@ -55,5 +55,4 @@ private static function buildCache() { return PiwikCache::getEagerCache(); } - } diff --git a/core/Tracker/TableLogAction.php b/core/Tracker/TableLogAction.php index 653c7f84079..21350aedb56 100644 --- a/core/Tracker/TableLogAction.php +++ b/core/Tracker/TableLogAction.php @@ -11,7 +11,6 @@ use Piwik\Common; use Piwik\Segment\SegmentExpression; -use Piwik\Tracker; /** * This class is used to query Action IDs from the log_action table. @@ -35,7 +34,7 @@ class TableLogAction public static function loadIdsAction($actionsNameAndType) { // Add url prefix if not set - foreach($actionsNameAndType as &$action) { + foreach ($actionsNameAndType as &$action) { if (2 == count($action)) { $action[] = null; } @@ -266,6 +265,4 @@ private static function isActionTypeStoredUnsanitized($actionType) return in_array($actionType, $actionsTypesStoredUnsanitized); } - } - diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index 4d81bc2f3ba..2ae3e0677dd 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -125,7 +125,6 @@ public function handle() if ($this->goalManager->isGoalAnOrder()) { $visitIsConverted = true; } - } elseif ($isManualGoalConversion) { // this request is from the JS call to piwikTracker.trackGoal() $someGoalsConverted = $this->goalManager->detectGoalId($this->request->getIdSite()); @@ -136,7 +135,6 @@ public function handle() Common::printDebug('Invalid goal tracking request for goal id = ' . $this->goalManager->idGoal); return; } - } else { // normal page view, potentially triggering a URL matching goal $action = Action::factory($this->request); @@ -178,7 +176,6 @@ public function handle() if (!is_null($action)) { $action->record($visitor, $idReferrerActionUrl, $idReferrerActionName); } - } catch (VisitorNotFoundInDb $e) { // There is an edge case when: @@ -386,7 +383,7 @@ protected function getVisitorIp() protected function getSettingsObject() { if (is_null($this->userSettings)) { - $this->userSettings = new Settings( $this->request, $this->getVisitorIp(), SettingsPiwik::isSameFingerprintAcrossWebsites()); + $this->userSettings = new Settings($this->request, $this->getVisitorIp(), SettingsPiwik::isSameFingerprintAcrossWebsites()); } return $this->userSettings; @@ -590,7 +587,7 @@ protected function getAllVisitDimensions() self::$dimensions = VisitDimension::getAllDimensions(); $dimensionNames = array(); - foreach(self::$dimensions as $dimension) { + foreach (self::$dimensions as $dimension) { $dimensionNames[] = $dimension->getColumnName(); } diff --git a/core/Tracker/Visit/Factory.php b/core/Tracker/Visit/Factory.php index 1d9349dfb19..778832925ce 100644 --- a/core/Tracker/Visit/Factory.php +++ b/core/Tracker/Visit/Factory.php @@ -8,6 +8,7 @@ */ namespace Piwik\Tracker\Visit; + use Piwik\Piwik; use Piwik\Tracker\Visit; use Piwik\Tracker\VisitInterface; diff --git a/core/Tracker/Visit/ReferrerSpamFilter.php b/core/Tracker/Visit/ReferrerSpamFilter.php index 51a50fcb2fc..0c6ee6204a4 100644 --- a/core/Tracker/Visit/ReferrerSpamFilter.php +++ b/core/Tracker/Visit/ReferrerSpamFilter.php @@ -27,7 +27,7 @@ public function isSpam(Request $request) $referrerUrl = $request->getParam('urlref'); - foreach($spammers as $spammerHost) { + foreach ($spammers as $spammerHost) { if (strpos($referrerUrl, $spammerHost) !== false) { Common::printDebug('Referrer URL is a known spam: ' . $spammerHost); return true; diff --git a/core/Tracker/VisitExcluded.php b/core/Tracker/VisitExcluded.php index 0081b37bc2b..8d34797bdc9 100644 --- a/core/Tracker/VisitExcluded.php +++ b/core/Tracker/VisitExcluded.php @@ -10,7 +10,6 @@ use Piwik\Cache as PiwikCache; use Piwik\Common; -use Piwik\Config; use Piwik\DeviceDetectorFactory; use Piwik\Network\IP; use Piwik\Piwik; diff --git a/core/Tracker/Visitor.php b/core/Tracker/Visitor.php index 4088e724f1b..3bd3d1a91c1 100644 --- a/core/Tracker/Visitor.php +++ b/core/Tracker/Visitor.php @@ -161,7 +161,7 @@ protected function shouldLookupOneVisitorFieldOnly($isVisitorIdToLookup) return true; } - if (!$isVisitorIdToLookup ) { + if (!$isVisitorIdToLookup) { return true; } diff --git a/core/Tracker/VisitorNotFoundInDb.php b/core/Tracker/VisitorNotFoundInDb.php index f1a0b71a045..5cbf79190d4 100644 --- a/core/Tracker/VisitorNotFoundInDb.php +++ b/core/Tracker/VisitorNotFoundInDb.php @@ -14,4 +14,3 @@ class VisitorNotFoundInDb extends \Exception { } - diff --git a/core/Translation/Loader/JsonFileLoader.php b/core/Translation/Loader/JsonFileLoader.php index f80b9405289..802bcc62d02 100644 --- a/core/Translation/Loader/JsonFileLoader.php +++ b/core/Translation/Loader/JsonFileLoader.php @@ -8,7 +8,6 @@ namespace Piwik\Translation\Loader; -use Exception; use Piwik\Common; /** diff --git a/core/Translation/Transifex/API.php b/core/Translation/Transifex/API.php index 12576075393..f73f6d2b456 100644 --- a/core/Translation/Transifex/API.php +++ b/core/Translation/Transifex/API.php @@ -139,10 +139,10 @@ protected function getApiResults($apiPath, $raw = false) if ($httpStatus == 401) { throw new AuthenticationFailedException(); - } else if ($httpStatus != 200) { + } elseif ($httpStatus != 200) { throw new Exception('Error while getting API results', $httpStatus); } return $raw ? $response : json_decode($response); } -} \ No newline at end of file +} diff --git a/core/Twig.php b/core/Twig.php index 3f1015cf3a3..09720eefddc 100755 --- a/core/Twig.php +++ b/core/Twig.php @@ -41,26 +41,26 @@ class Twig public function __construct() { $loader = $this->getDefaultThemeLoader(); - $this->addPluginNamespaces($loader); + $this->addPluginNamespaces($loader); - //get current theme - $manager = Plugin\Manager::getInstance(); - $theme = $manager->getThemeEnabled(); - $loaders = array(); + //get current theme + $manager = Plugin\Manager::getInstance(); + $theme = $manager->getThemeEnabled(); + $loaders = array(); $this->formatter = new Formatter(); - //create loader for custom theme to overwrite twig templates - if ($theme && $theme->getPluginName() != \Piwik\Plugin\Manager::DEFAULT_THEME) { - $customLoader = $this->getCustomThemeLoader($theme); - if ($customLoader) { - //make it possible to overwrite plugin templates - $this->addCustomPluginNamespaces($customLoader, $theme->getPluginName()); - $loaders[] = $customLoader; - } - } + //create loader for custom theme to overwrite twig templates + if ($theme && $theme->getPluginName() != \Piwik\Plugin\Manager::DEFAULT_THEME) { + $customLoader = $this->getCustomThemeLoader($theme); + if ($customLoader) { + //make it possible to overwrite plugin templates + $this->addCustomPluginNamespaces($customLoader, $theme->getPluginName()); + $loaders[] = $customLoader; + } + } - $loaders[] = $loader; + $loaders[] = $loader; $chainLoader = new Twig_Loader_Chain($loaders); @@ -161,7 +161,7 @@ protected function addFunction_postEvent() // make the first value the string that will get output in the template // plugins can modify this string $str = ''; - $params = array_merge( array( &$str ), $params); + $params = array_merge(array( &$str ), $params); Piwik::postEvent($eventName, $params); return $str; @@ -199,21 +199,22 @@ private function getDefaultThemeLoader() return $themeLoader; } - /** - * create template loader for a custom theme - * @param \Piwik\Plugin $theme - * @return \Twig_Loader_Filesystem - */ - protected function getCustomThemeLoader(Plugin $theme){ - if (!file_exists(sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, $theme->getPluginName()))){ - return false; - } - $themeLoader = new Twig_Loader_Filesystem(array( + /** + * create template loader for a custom theme + * @param \Piwik\Plugin $theme + * @return \Twig_Loader_Filesystem + */ + protected function getCustomThemeLoader(Plugin $theme) + { + if (!file_exists(sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, $theme->getPluginName()))) { + return false; + } + $themeLoader = new Twig_Loader_Filesystem(array( sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, $theme->getPluginName()) )); return $themeLoader; - } + } public function getTwigEnvironment() { @@ -353,18 +354,18 @@ private function addPluginNamespaces(Twig_Loader_Filesystem $loader) } } - /** - * - * Plugin-Templates can be overwritten by putting identically named templates in plugins/[theme]/templates/plugins/[plugin]/ - * - */ - private function addCustomPluginNamespaces(Twig_Loader_Filesystem $loader, $pluginName) + /** + * + * Plugin-Templates can be overwritten by putting identically named templates in plugins/[theme]/templates/plugins/[plugin]/ + * + */ + private function addCustomPluginNamespaces(Twig_Loader_Filesystem $loader, $pluginName) { $plugins = \Piwik\Plugin\Manager::getInstance()->getAllPluginsNames(); foreach ($plugins as $name) { $path = sprintf("%s/plugins/%s/templates/plugins/%s/", PIWIK_INCLUDE_PATH, $pluginName, $name); if (is_dir($path)) { - $loader->addPath(PIWIK_INCLUDE_PATH . '/plugins/' . $pluginName . '/templates/plugins/'. $name , $name); + $loader->addPath(PIWIK_INCLUDE_PATH . '/plugins/' . $pluginName . '/templates/plugins/'. $name, $name); } } } diff --git a/core/Unzip.php b/core/Unzip.php index 547a1a84a5a..ffef2add155 100644 --- a/core/Unzip.php +++ b/core/Unzip.php @@ -29,16 +29,18 @@ public static function factory($name, $filename) { switch ($name) { case 'ZipArchive': - if (class_exists('ZipArchive', false)) + if (class_exists('ZipArchive', false)) { return new ZipArchive($filename); + } break; case 'tar.gz': return new Tar($filename, 'gz'); case 'tar.bz2': return new Tar($filename, 'bz2'); case 'gz': - if (function_exists('gzopen')) + if (function_exists('gzopen')) { return new Gzip($filename); + } break; case 'PclZip': default: diff --git a/core/Updater.php b/core/Updater.php index bccddff3f22..9190320fa71 100644 --- a/core/Updater.php +++ b/core/Updater.php @@ -10,7 +10,6 @@ use Piwik\Columns\Updater as ColumnUpdater; use Piwik\Container\StaticContainer; -use Piwik\Exception\DatabaseSchemaIsNewerThanCodebaseException; use Piwik\Updater\UpdateObserver; use Zend_Db_Exception; @@ -290,7 +289,7 @@ private function loadComponentsWithUpdateFile() foreach ($files as $file) { $fileVersion = basename($file, '.php'); - if ( // if the update is from a newer version + if (// if the update is from a newer version version_compare($currentVersion, $fileVersion) == -1 // but we don't execute updates from non existing future releases && version_compare($fileVersion, $newVersion) <= 0 @@ -551,7 +550,7 @@ private function executeSingleUpdateClass($className) * @param array $sqlarray An array of SQL queries to be executed * @throws UpdaterErrorException */ - static function updateDatabase($file, $sqlarray) + public static function updateDatabase($file, $sqlarray) { self::$activeInstance->executeMigrationQueries($file, $sqlarray); } diff --git a/core/Updater/UpdateObserver.php b/core/Updater/UpdateObserver.php index b8a91562f55..e639ecdb04f 100644 --- a/core/Updater/UpdateObserver.php +++ b/core/Updater/UpdateObserver.php @@ -111,4 +111,4 @@ public function onError($componentName, $version, \Exception $exception) { // empty } -} \ No newline at end of file +} diff --git a/core/Updates.php b/core/Updates.php index 2ef3e0836da..0eeffc69ddc 100644 --- a/core/Updates.php +++ b/core/Updates.php @@ -18,7 +18,7 @@ abstract class Updates /** * @deprecated since v2.12.0 use getMigrationQueries() instead */ - static function getSql() + public static function getSql() { return array(); } @@ -26,7 +26,7 @@ static function getSql() /** * @deprecated since v2.12.0 use doUpdate() instead */ - static function update() + public static function update() { } diff --git a/core/Updates/0.2.10.php b/core/Updates/0.2.10.php index 215360e5767..e1081512446 100644 --- a/core/Updates/0.2.10.php +++ b/core/Updates/0.2.10.php @@ -18,7 +18,7 @@ */ class Updates_0_2_10 extends Updates { - static function getSql() + public static function getSql() { return array( 'CREATE TABLE `' . Common::prefixTable('option') . '` ( @@ -50,7 +50,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); diff --git a/core/Updates/0.2.12.php b/core/Updates/0.2.12.php index 0cf0fed8eaf..01d837b6369 100644 --- a/core/Updates/0.2.12.php +++ b/core/Updates/0.2.12.php @@ -17,7 +17,7 @@ */ class Updates_0_2_12 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('site') . '` @@ -31,7 +31,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.2.13.php b/core/Updates/0.2.13.php index e73acf0b777..8ed75348eae 100644 --- a/core/Updates/0.2.13.php +++ b/core/Updates/0.2.13.php @@ -17,7 +17,7 @@ */ class Updates_0_2_13 extends Updates { - static function getSql() + public static function getSql() { return array( 'DROP TABLE IF EXISTS `' . Common::prefixTable('option') . '`' => false, @@ -31,7 +31,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.2.24.php b/core/Updates/0.2.24.php index 23bf21274e6..58595ad6f1f 100644 --- a/core/Updates/0.2.24.php +++ b/core/Updates/0.2.24.php @@ -17,7 +17,7 @@ */ class Updates_0_2_24 extends Updates { - static function getSql() + public static function getSql() { return array( 'CREATE INDEX index_type_name @@ -29,7 +29,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.2.27.php b/core/Updates/0.2.27.php index a46990f5fa1..391fa60b33c 100644 --- a/core/Updates/0.2.27.php +++ b/core/Updates/0.2.27.php @@ -18,7 +18,7 @@ */ class Updates_0_2_27 extends Updates { - static function getSql() + public static function getSql() { $sqlarray = array( 'ALTER TABLE `' . Common::prefixTable('log_visit') . '` @@ -73,7 +73,7 @@ static function getSql() return $sqlarray; } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.2.32.php b/core/Updates/0.2.32.php index 15264ebef20..6e73786e15b 100644 --- a/core/Updates/0.2.32.php +++ b/core/Updates/0.2.32.php @@ -17,7 +17,7 @@ */ class Updates_0_2_32 extends Updates { - static function getSql() + public static function getSql() { return array( // 0.2.32 [941] @@ -32,7 +32,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.2.33.php b/core/Updates/0.2.33.php index b1e8886dbf2..b3dda1a1695 100644 --- a/core/Updates/0.2.33.php +++ b/core/Updates/0.2.33.php @@ -18,7 +18,7 @@ */ class Updates_0_2_33 extends Updates { - static function getSql() + public static function getSql() { $sqlarray = array( // 0.2.33 [1020] @@ -38,7 +38,7 @@ static function getSql() return $sqlarray; } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.2.35.php b/core/Updates/0.2.35.php index 658d8968562..266005fc728 100644 --- a/core/Updates/0.2.35.php +++ b/core/Updates/0.2.35.php @@ -17,7 +17,7 @@ */ class Updates_0_2_35 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('user_dashboard') . '` @@ -25,7 +25,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.2.37.php b/core/Updates/0.2.37.php index 6e7bb6da927..2e3878df511 100644 --- a/core/Updates/0.2.37.php +++ b/core/Updates/0.2.37.php @@ -17,7 +17,7 @@ */ class Updates_0_2_37 extends Updates { - static function getSql() + public static function getSql() { return array( 'DELETE FROM `' . Common::prefixTable('user_dashboard') . "` @@ -26,7 +26,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.4.1.php b/core/Updates/0.4.1.php index 1448b4c013a..6d820b77491 100644 --- a/core/Updates/0.4.1.php +++ b/core/Updates/0.4.1.php @@ -17,7 +17,7 @@ */ class Updates_0_4_1 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('log_conversion') . '` @@ -27,7 +27,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.4.2.php b/core/Updates/0.4.2.php index d3cac21d21b..932186d914f 100644 --- a/core/Updates/0.4.2.php +++ b/core/Updates/0.4.2.php @@ -17,7 +17,7 @@ */ class Updates_0_4_2 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('log_visit') . '` @@ -31,7 +31,7 @@ static function getSql() } // when restoring (possibly) previousy dropped columns, ignore mysql code error 1060: duplicate column - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.4.4.php b/core/Updates/0.4.4.php index 51972e2cbf3..3c468659a11 100644 --- a/core/Updates/0.4.4.php +++ b/core/Updates/0.4.4.php @@ -16,7 +16,7 @@ */ class Updates_0_4_4 extends Updates { - static function update() + public static function update() { $obsoleteFile = PIWIK_DOCUMENT_ROOT . '/libs/open-flash-chart/php-ofc-library/ofc_upload_image.php'; if (file_exists($obsoleteFile)) { diff --git a/core/Updates/0.4.php b/core/Updates/0.4.php index ce86db2ceee..ac171940300 100644 --- a/core/Updates/0.4.php +++ b/core/Updates/0.4.php @@ -17,7 +17,7 @@ */ class Updates_0_4 extends Updates { - static function getSql() + public static function getSql() { return array( // 0.4 [1140] @@ -32,7 +32,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.5.4.php b/core/Updates/0.5.4.php index 502da855bc2..c4c1a1d9068 100644 --- a/core/Updates/0.5.4.php +++ b/core/Updates/0.5.4.php @@ -18,7 +18,7 @@ */ class Updates_0_5_4 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('log_action') . '` @@ -26,7 +26,7 @@ static function getSql() ); } - static function update() + public static function update() { $salt = Common::generateUniqId(); $config = Config::getInstance(); diff --git a/core/Updates/0.5.5.php b/core/Updates/0.5.5.php index 50f6236caa5..aed0a255710 100644 --- a/core/Updates/0.5.5.php +++ b/core/Updates/0.5.5.php @@ -18,7 +18,7 @@ */ class Updates_0_5_5 extends Updates { - static function getSql() + public static function getSql() { $sqlarray = array( 'DROP INDEX index_idsite_date ON ' . Common::prefixTable('log_visit') => 1091, @@ -38,9 +38,8 @@ static function getSql() return $sqlarray; } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); - } } diff --git a/core/Updates/0.5.php b/core/Updates/0.5.php index 6c7a51af4e7..f7788430e15 100644 --- a/core/Updates/0.5.php +++ b/core/Updates/0.5.php @@ -17,7 +17,7 @@ */ class Updates_0_5 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE ' . Common::prefixTable('log_action') . ' ADD COLUMN `hash` INTEGER(10) UNSIGNED NOT NULL AFTER `name`;' => 1060, @@ -33,7 +33,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.6-rc1.php b/core/Updates/0.6-rc1.php index 9f293dda97f..f652e29b96f 100644 --- a/core/Updates/0.6-rc1.php +++ b/core/Updates/0.6-rc1.php @@ -17,7 +17,7 @@ */ class Updates_0_6_rc1 extends Updates { - static function getSql() + public static function getSql() { $defaultTimezone = 'UTC'; $defaultCurrency = 'USD'; @@ -38,7 +38,7 @@ static function getSql() ); } - static function update() + public static function update() { // first we disable the plugins and keep an array of warnings messages $pluginsToDisableMessage = array( @@ -64,4 +64,4 @@ static function update() ""); } } -} \ No newline at end of file +} diff --git a/core/Updates/0.6.3.php b/core/Updates/0.6.3.php index 56488304ff0..acb33186253 100644 --- a/core/Updates/0.6.3.php +++ b/core/Updates/0.6.3.php @@ -18,7 +18,7 @@ */ class Updates_0_6_3 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('log_visit') . '` @@ -28,7 +28,7 @@ static function getSql() ); } - static function update() + public static function update() { $config = Config::getInstance(); $dbInfos = $config->database; diff --git a/core/Updates/0.7.php b/core/Updates/0.7.php index 5af49b8d8b3..e6d156d4a5f 100644 --- a/core/Updates/0.7.php +++ b/core/Updates/0.7.php @@ -17,7 +17,7 @@ */ class Updates_0_7 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('option') . '` @@ -25,7 +25,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/0.9.1.php b/core/Updates/0.9.1.php index 9d49a906e65..690b9b9ef4e 100644 --- a/core/Updates/0.9.1.php +++ b/core/Updates/0.9.1.php @@ -18,7 +18,7 @@ */ class Updates_0_9_1 extends Updates { - static function getSql() + public static function getSql() { if (!SettingsServer::isTimezoneSupportEnabled()) { return array(); @@ -48,7 +48,7 @@ static function getSql() ); } - static function update() + public static function update() { if (SettingsServer::isTimezoneSupportEnabled()) { Updater::updateDatabase(__FILE__, self::getSql()); diff --git a/core/Updates/1.1.php b/core/Updates/1.1.php index 5e533c5e072..303fd254a6a 100644 --- a/core/Updates/1.1.php +++ b/core/Updates/1.1.php @@ -17,7 +17,7 @@ */ class Updates_1_1 extends Updates { - static function update() + public static function update() { $config = Config::getInstance(); diff --git a/core/Updates/1.10-b4.php b/core/Updates/1.10-b4.php index 2079e24546e..31bda4882f1 100755 --- a/core/Updates/1.10-b4.php +++ b/core/Updates/1.10-b4.php @@ -15,12 +15,12 @@ */ class Updates_1_10_b4 extends Updates { - static function isMajorUpdate() + public static function isMajorUpdate() { return false; } - static function update() + public static function update() { try { \Piwik\Plugin\Manager::getInstance()->activatePlugin('MobileMessaging'); diff --git a/core/Updates/1.10.1.php b/core/Updates/1.10.1.php index 743a4dda4c0..63226964c29 100755 --- a/core/Updates/1.10.1.php +++ b/core/Updates/1.10.1.php @@ -15,12 +15,12 @@ */ class Updates_1_10_1 extends Updates { - static function isMajorUpdate() + public static function isMajorUpdate() { return false; } - static function update() + public static function update() { try { \Piwik\Plugin\Manager::getInstance()->activatePlugin('Overlay'); diff --git a/core/Updates/1.10.2-b1.php b/core/Updates/1.10.2-b1.php index 03943f63a1f..b963be0176a 100755 --- a/core/Updates/1.10.2-b1.php +++ b/core/Updates/1.10.2-b1.php @@ -17,7 +17,7 @@ */ class Updates_1_10_2_b1 extends Updates { - static function getSql() + public static function getSql() { return array( // ignore existing column name error (1060) @@ -26,7 +26,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/1.10.2-b2.php b/core/Updates/1.10.2-b2.php index a1a88de66ef..66fa382ba73 100644 --- a/core/Updates/1.10.2-b2.php +++ b/core/Updates/1.10.2-b2.php @@ -17,7 +17,7 @@ */ class Updates_1_10_2_b2 extends Updates { - static function getSql() + public static function getSql() { return array( // ignore existing column name error (1060) @@ -26,7 +26,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/1.11-b1.php b/core/Updates/1.11-b1.php index 2c0c02c8770..ceb04c960e3 100644 --- a/core/Updates/1.11-b1.php +++ b/core/Updates/1.11-b1.php @@ -15,12 +15,12 @@ */ class Updates_1_11_b1 extends Updates { - static function isMajorUpdate() + public static function isMajorUpdate() { return false; } - static function update() + public static function update() { try { \Piwik\Plugin\Manager::getInstance()->activatePlugin('UserCountryMap'); diff --git a/core/Updates/1.12-b1.php b/core/Updates/1.12-b1.php index cf0663853e7..59f4c530f82 100644 --- a/core/Updates/1.12-b1.php +++ b/core/Updates/1.12-b1.php @@ -17,12 +17,12 @@ */ class Updates_1_12_b1 extends Updates { - static function isMajorUpdate() + public static function isMajorUpdate() { return true; } - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('log_link_visit_action') . '` @@ -30,9 +30,8 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } - } diff --git a/core/Updates/1.12-b15.php b/core/Updates/1.12-b15.php index 2187fc88162..b3228e8389e 100644 --- a/core/Updates/1.12-b15.php +++ b/core/Updates/1.12-b15.php @@ -15,7 +15,7 @@ */ class Updates_1_12_b15 extends Updates { - static function update() + public static function update() { try { \Piwik\Plugin\Manager::getInstance()->activatePlugin('SegmentEditor'); diff --git a/core/Updates/1.12-b16.php b/core/Updates/1.12-b16.php index 853de0ad85d..ce95badbe17 100644 --- a/core/Updates/1.12-b16.php +++ b/core/Updates/1.12-b16.php @@ -17,7 +17,7 @@ */ class Updates_1_12_b16 extends Updates { - static function getSql() + public static function getSql() { return array( // ignore existing column name error (1060) @@ -26,7 +26,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/1.2-rc1.php b/core/Updates/1.2-rc1.php index e268ad85702..652bb417520 100644 --- a/core/Updates/1.2-rc1.php +++ b/core/Updates/1.2-rc1.php @@ -17,7 +17,7 @@ */ class Updates_1_2_rc1 extends Updates { - static function getSql() + public static function getSql() { return array( // Various performance improvements schema updates @@ -125,7 +125,7 @@ static function getSql() ); } - static function update() + public static function update() { // first we disable the plugins and keep an array of warnings messages $pluginsToDisableMessage = array( @@ -150,7 +150,5 @@ static function update() implode('
  • ', $disabledPlugins) . "
  • "); } - } } - diff --git a/core/Updates/1.2-rc2.php b/core/Updates/1.2-rc2.php index a991f4e0a6f..3696c485e4e 100644 --- a/core/Updates/1.2-rc2.php +++ b/core/Updates/1.2-rc2.php @@ -15,7 +15,7 @@ */ class Updates_1_2_rc2 extends Updates { - static function update() + public static function update() { try { \Piwik\Plugin\Manager::getInstance()->activatePlugin('CustomVariables'); @@ -23,4 +23,3 @@ static function update() } } } - diff --git a/core/Updates/1.2.3.php b/core/Updates/1.2.3.php index d240462468d..3e449b9f46f 100644 --- a/core/Updates/1.2.3.php +++ b/core/Updates/1.2.3.php @@ -18,7 +18,7 @@ */ class Updates_1_2_3 extends Updates { - static function getSql() + public static function getSql() { return array( // LOAD DATA INFILE uses the database's charset @@ -33,9 +33,8 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } } - diff --git a/core/Updates/1.2.5-rc1.php b/core/Updates/1.2.5-rc1.php index af6308ad8ad..f69f6730564 100644 --- a/core/Updates/1.2.5-rc1.php +++ b/core/Updates/1.2.5-rc1.php @@ -17,7 +17,7 @@ */ class Updates_1_2_5_rc1 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('goal') . '` @@ -29,9 +29,8 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } } - diff --git a/core/Updates/1.2.5-rc7.php b/core/Updates/1.2.5-rc7.php index 85ce3792f12..c1be88ae734 100644 --- a/core/Updates/1.2.5-rc7.php +++ b/core/Updates/1.2.5-rc7.php @@ -17,7 +17,7 @@ */ class Updates_1_2_5_rc7 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('log_visit') . '` @@ -25,9 +25,8 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } } - diff --git a/core/Updates/1.4-rc1.php b/core/Updates/1.4-rc1.php index 5290e8d24b9..d3cf376d747 100644 --- a/core/Updates/1.4-rc1.php +++ b/core/Updates/1.4-rc1.php @@ -17,7 +17,7 @@ */ class Updates_1_4_rc1 extends Updates { - static function getSql() + public static function getSql() { return array( 'UPDATE `' . Common::prefixTable('pdf') . '` @@ -27,7 +27,7 @@ static function getSql() ); } - static function update() + public static function update() { try { Updater::updateDatabase(__FILE__, self::getSql()); diff --git a/core/Updates/1.4-rc2.php b/core/Updates/1.4-rc2.php index a54ab231c0e..05cc7c92ae9 100644 --- a/core/Updates/1.4-rc2.php +++ b/core/Updates/1.4-rc2.php @@ -17,7 +17,7 @@ */ class Updates_1_4_rc2 extends Updates { - static function getSql() + public static function getSql() { return array( "SET sql_mode=''" => false, @@ -37,7 +37,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/1.5-b1.php b/core/Updates/1.5-b1.php index 9661fe32138..06c8663966c 100644 --- a/core/Updates/1.5-b1.php +++ b/core/Updates/1.5-b1.php @@ -17,7 +17,7 @@ */ class Updates_1_5_b1 extends Updates { - static function getSql() + public static function getSql() { return array( 'CREATE TABLE `' . Common::prefixTable('log_conversion_item') . '` ( @@ -56,7 +56,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/1.5-b2.php b/core/Updates/1.5-b2.php index 377c26f112f..a6868db408d 100644 --- a/core/Updates/1.5-b2.php +++ b/core/Updates/1.5-b2.php @@ -17,7 +17,7 @@ */ class Updates_1_5_b2 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('log_link_visit_action') . '` @@ -34,7 +34,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/1.5-b3.php b/core/Updates/1.5-b3.php index e7e8754ac39..9a2b6e353a6 100644 --- a/core/Updates/1.5-b3.php +++ b/core/Updates/1.5-b3.php @@ -17,7 +17,7 @@ */ class Updates_1_5_b3 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('log_visit') . '` @@ -56,7 +56,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/1.5-b4.php b/core/Updates/1.5-b4.php index 802992f6ae1..e2b20db87c2 100644 --- a/core/Updates/1.5-b4.php +++ b/core/Updates/1.5-b4.php @@ -17,7 +17,7 @@ */ class Updates_1_5_b4 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('site') . '` @@ -25,7 +25,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/1.5-b5.php b/core/Updates/1.5-b5.php index 5b13385fd85..701e3135b1a 100644 --- a/core/Updates/1.5-b5.php +++ b/core/Updates/1.5-b5.php @@ -17,7 +17,7 @@ */ class Updates_1_5_b5 extends Updates { - static function getSql() + public static function getSql() { return array( 'CREATE TABLE `' . Common::prefixTable('session') . '` ( @@ -30,7 +30,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/1.5-rc6.php b/core/Updates/1.5-rc6.php index fa940cab0a1..60d27b86536 100644 --- a/core/Updates/1.5-rc6.php +++ b/core/Updates/1.5-rc6.php @@ -15,7 +15,7 @@ */ class Updates_1_5_rc6 extends Updates { - static function update() + public static function update() { try { \Piwik\Plugin\Manager::getInstance()->activatePlugin('PrivacyManager'); @@ -23,4 +23,3 @@ static function update() } } } - diff --git a/core/Updates/1.6-b1.php b/core/Updates/1.6-b1.php index f28fc487cc2..1a1186ca905 100644 --- a/core/Updates/1.6-b1.php +++ b/core/Updates/1.6-b1.php @@ -17,7 +17,7 @@ */ class Updates_1_6_b1 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('log_conversion_item') . '` @@ -61,7 +61,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/1.6-rc1.php b/core/Updates/1.6-rc1.php index 75ca3fd0322..9f963084e24 100644 --- a/core/Updates/1.6-rc1.php +++ b/core/Updates/1.6-rc1.php @@ -15,7 +15,7 @@ */ class Updates_1_6_rc1 extends Updates { - static function update() + public static function update() { try { \Piwik\Plugin\Manager::getInstance()->activatePlugin('ImageGraph'); @@ -23,4 +23,3 @@ static function update() } } } - diff --git a/core/Updates/1.7-b1.php b/core/Updates/1.7-b1.php index 676065d3bd8..cb3d323a3da 100644 --- a/core/Updates/1.7-b1.php +++ b/core/Updates/1.7-b1.php @@ -17,7 +17,7 @@ */ class Updates_1_7_b1 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('pdf') . '` @@ -27,7 +27,7 @@ static function getSql() ); } - static function update() + public static function update() { try { Updater::updateDatabase(__FILE__, self::getSql()); diff --git a/core/Updates/1.7.2-rc5.php b/core/Updates/1.7.2-rc5.php index 4fb21e72fe4..4280fe73d37 100644 --- a/core/Updates/1.7.2-rc5.php +++ b/core/Updates/1.7.2-rc5.php @@ -17,7 +17,7 @@ */ class Updates_1_7_2_rc5 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('pdf') . '` @@ -25,7 +25,7 @@ static function getSql() ); } - static function update() + public static function update() { try { Updater::updateDatabase(__FILE__, self::getSql()); diff --git a/core/Updates/1.7.2-rc7.php b/core/Updates/1.7.2-rc7.php index 3966d8c86dc..f19da572f80 100755 --- a/core/Updates/1.7.2-rc7.php +++ b/core/Updates/1.7.2-rc7.php @@ -18,7 +18,7 @@ */ class Updates_1_7_2_rc7 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('user_dashboard') . '` @@ -26,7 +26,7 @@ static function getSql() ); } - static function update() + public static function update() { try { $dashboards = Db::fetchAll('SELECT * FROM `' . Common::prefixTable('user_dashboard') . '`'); diff --git a/core/Updates/1.8.3-b1.php b/core/Updates/1.8.3-b1.php index ee8e6c4d005..51d6d68d061 100644 --- a/core/Updates/1.8.3-b1.php +++ b/core/Updates/1.8.3-b1.php @@ -20,7 +20,7 @@ class Updates_1_8_3_b1 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('site') . '` @@ -44,7 +44,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); if (!\Piwik\Plugin\Manager::getInstance()->isPluginLoaded('ScheduledReports')) { @@ -61,7 +61,6 @@ static function update() $reports = Db::fetchAll('SELECT * FROM `' . Common::prefixTable('pdf') . '`'); foreach ($reports as $report) { - $idreport = $report['idreport']; $idsite = $report['idsite']; $login = $report['login']; @@ -110,6 +109,5 @@ static function update() Db::query('DROP TABLE `' . Common::prefixTable('pdf') . '`'); } catch (\Exception $e) { } - } } diff --git a/core/Updates/1.8.4-b1.php b/core/Updates/1.8.4-b1.php index 272eb084985..7ab572532f1 100644 --- a/core/Updates/1.8.4-b1.php +++ b/core/Updates/1.8.4-b1.php @@ -18,12 +18,12 @@ class Updates_1_8_4_b1 extends Updates { - static function isMajorUpdate() + public static function isMajorUpdate() { return true; } - static function getSql() + public static function getSql() { $action = Common::prefixTable('log_action'); $duplicates = Common::prefixTable('log_action_duplicates'); @@ -176,7 +176,7 @@ static function getSql() ); } - static function update() + public static function update() { try { self::enableMaintenanceMode(); diff --git a/core/Updates/1.9-b16.php b/core/Updates/1.9-b16.php index d6b1c04a09d..937c82a49e7 100755 --- a/core/Updates/1.9-b16.php +++ b/core/Updates/1.9-b16.php @@ -17,12 +17,12 @@ */ class Updates_1_9_b16 extends Updates { - static function isMajorUpdate() + public static function isMajorUpdate() { return true; } - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('log_link_visit_action') . '` @@ -45,9 +45,8 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } } - diff --git a/core/Updates/1.9-b19.php b/core/Updates/1.9-b19.php index 87d46f856a5..15d2a8fd93f 100755 --- a/core/Updates/1.9-b19.php +++ b/core/Updates/1.9-b19.php @@ -17,7 +17,7 @@ */ class Updates_1_9_b19 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE `' . Common::prefixTable('log_link_visit_action') . '` @@ -29,7 +29,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); @@ -39,4 +39,3 @@ static function update() } } } - diff --git a/core/Updates/1.9-b9.php b/core/Updates/1.9-b9.php index 5274232cd83..ce37c0ea5b1 100755 --- a/core/Updates/1.9-b9.php +++ b/core/Updates/1.9-b9.php @@ -17,12 +17,12 @@ */ class Updates_1_9_b9 extends Updates { - static function isMajorUpdate() + public static function isMajorUpdate() { return true; } - static function getSql() + public static function getSql() { $logVisit = Common::prefixTable('log_visit'); $logConversion = Common::prefixTable('log_conversion'); @@ -45,7 +45,7 @@ static function getSql() ); } - static function update() + public static function update() { try { self::enableMaintenanceMode(); @@ -57,4 +57,3 @@ static function update() } } } - diff --git a/core/Updates/1.9.1-b2.php b/core/Updates/1.9.1-b2.php index 81e64b938bf..c68b2f8ed7a 100644 --- a/core/Updates/1.9.1-b2.php +++ b/core/Updates/1.9.1-b2.php @@ -17,14 +17,14 @@ */ class Updates_1_9_1_b2 extends Updates { - static function getSql() + public static function getSql() { return array( 'ALTER TABLE ' . Common::prefixTable('site') . " DROP `feedburnerName`" => 1091 ); } - static function update() + public static function update() { // manually remove ExampleFeedburner column Updater::updateDatabase(__FILE__, self::getSql()); diff --git a/core/Updates/1.9.3-b10.php b/core/Updates/1.9.3-b10.php index a2d7a179a09..5b711b04d44 100755 --- a/core/Updates/1.9.3-b10.php +++ b/core/Updates/1.9.3-b10.php @@ -15,12 +15,12 @@ */ class Updates_1_9_3_b10 extends Updates { - static function isMajorUpdate() + public static function isMajorUpdate() { return false; } - static function update() + public static function update() { try { \Piwik\Plugin\Manager::getInstance()->activatePlugin('Annotations'); diff --git a/core/Updates/1.9.3-b3.php b/core/Updates/1.9.3-b3.php index 875a5754cfb..e7be93c9fb6 100644 --- a/core/Updates/1.9.3-b3.php +++ b/core/Updates/1.9.3-b3.php @@ -15,7 +15,7 @@ */ class Updates_1_9_3_b3 extends Updates { - static function update() + public static function update() { // Insight was a temporary code name for Overlay $pluginToDelete = 'Insight'; diff --git a/core/Updates/1.9.3-b8.php b/core/Updates/1.9.3-b8.php index 867ac817acb..d3deadc0ce6 100755 --- a/core/Updates/1.9.3-b8.php +++ b/core/Updates/1.9.3-b8.php @@ -17,7 +17,7 @@ */ class Updates_1_9_3_b8 extends Updates { - static function getSql() + public static function getSql() { return array( // ignore existing column name error (1060) @@ -26,7 +26,7 @@ static function getSql() ); } - static function update() + public static function update() { // add excluded_user_agents column to site table Updater::updateDatabase(__FILE__, self::getSql()); diff --git a/core/Updates/2.0-a13.php b/core/Updates/2.0-a13.php index b428daef5a6..7c01824ee40 100644 --- a/core/Updates/2.0-a13.php +++ b/core/Updates/2.0-a13.php @@ -9,7 +9,6 @@ namespace Piwik\Updates; use Piwik\Common; -use Piwik\Db; use Piwik\Option; use Piwik\Updater; use Piwik\Updates; @@ -61,6 +60,5 @@ public static function update() \Piwik\Plugin\Manager::getInstance()->activatePlugin('ScheduledReports'); } catch (\Exception $e) { } - } } diff --git a/core/Updates/2.0-a17.php b/core/Updates/2.0-a17.php index 5d651435962..38090f9a60c 100644 --- a/core/Updates/2.0-a17.php +++ b/core/Updates/2.0-a17.php @@ -8,7 +8,6 @@ */ namespace Piwik\Updates; -use Piwik\Db; use Piwik\Filesystem; use Piwik\Updates; @@ -33,10 +32,9 @@ public static function update() if (file_exists($dir)) { $errors[] = "Please delete this directory manually (eg. using your FTP software): $dir \n"; } - } if (!empty($errors)) { throw new \Exception("Warnings during the update:
    " . implode("
    ", $errors)); } - } + } } diff --git a/core/Updates/2.0-a7.php b/core/Updates/2.0-a7.php index 9898d80a895..d2bf8703ed7 100644 --- a/core/Updates/2.0-a7.php +++ b/core/Updates/2.0-a7.php @@ -17,7 +17,7 @@ */ class Updates_2_0_a7 extends Updates { - static function getSql() + public static function getSql() { return array( // ignore existing column name error (1060) @@ -29,7 +29,7 @@ static function getSql() ); } - static function update() + public static function update() { // add tag & level columns to logger_message table Updater::updateDatabase(__FILE__, self::getSql()); diff --git a/core/Updates/2.0-b10.php b/core/Updates/2.0-b10.php index 0a2152ed4a0..ef6dcba9199 100644 --- a/core/Updates/2.0-b10.php +++ b/core/Updates/2.0-b10.php @@ -15,7 +15,7 @@ */ class Updates_2_0_b10 extends Updates { - static function update() + public static function update() { parent::deletePluginFromConfigFile('Referers'); parent::deletePluginFromConfigFile('PDFReports'); diff --git a/core/Updates/2.0-b13.php b/core/Updates/2.0-b13.php index a5e9546b906..a9b7a1618b9 100644 --- a/core/Updates/2.0-b13.php +++ b/core/Updates/2.0-b13.php @@ -33,10 +33,9 @@ public static function update() if (file_exists($dir)) { $errors[] = "Please delete this directory manually (eg. using your FTP software): $dir \n"; } - } if (!empty($errors)) { throw new \Exception("Warnings during the update:
    " . implode("
    ", $errors)); } - } + } } diff --git a/core/Updates/2.0-b3.php b/core/Updates/2.0-b3.php index b4dcdf25dbf..f24c514d7ac 100644 --- a/core/Updates/2.0-b3.php +++ b/core/Updates/2.0-b3.php @@ -17,12 +17,12 @@ */ class Updates_2_0_b3 extends Updates { - static function isMajorUpdate() + public static function isMajorUpdate() { return true; } - static function getSql() + public static function getSql() { return array( 'ALTER TABLE ' . Common::prefixTable('log_visit') @@ -34,7 +34,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); diff --git a/core/Updates/2.0-b9.php b/core/Updates/2.0-b9.php index 59819890ca8..568358235f8 100644 --- a/core/Updates/2.0-b9.php +++ b/core/Updates/2.0-b9.php @@ -18,7 +18,7 @@ */ class Updates_2_0_b9 extends Updates { - static function getSql() + public static function getSql() { return array( "ALTER TABLE `" . Common::prefixTable('site') @@ -26,7 +26,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/2.0-rc1.php b/core/Updates/2.0-rc1.php index 64baac6e6d9..dc3f0dbb9c8 100644 --- a/core/Updates/2.0-rc1.php +++ b/core/Updates/2.0-rc1.php @@ -18,7 +18,7 @@ public static function update() { try { \Piwik\Plugin\Manager::getInstance()->activatePlugin('Morpheus'); - } catch(\Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/2.0.3-b7.php b/core/Updates/2.0.3-b7.php index 9903d999c15..779427db55b 100644 --- a/core/Updates/2.0.3-b7.php +++ b/core/Updates/2.0.3-b7.php @@ -18,7 +18,7 @@ */ class Updates_2_0_3_b7 extends Updates { - static function update() + public static function update() { $errors = array(); @@ -43,8 +43,7 @@ static function update() foreach ($oldPlugins as $plugin) { try { \Piwik\Plugin\Manager::getInstance()->deactivatePlugin($plugin); - } catch(\Exception $e) { - + } catch (\Exception $e) { } $dir = PIWIK_INCLUDE_PATH . "/plugins/$plugin"; @@ -56,7 +55,6 @@ static function update() if (file_exists($dir)) { $errors[] = "Please delete this directory manually (eg. using your FTP software): $dir \n"; } - } if (!empty($errors)) { throw new \Exception("Warnings during the update:
    " . implode("
    ", $errors)); diff --git a/core/Updates/2.0.4-b5.php b/core/Updates/2.0.4-b5.php index 94e6a6529d0..c9d5f927180 100644 --- a/core/Updates/2.0.4-b5.php +++ b/core/Updates/2.0.4-b5.php @@ -22,7 +22,7 @@ */ class Updates_2_0_4_b5 extends Updates { - static function getSql() + public static function getSql() { return array( // ignore existing column name error (1060) @@ -31,7 +31,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); @@ -78,7 +78,7 @@ private static function migrateConfigSuperUserToDb() 'superuser_access' => 1 ) ); - } catch(\Exception $e) { + } catch (\Exception $e) { echo "There was an issue, but we proceed: " . $e->getMessage(); } diff --git a/core/Updates/2.0.4-b7.php b/core/Updates/2.0.4-b7.php index 512180fec9f..319b3bea30c 100644 --- a/core/Updates/2.0.4-b7.php +++ b/core/Updates/2.0.4-b7.php @@ -9,7 +9,6 @@ namespace Piwik\Updates; -use Piwik\Db; use Piwik\Option; use Piwik\Plugins\MobileMessaging\MobileMessaging; use Piwik\Plugins\UsersManager\API as UsersManagerApi; @@ -20,12 +19,12 @@ */ class Updates_2_0_4_b7 extends Updates { - static function getSql() + public static function getSql() { return array(); } - static function update() + public static function update() { try { self::migrateExistingMobileMessagingOptions(); diff --git a/core/Updates/2.0.4-b8.php b/core/Updates/2.0.4-b8.php index 0e8b56c4121..f31927a047d 100644 --- a/core/Updates/2.0.4-b8.php +++ b/core/Updates/2.0.4-b8.php @@ -10,7 +10,6 @@ namespace Piwik\Updates; use Piwik\Config; -use Piwik\Db; use Piwik\Plugins\CoreAdminHome\CustomLogo; use Piwik\Plugins\PrivacyManager\Config as PrivacyManagerConfig; use Piwik\UpdaterErrorException; @@ -20,12 +19,12 @@ */ class Updates_2_0_4_b8 extends Updates { - static function getSql() + public static function getSql() { return array(); } - static function update() + public static function update() { try { $config = Config::getInstance(); @@ -34,7 +33,6 @@ static function update() self::migratePrivacyManagerConfig($config, new PrivacyManagerConfig()); $config->forceSave(); - } catch (\Exception $e) { throw new UpdaterErrorException($e->getMessage()); } diff --git a/core/Updates/2.1.1-b11.php b/core/Updates/2.1.1-b11.php index 3fa0364e73d..ad05de0888d 100644 --- a/core/Updates/2.1.1-b11.php +++ b/core/Updates/2.1.1-b11.php @@ -21,7 +21,7 @@ */ class Updates_2_1_1_b11 extends Updates { - static function update() + public static function update() { $returningMetrics = array( 'nb_visits_returning', diff --git a/core/Updates/2.10.0-b10.php b/core/Updates/2.10.0-b10.php index 3628719ccdb..41139073a1d 100644 --- a/core/Updates/2.10.0-b10.php +++ b/core/Updates/2.10.0-b10.php @@ -16,34 +16,32 @@ class Updates_2_10_0_b10 extends Updates { - static function getSql() + public static function getSql() { $sqls = array(); $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled(); - $archiveBlobTables = array_filter($archiveTables, function($name) { + $archiveBlobTables = array_filter($archiveTables, function ($name) { return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE; }); foreach ($archiveBlobTables as $table) { - $sqls["UPDATE " . $table . " SET name = 'DevicePlugins_plugin' WHERE name = 'UserSettings_plugin'"] = false; } return $sqls; } - static function update() + public static function update() { $pluginManager = \Piwik\Plugin\Manager::getInstance(); try { $pluginManager->activatePlugin('DevicePlugins'); - } catch(\Exception $e) { + } catch (\Exception $e) { } Updater::updateDatabase(__FILE__, self::getSql()); } - } diff --git a/core/Updates/2.10.0-b4.php b/core/Updates/2.10.0-b4.php index 88cbaf4df44..fd3c7c5cf16 100644 --- a/core/Updates/2.10.0-b4.php +++ b/core/Updates/2.10.0-b4.php @@ -17,13 +17,13 @@ class Updates_2_10_0_b4 extends Updates { - static function update() + public static function update() { $pluginManager = \Piwik\Plugin\Manager::getInstance(); try { $pluginManager->activatePlugin('BulkTracking'); - } catch(\Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/2.10.0-b5.php b/core/Updates/2.10.0-b5.php index 51663a9d0a2..e7ae8f74a5f 100644 --- a/core/Updates/2.10.0-b5.php +++ b/core/Updates/2.10.0-b5.php @@ -15,8 +15,7 @@ use Piwik\Db; use Piwik\Updater; use Piwik\Updates; -use DeviceDetector\Parser\Client\Browser AS BrowserParser; -use Piwik\Plugins\Dashboard\Model AS DashboardModel; +use Piwik\Plugins\Dashboard\Model as DashboardModel; /** * This Update script will update all browser and os archives of UserSettings and DevicesDetection plugin @@ -44,7 +43,7 @@ class Updates_2_10_0_b5 extends Updates { public static $archiveBlobTables; - static function getSql() + public static function getSql() { $sqls = array('# ATTENTION: This update script will execute some more SQL queries than that below as it is necessary to rebuilt some archives #' => false); @@ -86,8 +85,7 @@ static function getSql() $allDashboards = Db::get()->fetchAll(sprintf("SELECT * FROM %s", Common::prefixTable('user_dashboard'))); - foreach($allDashboards AS $dashboard) { - + foreach ($allDashboards as $dashboard) { $dashboardLayout = json_decode($dashboard['layout']); $dashboardLayout = DashboardModel::replaceDashboardWidgets($dashboardLayout, $oldWidgets, $newWidgets); @@ -101,7 +99,7 @@ static function getSql() return $sqls; } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); @@ -124,7 +122,7 @@ public static function getAllArchiveBlobTables() if (empty(self::$archiveBlobTables)) { $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled(); - self::$archiveBlobTables = array_filter($archiveTables, function($name) { + self::$archiveBlobTables = array_filter($archiveTables, function ($name) { return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE; }); @@ -145,7 +143,6 @@ public static function getFirstDayOfArchivedDeviceDetectorData() static $deviceDetectionBlobAvailableDate; if (empty($deviceDetectionBlobAvailableDate)) { - $archiveBlobTables = self::getAllArchiveBlobTables(); $deviceDetectionBlobAvailableDate = null; @@ -157,7 +154,6 @@ public static function getFirstDayOfArchivedDeviceDetectorData() if (!empty($deviceDetectionBlobAvailableDate)) { break; } - } $deviceDetectionBlobAvailableDate = strtotime($deviceDetectionBlobAvailableDate); @@ -185,14 +181,14 @@ public static function updateBrowserArchives($table) // if start date of blob is before calculated date us old usersettings archive instead of already existing DevicesDetection archive if (strtotime($blob['date1']) < self::getFirstDayOfArchivedDeviceDetectorData()) { - Db::get()->query(sprintf("DELETE FROM %s WHERE idarchive = ? AND name = ?", $table), array($blob['idarchive'], 'DevicesDetection_browserVersions')); Db::get()->query(sprintf("UPDATE %s SET name = ? WHERE idarchive = ? AND name = ?", $table), array('DevicesDetection_browserVersions', $blob['idarchive'], 'UserSettings_browser')); } } } - public static function updateOsArchives($table) { + public static function updateOsArchives($table) + { Db::exec(sprintf("UPDATE IGNORE %s SET name='DevicesDetection_osVersions' WHERE name = 'UserSettings_os'", $table)); /* @@ -204,7 +200,6 @@ public static function updateOsArchives($table) { // if start date of blob is before calculated date us old usersettings archive instead of already existing DevicesDetection archive if (strtotime($blob['date1']) < self::getFirstDayOfArchivedDeviceDetectorData()) { - Db::get()->query(sprintf("DELETE FROM %s WHERE idarchive = ? AND name = ?", $table), array($blob['idarchive'], 'DevicesDetection_osVersions')); Db::get()->query(sprintf("UPDATE %s SET name = ? WHERE idarchive = ? AND name = ?", $table), array('DevicesDetection_osVersions', $blob['idarchive'], 'UserSettings_os')); } diff --git a/core/Updates/2.10.0-b7.php b/core/Updates/2.10.0-b7.php index a44117fc811..b385e41d229 100644 --- a/core/Updates/2.10.0-b7.php +++ b/core/Updates/2.10.0-b7.php @@ -16,18 +16,17 @@ class Updates_2_10_0_b7 extends Updates { - static function getSql() + public static function getSql() { $sqls = array(); $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled(); - $archiveBlobTables = array_filter($archiveTables, function($name) { + $archiveBlobTables = array_filter($archiveTables, function ($name) { return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE; }); foreach ($archiveBlobTables as $table) { - $sqls["UPDATE " . $table . " SET name = 'Resolution_resolution' WHERE name = 'UserSettings_resolution'"] = false; $sqls["UPDATE " . $table . " SET name = 'Resolution_configuration' WHERE name = 'UserSettings_configuration'"] = false; } @@ -35,9 +34,8 @@ static function getSql() return $sqls; } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } - } diff --git a/core/Updates/2.10.0-b8.php b/core/Updates/2.10.0-b8.php index 17705f81435..03bd866f827 100644 --- a/core/Updates/2.10.0-b8.php +++ b/core/Updates/2.10.0-b8.php @@ -13,14 +13,13 @@ class Updates_2_10_0_b8 extends Updates { - static function update() + public static function update() { $pluginManager = \Piwik\Plugin\Manager::getInstance(); try { $pluginManager->activatePlugin('Resolution'); - } catch(\Exception $e) { + } catch (\Exception $e) { } } - } diff --git a/core/Updates/2.11.0-b2.php b/core/Updates/2.11.0-b2.php index ce0c7b25335..372256fdf3e 100644 --- a/core/Updates/2.11.0-b2.php +++ b/core/Updates/2.11.0-b2.php @@ -13,7 +13,7 @@ use Piwik\Piwik; use Piwik\Updater; use Piwik\Updates; -use Piwik\Plugins\Dashboard\Model AS DashboardModel; +use Piwik\Plugins\Dashboard\Model as DashboardModel; /** * Update for version 2.11.0-b2. @@ -21,7 +21,7 @@ class Updates_2_11_0_b2 extends Updates { - static function getSql() + public static function getSql() { $sqls = array(); @@ -38,8 +38,7 @@ static function getSql() $allDashboards = Db::get()->fetchAll(sprintf("SELECT * FROM %s", Common::prefixTable('user_dashboard'))); - foreach($allDashboards AS $dashboard) { - + foreach ($allDashboards as $dashboard) { $dashboardLayout = json_decode($dashboard['layout']); $dashboardLayout = DashboardModel::replaceDashboardWidgets($dashboardLayout, $oldWidgets, $newWidgets); @@ -52,13 +51,13 @@ static function getSql() return $sqls; } - static function update() + public static function update() { $pluginManager = \Piwik\Plugin\Manager::getInstance(); try { $pluginManager->activatePlugin('Ecommerce'); - } catch(\Exception $e) { + } catch (\Exception $e) { } Updater::updateDatabase(__FILE__, self::getSql()); diff --git a/core/Updates/2.11.0-b4.php b/core/Updates/2.11.0-b4.php index 00dc1b23eec..2f7c10cdab3 100644 --- a/core/Updates/2.11.0-b4.php +++ b/core/Updates/2.11.0-b4.php @@ -16,34 +16,32 @@ class Updates_2_11_0_b4 extends Updates { - static function getSql() + public static function getSql() { $sqls = array(); $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled(); - $archiveBlobTables = array_filter($archiveTables, function($name) { + $archiveBlobTables = array_filter($archiveTables, function ($name) { return ArchiveTableCreator::getTypeFromTableName($name) == ArchiveTableCreator::BLOB_TABLE; }); foreach ($archiveBlobTables as $table) { - $sqls["UPDATE " . $table . " SET name = 'UserLanguage_language' WHERE name = 'UserSettings_language'"] = false; } return $sqls; } - static function update() + public static function update() { $pluginManager = \Piwik\Plugin\Manager::getInstance(); try { $pluginManager->activatePlugin('UserLanguage'); - } catch(\Exception $e) { + } catch (\Exception $e) { } Updater::updateDatabase(__FILE__, self::getSql()); } - } diff --git a/core/Updates/2.11.0-b5.php b/core/Updates/2.11.0-b5.php index 1a75fd9f88a..5b3ebccb51c 100644 --- a/core/Updates/2.11.0-b5.php +++ b/core/Updates/2.11.0-b5.php @@ -13,7 +13,7 @@ class Updates_2_11_0_b5 extends Updates { - static function update() + public static function update() { try { Manager::getInstance()->activatePlugin('Monolog'); diff --git a/core/Updates/2.11.1-b4.php b/core/Updates/2.11.1-b4.php index 7777f10f891..a4c7bb149cd 100644 --- a/core/Updates/2.11.1-b4.php +++ b/core/Updates/2.11.1-b4.php @@ -19,7 +19,7 @@ class Updates_2_11_1_b4 extends Updates * Here you can define any action that should be performed during the update. For instance executing SQL statements, * renaming config entries, updating files, etc. */ - static function update() + public static function update() { if (!Development::isEnabled()) { return; diff --git a/core/Updates/2.13.0-b3.php b/core/Updates/2.13.0-b3.php index 3d6cd83cea7..f0950c64227 100644 --- a/core/Updates/2.13.0-b3.php +++ b/core/Updates/2.13.0-b3.php @@ -9,7 +9,6 @@ namespace Piwik\Updates; -use Piwik\Config; use Piwik\Updater; use Piwik\Updates; @@ -21,7 +20,7 @@ public function doUpdate(Updater $updater) try { $pluginManager->activatePlugin('Diagnostics'); - } catch(\Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/2.13.1.php b/core/Updates/2.13.1.php index 8cb01ad22c0..32650b05b18 100644 --- a/core/Updates/2.13.1.php +++ b/core/Updates/2.13.1.php @@ -22,7 +22,7 @@ class Updates_2_13_1 extends Updates * Here you can define one or multiple SQL statements that should be executed during the update. * @return array */ - static function getSql() + public static function getSql() { $optionTable = Common::prefixTable('option'); $removeEmptyDefaultReportsSql = "delete from `$optionTable` where option_name like '%defaultReport%' and option_value=''"; @@ -36,7 +36,7 @@ static function getSql() * Here you can define any action that should be performed during the update. For instance executing SQL statements, * renaming config entries, updating files, etc. */ - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/2.14.0-b1.php b/core/Updates/2.14.0-b1.php index 6d6d7ff5299..e414bc3af8e 100644 --- a/core/Updates/2.14.0-b1.php +++ b/core/Updates/2.14.0-b1.php @@ -9,7 +9,6 @@ namespace Piwik\Updates; -use Piwik\Config; use Piwik\Updater; use Piwik\Updates; use Piwik\Plugin\Manager; @@ -26,14 +25,12 @@ private function uninstallPlugin($plugin) $pluginManager = Manager::getInstance(); if ($pluginManager->isPluginInstalled($plugin)) { - if ($pluginManager->isPluginActivated($plugin)) { $pluginManager->deactivatePlugin($plugin); } $pluginManager->unloadPlugin($plugin); $pluginManager->uninstallPlugin($plugin); - } else { $this->makeSurePluginIsRemovedFromFilesystem($plugin); } diff --git a/core/Updates/2.2.0-b15.php b/core/Updates/2.2.0-b15.php index d35e6a1ff8a..1a03a1ccd10 100644 --- a/core/Updates/2.2.0-b15.php +++ b/core/Updates/2.2.0-b15.php @@ -7,14 +7,13 @@ */ namespace Piwik\Updates; -use Piwik\Db; use Piwik\Updates; /** */ class Updates_2_2_0_b15 extends Updates { - static function update() + public static function update() { // This was added in the beta cycle and then removed // if the file is there, it can cause bugs (we don't have an archiver in VisitFrequency anymore) diff --git a/core/Updates/2.2.3-b6.php b/core/Updates/2.2.3-b6.php index 0b9d15e4f11..cb2c094e150 100644 --- a/core/Updates/2.2.3-b6.php +++ b/core/Updates/2.2.3-b6.php @@ -18,7 +18,7 @@ public static function update() { try { \Piwik\Plugin\Manager::getInstance()->activatePlugin('ZenMode'); - } catch(\Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/2.3.0-rc2.php b/core/Updates/2.3.0-rc2.php index 052a314a867..3d7488f9163 100644 --- a/core/Updates/2.3.0-rc2.php +++ b/core/Updates/2.3.0-rc2.php @@ -21,5 +21,4 @@ public static function update() ServerFilesGenerator::createHtAccessFiles(); } - } diff --git a/core/Updates/2.4.0-b1.php b/core/Updates/2.4.0-b1.php index cc0d615d543..ab73d614bc5 100644 --- a/core/Updates/2.4.0-b1.php +++ b/core/Updates/2.4.0-b1.php @@ -16,13 +16,13 @@ public static function update() { try { \Piwik\Plugin\Manager::getInstance()->activatePlugin('Morpheus'); - } catch(\Exception $e) { + } catch (\Exception $e) { } try { \Piwik\Plugin\Manager::getInstance()->deactivatePlugin('Zeitgeist'); self::deletePluginFromConfigFile('Zeitgeist'); - } catch(\Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/2.4.0-b3.php b/core/Updates/2.4.0-b3.php index 693cfd7ca0f..1a166c4ab26 100644 --- a/core/Updates/2.4.0-b3.php +++ b/core/Updates/2.4.0-b3.php @@ -18,17 +18,17 @@ public static function update() try { $pluginManager->activatePlugin('LeftMenu'); - } catch(\Exception $e) { + } catch (\Exception $e) { } try { $pluginManager->deactivatePlugin('Zeitgeist'); - } catch(\Exception $e) { + } catch (\Exception $e) { } try { $pluginManager->uninstallPlugin('Zeitgeist'); - } catch(\Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/2.4.0-b4.php b/core/Updates/2.4.0-b4.php index ad54fe8343b..7cd2288f075 100644 --- a/core/Updates/2.4.0-b4.php +++ b/core/Updates/2.4.0-b4.php @@ -23,12 +23,12 @@ public static function update() try { $pluginManager->deactivatePlugin('Zeitgeist'); - } catch(\Exception $e) { + } catch (\Exception $e) { } try { $pluginManager->uninstallPlugin('Zeitgeist'); - } catch(\Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/2.4.0-b6.php b/core/Updates/2.4.0-b6.php index 62ab76c46e6..192ace4bafc 100644 --- a/core/Updates/2.4.0-b6.php +++ b/core/Updates/2.4.0-b6.php @@ -18,7 +18,7 @@ public static function update() try { $pluginManager->activatePlugin('DevicesDetection'); - } catch(\Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/2.4.0-b8.php b/core/Updates/2.4.0-b8.php index 4df50ee0cee..04eaf72334d 100644 --- a/core/Updates/2.4.0-b8.php +++ b/core/Updates/2.4.0-b8.php @@ -14,7 +14,7 @@ class Updates_2_4_0_b8 extends Updates { - static function getSql() + public static function getSql() { return array( "ALTER TABLE `" . Common::prefixTable('session') @@ -22,7 +22,7 @@ static function getSql() ); } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } diff --git a/core/Updates/2.5.0-b1.php b/core/Updates/2.5.0-b1.php index 54c0e6e0268..b29be3dafd0 100644 --- a/core/Updates/2.5.0-b1.php +++ b/core/Updates/2.5.0-b1.php @@ -33,5 +33,4 @@ private static function updateConfig() $config->forceSave(); } } - } diff --git a/core/Updates/2.5.0-rc2.php b/core/Updates/2.5.0-rc2.php index e1c55840e90..5140984ff01 100644 --- a/core/Updates/2.5.0-rc2.php +++ b/core/Updates/2.5.0-rc2.php @@ -18,7 +18,7 @@ class Updates_2_5_0_rc2 extends Updates { - static function update() + public static function update() { $files = self::getFilesToDeleteIfOld(); diff --git a/core/Updates/2.5.0-rc4.php b/core/Updates/2.5.0-rc4.php index a6485941cbc..d847ab98c52 100644 --- a/core/Updates/2.5.0-rc4.php +++ b/core/Updates/2.5.0-rc4.php @@ -19,7 +19,7 @@ class Updates_2_5_0_rc4 extends Updates { - static function update() + public static function update() { Cache::deleteTrackerCache(); Filesystem::clearPhpCaches(); diff --git a/core/Updates/2.6.0-b1.php b/core/Updates/2.6.0-b1.php index 5819ca95f90..0f0f7b42d09 100644 --- a/core/Updates/2.6.0-b1.php +++ b/core/Updates/2.6.0-b1.php @@ -21,7 +21,7 @@ class Updates_2_6_0_b1 extends Updates * Here you can define any action that should be performed during the update. For instance executing SQL statements, * renaming config entries, updating files, etc. */ - static function update() + public static function update() { $config = Config::getInstance(); $config->Plugins_Tracker = array(); diff --git a/core/Updates/2.7.0-b2.php b/core/Updates/2.7.0-b2.php index 2951dae6537..277fcdd1d07 100644 --- a/core/Updates/2.7.0-b2.php +++ b/core/Updates/2.7.0-b2.php @@ -15,14 +15,13 @@ */ class Updates_2_7_0_b2 extends Updates { - static function update() + public static function update() { $pluginManager = \Piwik\Plugin\Manager::getInstance(); try { $pluginManager->activatePlugin('Contents'); - } catch(\Exception $e) { + } catch (\Exception $e) { } } } - diff --git a/core/Updates/2.7.0-b4.php b/core/Updates/2.7.0-b4.php index 92f7ff1c710..0d4714ad4e3 100644 --- a/core/Updates/2.7.0-b4.php +++ b/core/Updates/2.7.0-b4.php @@ -15,19 +15,18 @@ */ class Updates_2_7_0_b4 extends Updates { - static function update() + public static function update() { $pluginManager = \Piwik\Plugin\Manager::getInstance(); try { $pluginManager->activatePlugin('Contents'); - } catch(\Exception $e) { + } catch (\Exception $e) { } } - static function isMajorUpdate() + public static function isMajorUpdate() { return true; } } - diff --git a/core/Updates/2.9.0-b1.php b/core/Updates/2.9.0-b1.php index 5720bf076e8..8c2333d857d 100644 --- a/core/Updates/2.9.0-b1.php +++ b/core/Updates/2.9.0-b1.php @@ -17,7 +17,7 @@ class Updates_2_9_0_b1 extends Updates { - static function getSql() + public static function getSql() { $sql = array(); $sql = self::updateBrowserEngine($sql); @@ -25,7 +25,7 @@ static function getSql() return $sql; } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); @@ -34,7 +34,6 @@ static function update() try { Manager::getInstance()->activatePlugin('TestRunner'); } catch (\Exception $e) { - } } @@ -54,8 +53,7 @@ private static function updateBrowserEngine($sql) $engineUpdate = "''"; $ifFragment = "IF (`config_browser_name` IN ('%s'), '%s', %s)"; - foreach ($browserEngineMatch AS $engine => $browsers) { - + foreach ($browserEngineMatch as $engine => $browsers) { $engineUpdate = sprintf($ifFragment, implode("','", $browsers), $engine, $engineUpdate); } diff --git a/core/Updates/2.9.0-b7.php b/core/Updates/2.9.0-b7.php index 110545aaa80..6eeccd71f58 100644 --- a/core/Updates/2.9.0-b7.php +++ b/core/Updates/2.9.0-b7.php @@ -16,7 +16,7 @@ class Updates_2_9_0_b7 extends Updates { - static function getSql() + public static function getSql() { $sql = array(); $sql = self::addCreateSequenceTableQuery($sql); @@ -25,7 +25,7 @@ static function getSql() return $sql; } - static function update() + public static function update() { Updater::updateDatabase(__FILE__, self::getSql()); } @@ -87,5 +87,4 @@ private static function getSequenceTableName() { return Common::prefixTable('sequence'); } - } diff --git a/core/Url.php b/core/Url.php index 04131c9827a..6db8ed7ee5b 100644 --- a/core/Url.php +++ b/core/Url.php @@ -9,9 +9,7 @@ namespace Piwik; use Exception; - use Piwik\Network\IPUtils; -use Piwik\Session; /** * Provides URL related helper methods. @@ -217,8 +215,9 @@ public static function isValidHost($host = false) if ($host === false) { $host = @$_SERVER['HTTP_HOST']; - if (empty($host)) // if no current host, assume valid - { + if (empty($host)) { + // if no current host, assume valid + return true; } } @@ -406,7 +405,7 @@ public static function getArrayFromCurrentQueryString() * @return string eg, `"?param2=value2¶m3=value3"` * @api */ - static function getCurrentQueryStringWithParametersModified($params) + public static function getCurrentQueryStringWithParametersModified($params) { $urlValues = self::getArrayFromCurrentQueryString(); foreach ($params as $key => $value) { diff --git a/core/UrlHelper.php b/core/UrlHelper.php index bcea3c979fb..3a550c8eb30 100644 --- a/core/UrlHelper.php +++ b/core/UrlHelper.php @@ -45,7 +45,7 @@ public static function getQueryStringWithExcludedParameters($queryParameters, $p $validQuery .= $name . '[]=' . $param . $separator; } } - } else if ($value === false) { + } elseif ($value === false) { $validQuery .= $name . $separator; } else { $validQuery .= $name . '=' . $value . $separator; @@ -207,7 +207,7 @@ public static function getArrayFromQueryString($urlQuery) $nameToValue[$name] = array(); } array_push($nameToValue[$name], $value); - } else if (!empty($name)) { + } elseif (!empty($name)) { $nameToValue[$name] = $value; } } @@ -365,7 +365,7 @@ public static function extractSearchEngineInformationFromUrl($referrerUrl) $query = str_replace('&', '&', strstr($query, '?')); } $searchEngineName = 'Google Images'; - } else if ($searchEngineName === 'Google' + } elseif ($searchEngineName === 'Google' && (strpos($query, '&as_') !== false || strpos($query, 'as_') === 0) ) { $keys = array(); diff --git a/core/Version.php b/core/Version.php index 4060011f1f1..da0b9751b0f 100644 --- a/core/Version.php +++ b/core/Version.php @@ -36,5 +36,4 @@ private function isNonStableVersion($version) { return (bool) preg_match('/^(\d+)\.(\d+)\.(\d+)-.{1,4}(\d+)$/', $version); } - } diff --git a/core/View.php b/core/View.php index 08c65695b91..fc1c1e0a112 100644 --- a/core/View.php +++ b/core/View.php @@ -365,7 +365,7 @@ public function assign($var, $value = null) * @ignore */ public static function clearCompiledTemplates() - { + { $twig = new Twig(); $environment = $twig->getTwigEnvironment(); $environment->clearTemplateCache(); diff --git a/core/View/RenderTokenParser.php b/core/View/RenderTokenParser.php index 2800beab8b3..bac31e01ca9 100644 --- a/core/View/RenderTokenParser.php +++ b/core/View/RenderTokenParser.php @@ -79,4 +79,4 @@ public function getTag() { return 'render'; } -} \ No newline at end of file +} diff --git a/core/View/UIControl.php b/core/View/UIControl.php index 6bbb1e0b1d6..845d0f9d6ae 100644 --- a/core/View/UIControl.php +++ b/core/View/UIControl.php @@ -168,4 +168,4 @@ public function getClientSideParameters() { return array(); } -} \ No newline at end of file +} diff --git a/core/View/ViewInterface.php b/core/View/ViewInterface.php index 9c8d01ee0cc..de3115c3769 100644 --- a/core/View/ViewInterface.php +++ b/core/View/ViewInterface.php @@ -21,5 +21,5 @@ interface ViewInterface * * @return string Serialized data, eg, (image, array, html...). */ - function render(); + public function render(); } diff --git a/core/ViewDataTable/Config.php b/core/ViewDataTable/Config.php index f4eef3c639a..8e4e59586b6 100644 --- a/core/ViewDataTable/Config.php +++ b/core/ViewDataTable/Config.php @@ -8,6 +8,7 @@ */ namespace Piwik\ViewDataTable; + use Piwik\API\Request as ApiRequest; use Piwik\DataTable; use Piwik\DataTable\Filter\PivotByDimension; diff --git a/core/ViewDataTable/Request.php b/core/ViewDataTable/Request.php index 6bca3430686..8eff0811795 100644 --- a/core/ViewDataTable/Request.php +++ b/core/ViewDataTable/Request.php @@ -142,5 +142,4 @@ protected function getDefault($nameVar) return false; } - } diff --git a/core/ViewDataTable/RequestConfig.php b/core/ViewDataTable/RequestConfig.php index a6c9b7bed80..2c6e364d1db 100644 --- a/core/ViewDataTable/RequestConfig.php +++ b/core/ViewDataTable/RequestConfig.php @@ -8,7 +8,7 @@ */ namespace Piwik\ViewDataTable; -use Piwik\Common; + /** * Contains base request properties for {@link Piwik\Plugin\ViewDataTable} instances. Manipulating diff --git a/core/dispatch.php b/core/dispatch.php index fd05aac2b50..53d0b8b3b32 100644 --- a/core/dispatch.php +++ b/core/dispatch.php @@ -39,4 +39,4 @@ } catch (Exception $ex) { ExceptionHandler::dieWithHtmlErrorPage($ex); } -} \ No newline at end of file +} diff --git a/core/testMinimumPhpVersion.php b/core/testMinimumPhpVersion.php index eb1ee157eec..6bbe380ffb7 100644 --- a/core/testMinimumPhpVersion.php +++ b/core/testMinimumPhpVersion.php @@ -100,7 +100,7 @@ function Piwik_GetErrorMessagePage($message, $optionalTrace = false, $optionalLi header('Content-Type: text/html; charset=utf-8'); $isInternalServerError = preg_match('/(sql|database|mysql)/i', $message); - if($isInternalServerError) { + if ($isInternalServerError) { header('HTTP/1.1 500 Internal Server Error'); } }