Skip to content

Commit

Permalink
Fix bug in SegmentEditor plugin, make sure getKnownSegmentsToArchiveA…
Browse files Browse the repository at this point in the history
…llSites adds segment definitions to output segment array and not whole stored segment data.
  • Loading branch information
Benaka Moorthi committed Jun 11, 2013
1 parent 7005ef7 commit c5de357
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions core/Piwik.php
Expand Up @@ -1539,10 +1539,11 @@ static public function getKnownSegmentsToArchive()

if (is_null($cachedResult)) {
$segments = Piwik_Config::getInstance()->Segments;
$cachedResult = isset($segments['Segments']) ? $segments['Segments'] : '';
$cachedResult = isset($segments['Segments']) ? $segments['Segments'] : array();

Piwik_PostEvent('Piwik.getKnownSegmentsToArchiveAllSites', $cachedResult);


$cachedResult = array_unique($cachedResult);
}

return $cachedResult;
Expand Down
8 changes: 5 additions & 3 deletions plugins/SegmentEditor/SegmentEditor.php
Expand Up @@ -45,9 +45,11 @@ function getSegmentEditorHtml($notification)
public function getKnownSegmentsToArchiveAllSites($notification)
{
$segments =& $notification->getNotificationObject();
$segmentToAutoArchive = Piwik_SegmentEditor_API::getInstance()->getAll($idSite = false, $returnAutoArchived = true);
if (!empty($segmentToAutoArchive)) {
$segments = array_merge($segments, $segmentToAutoArchive);
$segmentsToAutoArchive = Piwik_SegmentEditor_API::getInstance()->getAll(
$idSite = false, $returnAutoArchived = true);

foreach ($segmentsToAutoArchive as $segment) {
$segments[] = $segment['definition'];
}
}

Expand Down

0 comments on commit c5de357

Please sign in to comment.