diff options
38 files changed, 67 insertions, 54 deletions
diff --git a/core/Db.php b/core/Db.php index cb9224c76c..d795a9b3f6 100644 --- a/core/Db.php +++ b/core/Db.php @@ -73,7 +73,8 @@ class Db * The return result is DBMS-specific. For MySQLI, it returns the number of rows affected. For PDO, it returns the Zend_Db_Statement object * If you want to fetch data from the DB you should use the function Db::fetchAll() * - * @param string $sql SQL Query + * @param string $sql SQL Query + * @throws \Exception * @return integer|\Zend_Db_Statement */ static public function exec($sql) @@ -100,8 +101,9 @@ class Db * * See also http://framework.zend.com/manual/en/zend.db.statement.html * - * @param string $sql SQL Query - * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) + * @param string $sql SQL Query + * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) + * @throws \Exception * @return \Zend_Db_Statement */ static public function query($sql, $parameters = array()) @@ -117,8 +119,9 @@ class Db /** * Executes the SQL Query and fetches all the rows from the database query * - * @param string $sql SQL Query - * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) + * @param string $sql SQL Query + * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) + * @throws \Exception * @return array (one row in the array per row fetched in the DB) */ static public function fetchAll($sql, $parameters = array()) @@ -137,6 +140,7 @@ class Db * @param string $sql SQL Query * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @return array + * @throws \Exception */ static public function fetchRow($sql, $parameters = array()) { @@ -154,6 +158,7 @@ class Db * @param string $sql SQL Query * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @return string + * @throws \Exception */ static public function fetchOne($sql, $parameters = array()) { @@ -171,6 +176,7 @@ class Db * @param string $sql SQL query * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @return array + * @throws \Exception */ static public function fetchAssoc($sql, $parameters = array()) { diff --git a/core/Filesystem.php b/core/Filesystem.php index 8dc797d00a..feb02fd0b0 100644 --- a/core/Filesystem.php +++ b/core/Filesystem.php @@ -197,7 +197,7 @@ class Filesystem * * @param string $dir Directory name * @param boolean $deleteRootToo Delete specified top-level directory as well - * @param Closure|false $beforeUnlink A closure to execute before unlinking. + * @param \Closure|false $beforeUnlink A closure to execute before unlinking. */ public static function unlinkRecursive($dir, $deleteRootToo, \Closure $beforeUnlink = null) { diff --git a/core/Menu/Admin.php b/core/Menu/Admin.php index 67b9187d8c..38b0cb1bb1 100644 --- a/core/Menu/Admin.php +++ b/core/Menu/Admin.php @@ -10,7 +10,7 @@ */ namespace Piwik\Menu; -use Piwik\Menu\MenuAbstract; + use Piwik\Piwik; /** diff --git a/core/Updater.php b/core/Updater.php index 971a00847e..6d431910b8 100644 --- a/core/Updater.php +++ b/core/Updater.php @@ -113,6 +113,7 @@ class Updater * Returns the list of SQL queries that would be executed during the update * * @return array of SQL queries + * @throws \Exception */ public function getSqlQueriesToExecute() { diff --git a/core/Updates/0.4.4.php b/core/Updates/0.4.4.php index 80f03d4ec5..ad70569c71 100644 --- a/core/Updates/0.4.4.php +++ b/core/Updates/0.4.4.php @@ -24,7 +24,7 @@ class Updates_0_4_4 extends Updates if (file_exists($obsoleteFile)) { $rc = @unlink($obsoleteFile); if (!$rc) { - throw new Exception(Piwik_TranslateException('General_ExceptionUndeletableFile', array($obsoleteFile))); + throw new \Exception(Piwik_TranslateException('General_ExceptionUndeletableFile', array($obsoleteFile))); } } } diff --git a/core/Updates/0.5.4.php b/core/Updates/0.5.4.php index f041a10732..a386e4b306 100644 --- a/core/Updates/0.5.4.php +++ b/core/Updates/0.5.4.php @@ -41,9 +41,9 @@ class Updates_0_5_4 extends Updates $config->superuser = $superuser; $config->forceSave(); } else { - throw new Exception('mandatory update failed'); + throw new \Exception('mandatory update failed'); } - } catch (Exception $e) { + } catch (\Exception $e) { throw new \Piwik\Updater_UpdateErrorException("Please edit your config/config.ini.php file and add below <code>[superuser]</code> the following line: <br /><code>salt = $salt</code>"); } } @@ -56,10 +56,10 @@ class Updates_0_5_4 extends Updates $config->Plugins = $plugins; $config->forceSave(); } else { - throw new Exception('optional update failed'); + throw new \Exception('optional update failed'); } - } catch (Exception $e) { - throw new Exception("You can now enable the new MultiSites plugin in the Plugins screen in the Piwik admin!"); + } catch (\Exception $e) { + throw new \Exception("You can now enable the new MultiSites plugin in the Plugins screen in the Piwik admin!"); } } diff --git a/core/Updates/0.6-rc1.php b/core/Updates/0.6-rc1.php index 2b2a37fe40..51826517f8 100644 --- a/core/Updates/0.6-rc1.php +++ b/core/Updates/0.6-rc1.php @@ -61,7 +61,7 @@ class Updates_0_6_rc1 extends Updates // Outputs warning message, pointing users to the plugin download page if (!empty($disabledPlugins)) { - throw new Exception("The following plugins were disabled during the upgrade:" + throw new \Exception("The following plugins were disabled during the upgrade:" . "<ul><li>" . implode('</li><li>', $disabledPlugins) . "</li></ul>"); diff --git a/core/Updates/0.6.3.php b/core/Updates/0.6.3.php index abcd433ad0..3737c96bce 100644 --- a/core/Updates/0.6.3.php +++ b/core/Updates/0.6.3.php @@ -42,9 +42,9 @@ class Updates_0_6_3 extends Updates $config->database = $dbInfos; $config->forceSave(); } else { - throw new Exception('mandatory update failed'); + throw new \Exception('mandatory update failed'); } - } catch (Exception $e) { + } catch (\Exception $e) { throw new \Piwik\Updater_UpdateErrorException("Please edit your config/config.ini.php file and add below <code>[database]</code> the following line: <br /><code>schema = Myisam</code>"); } } diff --git a/core/Updates/1.1.php b/core/Updates/1.1.php index 26a3df6697..938fc0f6f0 100644 --- a/core/Updates/1.1.php +++ b/core/Updates/1.1.php @@ -28,8 +28,8 @@ class Updates_1_1 extends Updates try { // throws an exception if invalid Piwik::checkValidLoginString($rootLogin); - } catch (Exception $e) { - throw new Exception('Superuser login name "' . $rootLogin . '" is no longer a valid format. ' + } catch (\Exception $e) { + throw new \Exception('Superuser login name "' . $rootLogin . '" is no longer a valid format. ' . $e->getMessage() . ' Edit your config/config.ini.php to change it.'); } diff --git a/core/Updates/1.10-b4.php b/core/Updates/1.10-b4.php index 0f4c2bc4c9..8627bba983 100755 --- a/core/Updates/1.10-b4.php +++ b/core/Updates/1.10-b4.php @@ -27,7 +27,7 @@ class Updates_1_10_b4 extends Updates { try { \Piwik\PluginsManager::getInstance()->activatePlugin('MobileMessaging'); - } catch (Exception $e) { + } catch (\Exception $e) { // pass } } diff --git a/core/Updates/1.10.1.php b/core/Updates/1.10.1.php index f21fad89c5..453773a5a0 100755 --- a/core/Updates/1.10.1.php +++ b/core/Updates/1.10.1.php @@ -27,7 +27,7 @@ class Updates_1_10_1 extends Updates { try { \Piwik\PluginsManager::getInstance()->activatePlugin('Overlay'); - } catch (Exception $e) { + } catch (\Exception $e) { // pass } } diff --git a/core/Updates/1.11-b1.php b/core/Updates/1.11-b1.php index ebfc57e480..19e2708b1f 100644 --- a/core/Updates/1.11-b1.php +++ b/core/Updates/1.11-b1.php @@ -27,7 +27,7 @@ class Updates_1_11_b1 extends Updates { try { \Piwik\PluginsManager::getInstance()->activatePlugin('UserCountryMap'); - } catch (Exception $e) { + } catch (\Exception $e) { // pass } } diff --git a/core/Updates/1.12-b15.php b/core/Updates/1.12-b15.php index 3c4b7f28b5..68d122385c 100644 --- a/core/Updates/1.12-b15.php +++ b/core/Updates/1.12-b15.php @@ -22,7 +22,7 @@ class Updates_1_12_b15 extends Updates { try { \Piwik\PluginsManager::getInstance()->activatePlugin('SegmentEditor'); - } catch (Exception $e) { + } catch (\Exception $e) { // pass } } diff --git a/core/Updates/1.2-rc1.php b/core/Updates/1.2-rc1.php index 45c5250770..361da47295 100644 --- a/core/Updates/1.2-rc1.php +++ b/core/Updates/1.2-rc1.php @@ -138,7 +138,7 @@ class Updates_1_2_rc1 extends Updates // Outputs warning message, pointing users to the plugin download page if (!empty($disabledPlugins)) { - throw new Exception("The following plugins were disabled during the upgrade:" + throw new \Exception("The following plugins were disabled during the upgrade:" . "<ul><li>" . implode('</li><li>', $disabledPlugins) . "</li></ul>"); diff --git a/core/Updates/1.2-rc2.php b/core/Updates/1.2-rc2.php index 3fcbabb57b..6d2373c3c9 100644 --- a/core/Updates/1.2-rc2.php +++ b/core/Updates/1.2-rc2.php @@ -22,7 +22,7 @@ class Updates_1_2_rc2 extends Updates { try { \Piwik\PluginsManager::getInstance()->activatePlugin('CustomVariables'); - } catch (Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/1.4-rc1.php b/core/Updates/1.4-rc1.php index 05a9e993c7..dfb7335baa 100644 --- a/core/Updates/1.4-rc1.php +++ b/core/Updates/1.4-rc1.php @@ -34,7 +34,7 @@ class Updates_1_4_rc1 extends Updates { try { Updater::updateDatabase(__FILE__, self::getSql()); - } catch (Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/1.5-rc6.php b/core/Updates/1.5-rc6.php index 10366e30bd..0bf8abe3c4 100644 --- a/core/Updates/1.5-rc6.php +++ b/core/Updates/1.5-rc6.php @@ -22,7 +22,7 @@ class Updates_1_5_rc6 extends Updates { try { \Piwik\PluginsManager::getInstance()->activatePlugin('PrivacyManager'); - } catch (Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/1.6-rc1.php b/core/Updates/1.6-rc1.php index 3f900b3934..5259cc64b3 100644 --- a/core/Updates/1.6-rc1.php +++ b/core/Updates/1.6-rc1.php @@ -22,7 +22,7 @@ class Updates_1_6_rc1 extends Updates { try { \Piwik\PluginsManager::getInstance()->activatePlugin('ImageGraph'); - } catch (Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/1.7-b1.php b/core/Updates/1.7-b1.php index 6142722a71..3240204d18 100644 --- a/core/Updates/1.7-b1.php +++ b/core/Updates/1.7-b1.php @@ -34,7 +34,7 @@ class Updates_1_7_b1 extends Updates { try { Updater::updateDatabase(__FILE__, self::getSql()); - } catch (Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/1.7.2-rc5.php b/core/Updates/1.7.2-rc5.php index a00f1f7eb6..9127d554d3 100644 --- a/core/Updates/1.7.2-rc5.php +++ b/core/Updates/1.7.2-rc5.php @@ -32,7 +32,7 @@ class Updates_1_7_2_rc5 extends Updates { try { Updater::updateDatabase(__FILE__, self::getSql()); - } catch (Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/1.7.2-rc7.php b/core/Updates/1.7.2-rc7.php index 68c7b17d6d..454d14599e 100755 --- a/core/Updates/1.7.2-rc7.php +++ b/core/Updates/1.7.2-rc7.php @@ -42,7 +42,7 @@ class Updates_1_7_2_rc7 extends Updates Db::query('UPDATE `' . Common::prefixTable('user_dashboard') . '` SET layout = ? WHERE iddashboard = ? AND login = ?', array($layout, $idDashboard, $login)); } Updater::updateDatabase(__FILE__, self::getSql()); - } catch (Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/1.8.3-b1.php b/core/Updates/1.8.3-b1.php index e5dcb14980..d931ef8082 100644 --- a/core/Updates/1.8.3-b1.php +++ b/core/Updates/1.8.3-b1.php @@ -111,7 +111,7 @@ class Updates_1_8_3_b1 extends Updates } Db::query('DROP TABLE `' . Common::prefixTable('pdf') . '`'); - } catch (Exception $e) { + } catch (\Exception $e) { } } diff --git a/core/Updates/1.8.4-b1.php b/core/Updates/1.8.4-b1.php index ede4838e91..bed4eac7a5 100644 --- a/core/Updates/1.8.4-b1.php +++ b/core/Updates/1.8.4-b1.php @@ -185,7 +185,7 @@ class Updates_1_8_4_b1 extends Updates self::enableMaintenanceMode(); Updater::updateDatabase(__FILE__, self::getSql()); self::disableMaintenanceMode(); - } catch (Exception $e) { + } catch (\Exception $e) { self::disableMaintenanceMode(); throw $e; } diff --git a/core/Updates/1.9-b19.php b/core/Updates/1.9-b19.php index c372e3d56b..904f75a757 100755 --- a/core/Updates/1.9-b19.php +++ b/core/Updates/1.9-b19.php @@ -39,7 +39,7 @@ class Updates_1_9_b19 extends Updates try { \Piwik\PluginsManager::getInstance()->activatePlugin('Transitions'); - } catch (Exception $e) { + } catch (\Exception $e) { } } } diff --git a/core/Updates/1.9-b9.php b/core/Updates/1.9-b9.php index 8801c24b21..30e148d185 100755 --- a/core/Updates/1.9-b9.php +++ b/core/Updates/1.9-b9.php @@ -51,7 +51,7 @@ class Updates_1_9_b9 extends Updates self::enableMaintenanceMode(); Updater::updateDatabase(__FILE__, self::getSql()); self::disableMaintenanceMode(); - } catch (Exception $e) { + } catch (\Exception $e) { self::disableMaintenanceMode(); throw $e; } diff --git a/core/Updates/1.9.3-b10.php b/core/Updates/1.9.3-b10.php index 620d08f4e2..154313105d 100755 --- a/core/Updates/1.9.3-b10.php +++ b/core/Updates/1.9.3-b10.php @@ -27,7 +27,7 @@ class Updates_1_9_3_b10 extends Updates { try { \Piwik\PluginsManager::getInstance()->activatePlugin('Annotations'); - } catch (Exception $e) { + } catch (\Exception $e) { // pass } } diff --git a/core/Updates/2.0-a12.php b/core/Updates/2.0-a12.php index e29c1a1e0b..4f8aac1272 100644 --- a/core/Updates/2.0-a12.php +++ b/core/Updates/2.0-a12.php @@ -35,7 +35,7 @@ class Updates_2_0_a12 extends Updates if ($rows == 0) { $result["DROP TABLE $tableName"] = false; } - } catch (Exception $ex) { + } catch (\Exception $ex) { // ignore } } diff --git a/core/Updates/2.0-a13.php b/core/Updates/2.0-a13.php index 631fd8c67e..5a572d8073 100644 --- a/core/Updates/2.0-a13.php +++ b/core/Updates/2.0-a13.php @@ -68,11 +68,11 @@ class Updates_2_0_a13 extends Updates try { \Piwik\PluginsManager::getInstance()->activatePlugin('Referrers'); - } catch(Exception $e) { + } catch(\Exception $e) { } try { \Piwik\PluginsManager::getInstance()->activatePlugin('ScheduledReports'); - } catch(Exception $e) { + } catch(\Exception $e) { } } diff --git a/libs/PiwikTracker/PiwikTracker.php b/libs/PiwikTracker/PiwikTracker.php index 78874d9996..eb8d1924b4 100644 --- a/libs/PiwikTracker/PiwikTracker.php +++ b/libs/PiwikTracker/PiwikTracker.php @@ -370,7 +370,7 @@ class PiwikTracker * * @param string $keyword Searched query on the site * @param string $category Optional, Search engine category if applicable - * @param int $countResults results displayed on the search result page. Used to track "zero result" keywords. + * @param bool|int $countResults results displayed on the search result page. Used to track "zero result" keywords. * * @return mixed Response or true if using bulk requests. */ diff --git a/misc/cron/archive.php b/misc/cron/archive.php index 1fdae6d839..4fecde5662 100644 --- a/misc/cron/archive.php +++ b/misc/cron/archive.php @@ -182,7 +182,6 @@ class CronArchive return "?module=API&method=VisitsSummary.getVisits&idSite=$idsite&period=$period&date=last" . $dateLast . "&format=php&token_auth=" . $this->token_auth; } - /** * Returns the option name of the option that stores the time the archive.php * script was last run. diff --git a/plugins/CorePluginsAdmin/PluginInstaller.php b/plugins/CorePluginsAdmin/PluginInstaller.php index 849b910e21..3fabe7cf55 100644 --- a/plugins/CorePluginsAdmin/PluginInstaller.php +++ b/plugins/CorePluginsAdmin/PluginInstaller.php @@ -173,22 +173,23 @@ class PluginInstaller */ private function getNameOfFirstSubfolder($pluginDir) { - if ($dir = opendir($pluginDir)) { - $firstSubFolder = ''; - - while ($file = readdir($dir)) { - if ($file[0] != '.' && is_dir($pluginDir . DIRECTORY_SEPARATOR . $file)) { - $firstSubFolder = $file; - break; - } - } + if (!($dir = opendir($pluginDir))) { + return false; + } + $firstSubFolder = ''; - if (empty($firstSubFolder)) { - throw new PluginInstallerException('The plugin ZIP file does not contain a subfolder, but Piwik expects plugin files to be within a subfolder in the Zip archive.'); + while ($file = readdir($dir)) { + if ($file[0] != '.' && is_dir($pluginDir . DIRECTORY_SEPARATOR . $file)) { + $firstSubFolder = $file; + break; } + } - return $firstSubFolder; + if (empty($firstSubFolder)) { + throw new PluginInstallerException('The plugin ZIP file does not contain a subfolder, but Piwik expects plugin files to be within a subfolder in the Zip archive.'); } + + return $firstSubFolder; } private function fixPluginFolderIfNeeded($tmpPluginFolder) diff --git a/plugins/CoreVisualizations/Visualizations/Cloud.php b/plugins/CoreVisualizations/Visualizations/Cloud.php index 971331059c..125c82805a 100644 --- a/plugins/CoreVisualizations/Visualizations/Cloud.php +++ b/plugins/CoreVisualizations/Visualizations/Cloud.php @@ -181,5 +181,6 @@ class Cloud extends Visualization return $key; } } + return 0; } } diff --git a/plugins/Goals/Archiver.php b/plugins/Goals/Archiver.php index efb26854bc..419ab876e1 100644 --- a/plugins/Goals/Archiver.php +++ b/plugins/Goals/Archiver.php @@ -246,6 +246,7 @@ class Archiver extends PluginsArchiver $this->aggregateFromEcommerceItems($query, $dimension); } $this->recordItemReports(); + return true; } protected function initItemReports() diff --git a/plugins/LanguagesManager/API.php b/plugins/LanguagesManager/API.php index c7bee7603a..2bc178d054 100644 --- a/plugins/LanguagesManager/API.php +++ b/plugins/LanguagesManager/API.php @@ -243,5 +243,6 @@ class API VALUES (?,?) ON DUPLICATE KEY UPDATE language=?', $paramsBind); + return true; } } diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php index f9b7a3ed00..ae7f2e8129 100644 --- a/plugins/LanguagesManager/LanguagesManager.php +++ b/plugins/LanguagesManager/LanguagesManager.php @@ -156,6 +156,7 @@ class LanguagesManager extends \Piwik\Plugin return $language['name']; } } + return false; } /** @@ -206,5 +207,6 @@ class LanguagesManager extends \Piwik\Plugin $cookie = new Cookie($cookieName, 0); $cookie->set('language', $languageCode); $cookie->save(); + return true; } } diff --git a/plugins/Live/API.php b/plugins/Live/API.php index 76ab9b999b..7d1938df69 100644 --- a/plugins/Live/API.php +++ b/plugins/Live/API.php @@ -19,6 +19,7 @@ use Piwik\DataTable\Row; use Piwik\DataTable; use Piwik\Date; use Piwik\Db; +use Piwik\MetricsFormatter; use Piwik\Period; use Piwik\Period\Range; use Piwik\Piwik; @@ -313,7 +314,7 @@ class API round($pageGenerationTimeTotal / $result['totalPageViews'], $precision = 2); } - $result['totalVisitDurationPretty'] = \Piwik\MetricsFormatter::getPrettyTimeFromSeconds($result['totalVisitDuration']); + $result['totalVisitDurationPretty'] = MetricsFormatter::getPrettyTimeFromSeconds($result['totalVisitDuration']); // use requested visits for first/last visit info $rows = $visits->getRows(); diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php index 2d65fb285b..1bb184f44a 100644 --- a/plugins/SitesManager/API.php +++ b/plugins/SitesManager/API.php @@ -93,6 +93,7 @@ class API /** * Returns all websites belonging to the specified group * @param string $group Group name + * @return array of sites */ public function getSitesFromGroup($group) { diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php index 6d3744f0f3..69b4946350 100644 --- a/plugins/Transitions/API.php +++ b/plugins/Transitions/API.php @@ -406,7 +406,6 @@ class API } } - //FIXMEA refactor after integration tests written $array = new DataArray($referrerData, $referrerSubData); return ArchiveProcessor\Day::getDataTableFromDataArray($array); } |