diff options
author | mattab <matthieu.aubry@gmail.com> | 2016-02-20 13:39:01 +0300 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2016-02-20 13:39:01 +0300 |
commit | 19931b9ae1db5c10ddef7110f21b1e819815a7cf (patch) | |
tree | 6c3b8ffb0e3b42018cf26b42029c35a6de18d989 /core | |
parent | c8f743040f72f90b9cd134d7b24276dd2aa58768 (diff) | |
parent | 11cd366df3fbef458163b987e4c781532479decc (diff) |
Merge branch 'master' of github.com:piwik/piwik
Diffstat (limited to 'core')
-rw-r--r-- | core/CronArchive.php | 22 | ||||
-rw-r--r-- | core/DataTable.php | 1 | ||||
-rw-r--r-- | core/Notification/Manager.php | 59 | ||||
-rw-r--r-- | core/Plugin/Manager.php | 11 | ||||
-rw-r--r-- | core/Version.php | 2 |
5 files changed, 77 insertions, 18 deletions
diff --git a/core/CronArchive.php b/core/CronArchive.php index 935f99dcfa..d96a0a4ae8 100644 --- a/core/CronArchive.php +++ b/core/CronArchive.php @@ -265,6 +265,7 @@ class CronArchive * * @param string|null $processNewSegmentsFrom When to archive new segments from. See [General] process_new_segments_from * for possible values. + * @param LoggerInterface|null $logger */ public function __construct($processNewSegmentsFrom = null, LoggerInterface $logger = null) { @@ -714,6 +715,12 @@ class CronArchive /** * Returns base URL to process reports for the $idSite on a given $period + * + * @param string $idSite + * @param string $period + * @param string $date + * @param bool|false $segment + * @return string */ private function getVisitsRequestUrl($idSite, $period, $date, $segment = false) { @@ -839,7 +846,11 @@ class CronArchive return true; } - private function getSegmentsForSite($idSite, $period) + /** + * @param $idSite + * @return array + */ + private function getSegmentsForSite($idSite) { $segmentsAllSites = $this->segments; $segmentsThisSite = SettingsPiwik::getKnownSegmentsToArchiveForSite($idSite); @@ -933,6 +944,8 @@ class CronArchive /** * Logs a section in the output + * + * @param string $title */ private function logSection($title = "") { @@ -968,6 +981,8 @@ class CronArchive /** * Issues a request to $url eg. "?module=API&method=API.getDefaultMetricTranslations&format=original&serialize=1" * + * @param string $url + * @return string */ private function request($url) { @@ -1053,6 +1068,7 @@ class CronArchive /** * @internal + * @param $api */ public function setApiToInvalidateArchivedReport($api) { @@ -1136,6 +1152,7 @@ class CronArchive /** * Detects whether a site had visits since midnight in the websites timezone * + * @param $idSite * @return bool */ private function hadWebsiteTrafficSinceMidnightInTimezone($idSite) @@ -1623,7 +1640,7 @@ class CronArchive private function getUrlsWithSegment($idSite, $period, $date) { $urlsWithSegment = array(); - $segmentsForSite = $this->getSegmentsForSite($idSite, $period); + $segmentsForSite = $this->getSegmentsForSite($idSite); $segments = array(); foreach ($segmentsForSite as $segment) { @@ -1680,6 +1697,7 @@ class CronArchive /** * @param $idSite * @param $period + * @param $date */ private function logArchiveWebsite($idSite, $period, $date) { diff --git a/core/DataTable.php b/core/DataTable.php index 221af5315a..0b68a96f50 100644 --- a/core/DataTable.php +++ b/core/DataTable.php @@ -1714,6 +1714,7 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess public function mergeSubtables($labelColumn = false, $useMetadataColumn = false) { $result = new DataTable(); + $result->setAllTableMetadata($this->getAllTableMetadata()); foreach ($this->getRowsWithoutSummaryRow() as $row) { $subtable = $row->getSubtable(); if ($subtable !== false) { diff --git a/core/Notification/Manager.php b/core/Notification/Manager.php index e7eafec49e..bdf1f130dd 100644 --- a/core/Notification/Manager.php +++ b/core/Notification/Manager.php @@ -24,6 +24,11 @@ class Manager private static $session = null; /** + * @var Notification[] + */ + private static $notifications = array(); + + /** * Posts a notification that will be shown in Piwik's status bar. If a notification with the same ID * has been posted and has not been closed/removed, it will be replaced with `$notification`. * @@ -105,12 +110,21 @@ class Manager private static function addNotification($id, Notification $notification) { - if (!self::isEnabled()) { - return; - } + self::saveNotificationAcrossUiRequestsIfNeeded($id, $notification); - $session = static::getSession(); - $session->notifications[$id] = $notification; + // we store all kinda notifications here so in case the session is not enabled or disabled later there is still + // a chance it gets delivered to the UI during the same request. + self::$notifications[$id] = $notification; + } + + private static function saveNotificationAcrossUiRequestsIfNeeded($id, Notification $notification) + { + $isPersistent = $notification->type === Notification::TYPE_PERSISTENT; + + if ($isPersistent && self::isSessionEnabled()) { + $session = static::getSession(); + $session->notifications[$id] = $notification; + } } private static function removeOldestNotificationsIfThereAreTooMany() @@ -126,28 +140,43 @@ class Manager private static function getAllNotifications() { - if (!self::isEnabled()) { + if (!self::isSessionEnabled()) { return array(); } - $session = static::getSession(); + $notifications = self::$notifications; + + foreach ($notifications as $id => $notification) { + // we copy them over to the session if possible and persist it in case the session was not yet + // writable / enabled at the time the notification was added. + self::saveNotificationAcrossUiRequestsIfNeeded($id, $notification); + } - return $session->notifications; + if (self::isSessionEnabled()) { + $session = static::getSession(); + foreach ($session->notifications as $id => $notification) { + $notifications[$id] = $notification; + } + } + + return $notifications; } private static function removeNotification($id) { - if (!self::isEnabled()) { - return; + if (array_key_exists($id, self::$notifications)) { + unset(self::$notifications[$id]); } - $session = static::getSession(); - if (array_key_exists($id, $session->notifications)) { - unset($session->notifications[$id]); + if (self::isSessionEnabled()) { + $session = static::getSession(); + if (array_key_exists($id, $session->notifications)) { + unset($session->notifications[$id]); + } } } - private static function isEnabled() + private static function isSessionEnabled() { return Session::isWritable() && Session::isReadable(); } @@ -161,7 +190,7 @@ class Manager static::$session = new SessionNamespace('notification'); } - if (empty(static::$session->notifications) && self::isEnabled()) { + if (empty(static::$session->notifications) && self::isSessionEnabled()) { static::$session->notifications = array(); } diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index 63a3e0aaaf..2b552f48e0 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -18,9 +18,11 @@ use Piwik\Container\StaticContainer; use Piwik\EventDispatcher; use Piwik\Filesystem; use Piwik\Log; +use Piwik\Notification; use Piwik\Piwik; use Piwik\Plugin; use Piwik\PluginDeactivatedException; +use Piwik\Session; use Piwik\Theme; use Piwik\Tracker; use Piwik\Translation\Translator; @@ -828,6 +830,15 @@ class Manager if ($newPlugin->hasMissingDependencies()) { $this->deactivatePlugin($pluginName); + + // add this state we do not know yet whether current user has super user access. We do not even know + // if someone is actually logged in. + $message = sprintf('We disabled the plugin %s as it has missing dependencies.', $pluginName); + $message .= ' Please contact your Piwik administrator.'; + + $notification = new Notification($message); + $notification->context = Notification::CONTEXT_ERROR; + Notification\Manager::notify('PluginManager_PluginDeactivated', $notification); continue; } diff --git a/core/Version.php b/core/Version.php index 7725230d97..9e9036a0ac 100644 --- a/core/Version.php +++ b/core/Version.php @@ -20,7 +20,7 @@ final class Version * The current Piwik version. * @var string */ - const VERSION = '2.16.0'; + const VERSION = '2.16.1-b1'; public function isStableVersion($version) { |