diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2020-04-16 23:24:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-16 23:24:39 +0300 |
commit | 37182bfda5529ddb4ba2aaedd09beb1e5ae94fbb (patch) | |
tree | f6609b714e4e6cac35769f98e8f47f5e95071b5f /plugins | |
parent | e943702e1e54bfc71d423bfd2ec2a48c0a4610f7 (diff) |
merge 3.x to 4.x (#15821)
* Avoid possible error subtable already exists but not loaded (#15779)
* Make sure to always set JSON_PIWIK to native JSON when possible (#15785)
* make sure to always set JSON_PIWIK to native JSON when possible
* rebuilt piwik.js
* Force POST for bulk requests, fix alwaysUseSendBeacon not respected for bulk requests (#15784)
* Force POST for bulk requests, fix alwaysUseSendBeacon not respected for bulk requests
* rebuilt piwik.js
* Make sure to clean up tracking failures before sending email notification (#15798)
Feedback from a customer... Eg the daily `cleanupTrackingFailures()` action might be only executed after the weekly `notifyTrackingFailures` therefore we should try to clean up failures first and then check if any are left. Avoids the case where a user opens hours later the email they receive and then there are no tracking failures reported. This could still happen but it's a bit less likely.
* 3.13.5-b1
* Faster segmented suggested values when browser archiving is disabled (#15786)
* Faster segmented suggested values when browser archiving is disabled
* make sure no segment is set
* remove wrong var type
* fix/add tests
* add more segment values
* detect if we should flatten or not
* add docs
* Fix problem when comparing segments or opening popovers (#15809)
refs #15805
* purge all old archives regardless of done value (#15800)
* purge all old archives regardless of done value, we only care about the newest usable one
* Fix test and start on new one.
* Add coverage for change in tests.
* there is no longer an inner join so should not need the idsite check
* Add more parameters to the computeNbUnique event (#15808)
* 3.13.5-b2
* One click update in two parts so new code is loaded for second. (#15770)
* One click update in two parts so new code is loaded for second.
* remove no longer needed code
Co-authored-by: Thomas Steur <tsteur@users.noreply.github.com>
Co-authored-by: Matthieu Aubry <mattab@users.noreply.github.com>
Co-authored-by: Stefan Giehl <stefan@matomo.org>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/API/API.php | 57 | ||||
-rw-r--r-- | plugins/API/SegmentMetadata.php | 4 | ||||
-rw-r--r-- | plugins/API/tests/System/AutoSuggestAPITest.php | 45 | ||||
-rw-r--r-- | plugins/Actions/Columns/ClickedUrl.php | 1 | ||||
-rw-r--r-- | plugins/Actions/Columns/DownloadUrl.php | 1 | ||||
-rw-r--r-- | plugins/Actions/Columns/EntryPageTitle.php | 1 | ||||
-rw-r--r-- | plugins/Actions/Columns/EntryPageUrl.php | 1 | ||||
-rw-r--r-- | plugins/Actions/Columns/ExitPageTitle.php | 1 | ||||
-rw-r--r-- | plugins/Actions/Columns/ExitPageUrl.php | 1 | ||||
-rw-r--r-- | plugins/Actions/Columns/PageTitle.php | 1 | ||||
-rw-r--r-- | plugins/Actions/Columns/PageUrl.php | 1 | ||||
-rw-r--r-- | plugins/Actions/DataTable/Filter/Actions.php | 17 | ||||
-rw-r--r-- | plugins/Contents/Columns/ContentName.php | 1 | ||||
-rw-r--r-- | plugins/Contents/Columns/ContentPiece.php | 1 | ||||
-rw-r--r-- | plugins/CoreAdminHome/Tasks.php | 1 | ||||
-rw-r--r-- | plugins/CoreUpdater/Controller.php | 12 | ||||
-rw-r--r-- | plugins/CoreUpdater/Updater.php | 65 | ||||
-rw-r--r-- | plugins/Events/Columns/EventAction.php | 1 | ||||
-rw-r--r-- | plugins/Events/Columns/EventCategory.php | 1 | ||||
-rw-r--r-- | plugins/Events/Columns/EventName.php | 2 |
20 files changed, 186 insertions, 29 deletions
diff --git a/plugins/API/API.php b/plugins/API/API.php index dfc484e9a6..1b009525eb 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -10,6 +10,7 @@ namespace Piwik\Plugins\API; use Piwik\API\Proxy; use Piwik\API\Request; +use Piwik\ArchiveProcessor\Rules; use Piwik\Cache; use Piwik\CacheId; use Piwik\Category\CategoryList; @@ -29,6 +30,7 @@ use Piwik\Plugin\SettingsProvider; use Piwik\Plugins\API\DataTable\MergeDataTables; use Piwik\Plugins\CoreAdminHome\CustomLogo; use Piwik\Plugins\CorePluginsAdmin\SettingsMetadata; +use Piwik\Segment; use Piwik\Site; use Piwik\Translation\Translator; use Piwik\Measurable\Type\TypeManager; @@ -580,6 +582,61 @@ class API extends \Piwik\Plugin\API // if segment has suggested values callback then return result from it instead $suggestedValuesCallbackRequiresTable = false; + + if (!empty($segment['suggestedValuesApi']) && is_string($segment['suggestedValuesApi']) && !Rules::isBrowserTriggerEnabled()) { + $now = Date::now()->setTimezone(Site::getTimezoneFor($idSite)); + if (self::$_autoSuggestLookBack != 60) { + // in Auto suggest tests we need to assume now is in 2018... + // we do - 20 to make sure the year is still correct otherwise could end up being 2017-12-31 and the recorded visits are over several days in the tests we make sure to select the last day a visit was recorded + $now = $now->subDay(self::$_autoSuggestLookBack - 20); + } + // we want to avoid launching the archiver should browser archiving be enabled as this can be very slow... we then rather + // use the live api. + $period = 'year'; + $date = $now->toString(); + if ($now->toString('m') == '01') { + if (Rules::isArchivingDisabledFor(array($idSite), new Segment('', array($idSite)), 'range')) { + $date = $now->subYear(1)->toString(); // use previous year data to avoid using range + } else { + $period = 'range'; + $date = $now->subMonth(1)->toString() . ',' . $now->addDay(1)->toString(); + } + } + + $apiParts = explode('.', $segment['suggestedValuesApi']); + $meta = $this->getMetadata($idSite, $apiParts[0], $apiParts[1]); + $flat = !empty($meta[0]['actionToLoadSubTables']) && $meta[0]['actionToLoadSubTables'] == $apiParts[1]; + + $table = Request::processRequest($segment['suggestedValuesApi'], array( + 'idSite' => $idSite, + 'period' => $period, + 'date' => $date, + 'segment' => '', + 'filter_offset' => 0, + 'flat' => (int) $flat, + 'filter_limit' => $maxSuggestionsToReturn + )); + if ($table && $table instanceof DataTable && $table->getRowsCount()) { + $values = []; + foreach ($table->getRowsWithoutSummaryRow() as $row) { + $segment = $row->getMetadata('segment'); + $remove = array( + $segmentName . Segment\SegmentExpression::MATCH_EQUAL, + $segmentName . Segment\SegmentExpression::MATCH_STARTS_WITH + ); + // we don't look at row columns since this could include rows that won't work eg Other summary rows. etc + // and it is generally not reliable. + if (!empty($segment) && preg_match('/^' . implode('|',$remove) . '/', $segment)) { + $values[] = urldecode(urldecode(str_replace($remove, '', $segment))); + } + } + + $values = array_slice($values, 0, $maxSuggestionsToReturn); + $values = array_map(array('Piwik\Common', 'unsanitizeInputValue'), $values); + return $values; + } + } + if (isset($segment['suggestedValuesCallback'])) { $suggestedValuesCallbackRequiresTable = $this->doesSuggestedValuesCallbackNeedData( $segment['suggestedValuesCallback']); diff --git a/plugins/API/SegmentMetadata.php b/plugins/API/SegmentMetadata.php index ec21e39fb1..ca6cf0e470 100644 --- a/plugins/API/SegmentMetadata.php +++ b/plugins/API/SegmentMetadata.php @@ -94,6 +94,10 @@ class SegmentMetadata ) { unset($segment['suggestedValuesCallback']); } + + if (isset($segment['suggestedValuesApi'])) { + unset($segment['suggestedValuesApi']); + } } } diff --git a/plugins/API/tests/System/AutoSuggestAPITest.php b/plugins/API/tests/System/AutoSuggestAPITest.php index fad66910aa..1a93679387 100644 --- a/plugins/API/tests/System/AutoSuggestAPITest.php +++ b/plugins/API/tests/System/AutoSuggestAPITest.php @@ -10,11 +10,13 @@ namespace Piwik\Plugins\API\tests\System; use Piwik\API\Request; use Piwik\Application\Environment; +use Piwik\ArchiveProcessor\Rules; use Piwik\Cache as PiwikCache; use Piwik\Columns\Dimension; use Piwik\Common; use Piwik\DataTable\Manager; use Piwik\Date; +use Piwik\Option; use Piwik\Plugins\API\API; use Piwik\Plugins\CustomVariables\Columns\CustomVariableName; use Piwik\Plugins\CustomVariables\Columns\CustomVariableValue; @@ -50,6 +52,7 @@ class AutoSuggestAPITest extends SystemTestCase protected static $processed = 0; protected static $skipped = array(); + private static $hasArchivedData = false; public static function setUpBeforeClass(): void { @@ -103,6 +106,43 @@ class AutoSuggestAPITest extends SystemTestCase } /** + * @dataProvider getApiForTestingBrowserArchivingDisabled + */ + public function testApiBrowserArchivingDisabled($api, $params) + { + if (!self::$hasArchivedData) { + self::$hasArchivedData = true; + // need to make sure data is archived before disabling the archiving + Request::processRequest('API.get', array( + 'date' => '2018-01-10', 'period' => 'year', 'idSite' => $params['idSite'], + 'trigger' => 'archivephp' + )); + } + + // Refresh cache for CustomVariables\Model + Cache::clearCacheGeneral(); + // disable browser archiving so the APIs are used + Option::set(Rules::OPTION_BROWSER_TRIGGER_ARCHIVING, 0); + + $this->runApiTests($api, $params); + + Option::set(Rules::OPTION_BROWSER_TRIGGER_ARCHIVING, 1); + } + + public function getApiForTestingBrowserArchivingDisabled() + { + $idSite = self::$fixture->idSite; + $segments = self::getSegmentsMetadata($onlyWithSuggestedValuesApi = true); + + $apiForTesting = array(); + foreach ($segments as $segment) { + $apiForTesting[] = $this->getApiForTestingForSegment($idSite, $segment); + } + + return $apiForTesting; + } + + /** * @param $idSite * @param $segment * @return array @@ -206,7 +246,7 @@ class AutoSuggestAPITest extends SystemTestCase $this->assertGreaterThan($minimumSegmentsToTest, self::$processed, $message); } - public static function getSegmentsMetadata() + public static function getSegmentsMetadata($onlyWithSuggestedValuesApi = false) { // Refresh cache for CustomVariables\Model Cache::clearCacheGeneral(); @@ -232,6 +272,9 @@ class AutoSuggestAPITest extends SystemTestCase if ($segment->isInternal()) { continue; } + if ($onlyWithSuggestedValuesApi && !$segment->getSuggestedValuesApi()) { + continue; + } $segments[] = $segment->getSegment(); } } diff --git a/plugins/Actions/Columns/ClickedUrl.php b/plugins/Actions/Columns/ClickedUrl.php index cc74ad45f6..70a3c4fc51 100644 --- a/plugins/Actions/Columns/ClickedUrl.php +++ b/plugins/Actions/Columns/ClickedUrl.php @@ -20,6 +20,7 @@ class ClickedUrl extends ActionDimension protected $nameSingular = 'Actions_ColumnClickedURL'; protected $namePlural = 'Actions_ColumnClickedURLs'; protected $category = 'General_Actions'; + protected $suggestedValuesApi = 'Actions.getOutlinks'; protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment'; protected $type = self::TYPE_URL; diff --git a/plugins/Actions/Columns/DownloadUrl.php b/plugins/Actions/Columns/DownloadUrl.php index 62a63157db..f3a91649a8 100644 --- a/plugins/Actions/Columns/DownloadUrl.php +++ b/plugins/Actions/Columns/DownloadUrl.php @@ -20,6 +20,7 @@ class DownloadUrl extends ActionDimension protected $namePlural = 'Actions_ColumnDownloadURLs'; protected $columnName = 'idaction_url'; protected $category = 'General_Actions'; + protected $suggestedValuesApi = 'Actions.getDownloads'; protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment'; protected $type = self::TYPE_URL; diff --git a/plugins/Actions/Columns/EntryPageTitle.php b/plugins/Actions/Columns/EntryPageTitle.php index 47741de58c..e6de18c507 100644 --- a/plugins/Actions/Columns/EntryPageTitle.php +++ b/plugins/Actions/Columns/EntryPageTitle.php @@ -21,6 +21,7 @@ class EntryPageTitle extends VisitDimension protected $columnType = 'INTEGER(10) UNSIGNED NULL'; protected $type = self::TYPE_TEXT; protected $segmentName = 'entryPageTitle'; + protected $suggestedValuesApi = 'Actions.getEntryPageTitles'; protected $nameSingular = 'Actions_ColumnEntryPageTitle'; protected $namePlural = 'Actions_WidgetEntryPageTitles'; protected $category = 'General_Actions'; diff --git a/plugins/Actions/Columns/EntryPageUrl.php b/plugins/Actions/Columns/EntryPageUrl.php index a44a1df0bb..c54be5b541 100644 --- a/plugins/Actions/Columns/EntryPageUrl.php +++ b/plugins/Actions/Columns/EntryPageUrl.php @@ -22,6 +22,7 @@ class EntryPageUrl extends VisitDimension protected $segmentName = 'entryPageUrl'; protected $nameSingular = 'Actions_ColumnEntryPageURL'; protected $namePlural = 'Actions_ColumnEntryPageURLs'; + protected $suggestedValuesApi = 'Actions.getEntryPageUrls'; protected $category = 'General_Actions'; protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment'; protected $type = self::TYPE_URL; diff --git a/plugins/Actions/Columns/ExitPageTitle.php b/plugins/Actions/Columns/ExitPageTitle.php index 4cc417c968..cacaeab388 100644 --- a/plugins/Actions/Columns/ExitPageTitle.php +++ b/plugins/Actions/Columns/ExitPageTitle.php @@ -23,6 +23,7 @@ class ExitPageTitle extends VisitDimension protected $nameSingular = 'Actions_ColumnExitPageTitle'; protected $namePlural = 'Actions_WidgetExitPageTitles'; protected $category = 'General_Actions'; + protected $suggestedValuesApi = 'Actions.getExitPageTitles'; protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment'; protected $type = self::TYPE_TEXT; diff --git a/plugins/Actions/Columns/ExitPageUrl.php b/plugins/Actions/Columns/ExitPageUrl.php index 42514a8bc2..2e4386a118 100644 --- a/plugins/Actions/Columns/ExitPageUrl.php +++ b/plugins/Actions/Columns/ExitPageUrl.php @@ -27,6 +27,7 @@ class ExitPageUrl extends VisitDimension protected $nameSingular = 'Actions_ColumnExitPageURL'; protected $namePlural = 'Actions_ColumnExitPageURLs'; protected $category = 'General_Actions'; + protected $suggestedValuesApi = 'Actions.getExitPageUrls'; protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment'; public function configureMetrics(MetricsList $metricsList, DimensionMetricFactory $dimensionMetricFactory) diff --git a/plugins/Actions/Columns/PageTitle.php b/plugins/Actions/Columns/PageTitle.php index 502744126d..8428c9d8c2 100644 --- a/plugins/Actions/Columns/PageTitle.php +++ b/plugins/Actions/Columns/PageTitle.php @@ -22,6 +22,7 @@ class PageTitle extends ActionDimension protected $nameSingular = 'Goals_PageTitle'; protected $namePlural = 'Actions_WidgetPageTitles'; protected $category = 'General_Actions'; + protected $suggestedValuesApi = 'Actions.getPageTitles'; protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment'; public function getDbColumnJoin() diff --git a/plugins/Actions/Columns/PageUrl.php b/plugins/Actions/Columns/PageUrl.php index 7728a49a5a..d12086cff5 100644 --- a/plugins/Actions/Columns/PageUrl.php +++ b/plugins/Actions/Columns/PageUrl.php @@ -25,6 +25,7 @@ class PageUrl extends ActionDimension protected $acceptValues = 'All these segments must be URL encoded, for example: http%3A%2F%2Fexample.com%2Fpath%2Fpage%3Fquery'; protected $category = 'General_Actions'; protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment'; + protected $suggestedValuesApi = 'Actions.getPageUrls'; public function getDbColumnJoin() { diff --git a/plugins/Actions/DataTable/Filter/Actions.php b/plugins/Actions/DataTable/Filter/Actions.php index 29bfe1bf49..a17a7b4920 100644 --- a/plugins/Actions/DataTable/Filter/Actions.php +++ b/plugins/Actions/DataTable/Filter/Actions.php @@ -13,6 +13,7 @@ use Piwik\Config; use Piwik\DataTable\BaseFilter; use Piwik\DataTable\Row; use Piwik\DataTable; +use Piwik\Plugins\Actions\ArchivingHelper; use Piwik\Tracker\Action; class Actions extends BaseFilter @@ -54,6 +55,9 @@ class Actions extends BaseFilter } } + $notDefinedUrl = ArchivingHelper::getUnknownActionName(Action::TYPE_PAGE_URL); + $notDefinedTitle = ArchivingHelper::getUnknownActionName(Action::TYPE_PAGE_TITLE); + foreach ($dataTable->getRows() as $row) { if (!$row->isSummaryRow()) { $url = $row->getMetadata('url'); @@ -75,10 +79,19 @@ class Actions extends BaseFilter if ($row->getIdSubDataTable()) { $row->setMetadata('segment', 'pageTitle=^' . urlencode(urlencode(trim($label)))); } else { - $row->setMetadata('segmentValue', urlencode(trim($label))); + $notDefinedName = ArchivingHelper::getUnknownActionName(Action::TYPE_PAGE_TITLE); + if (trim($label) == $notDefinedName) { + $row->setMetadata('segmentValue', ''); + } else { + $row->setMetadata('segmentValue', urlencode(trim($label))); + } } } else if ($this->actionType == Action::TYPE_PAGE_URL && $urlPrefix) { // folder for older data w/ no folder URL metadata - $row->setMetadata('segment', 'pageUrl=^' . urlencode(urlencode($urlPrefix . '/' . $label))); + if ($label === $notDefinedUrl) { + $row->setMetadata('segmentValue', ''); + } else { + $row->setMetadata('segment', 'pageUrl=^' . urlencode(urlencode($urlPrefix . '/' . $label))); + } } } diff --git a/plugins/Contents/Columns/ContentName.php b/plugins/Contents/Columns/ContentName.php index b327918a77..a56b49f835 100644 --- a/plugins/Contents/Columns/ContentName.php +++ b/plugins/Contents/Columns/ContentName.php @@ -24,6 +24,7 @@ class ContentName extends ActionDimension protected $nameSingular = 'Contents_ContentName'; protected $namePlural = 'Contents_ContentNames'; protected $acceptValues = 'The name of a content block, for instance "Ad Sale"'; + protected $suggestedValuesApi = 'Contents.getContentNames'; protected $type = self::TYPE_TEXT; protected $category = 'General_Actions'; protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment'; diff --git a/plugins/Contents/Columns/ContentPiece.php b/plugins/Contents/Columns/ContentPiece.php index 35ac1df8cc..c1d5d3d444 100644 --- a/plugins/Contents/Columns/ContentPiece.php +++ b/plugins/Contents/Columns/ContentPiece.php @@ -23,6 +23,7 @@ class ContentPiece extends ActionDimension protected $nameSingular = 'Contents_ContentPiece'; protected $namePlural = 'Contents_ContentPieces'; protected $acceptValues = 'The actual content. For instance "ad.jpg" or "My text ad"'; + protected $suggestedValuesApi = 'Contents.getContentPieces'; protected $type = self::TYPE_TEXT; protected $category = 'General_Actions'; protected $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment'; diff --git a/plugins/CoreAdminHome/Tasks.php b/plugins/CoreAdminHome/Tasks.php index a796708477..e68b035299 100644 --- a/plugins/CoreAdminHome/Tasks.php +++ b/plugins/CoreAdminHome/Tasks.php @@ -196,6 +196,7 @@ class Tasks extends \Piwik\Plugin\Tasks */ public function notifyTrackingFailures() { + $this->cleanupTrackingFailures(); $failures = $this->trackingFailures->getAllFailures(); $general = Config::getInstance()->General; if (!empty($failures) && $general['enable_tracking_failures_notification']) { diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php index d7ebb79489..306a27ed23 100644 --- a/plugins/CoreUpdater/Controller.php +++ b/plugins/CoreUpdater/Controller.php @@ -12,6 +12,7 @@ use Exception; use Piwik\AssetManager; use Piwik\Common; use Piwik\Config; +use Piwik\DataTable\Renderer\Json; use Piwik\DbHelper; use Piwik\Filechecks; use Piwik\FileIntegrity; @@ -172,6 +173,17 @@ class Controller extends \Piwik\Plugin\Controller return $view->render(); } + public function oneClickUpdatePartTwo() + { + Piwik::checkUserHasSuperUserAccess(); + + Json::sendHeaderJSON(); + + $messages = $this->updater->oneClickUpdatePartTwo(); + + echo json_encode($messages); + } + public function oneClickResults() { Filesystem::deleteAllCacheOnUpdate(); diff --git a/plugins/CoreUpdater/Updater.php b/plugins/CoreUpdater/Updater.php index 7baee1d46a..d3f8f54e1c 100644 --- a/plugins/CoreUpdater/Updater.php +++ b/plugins/CoreUpdater/Updater.php @@ -23,6 +23,7 @@ use Piwik\Plugins\Marketplace\Marketplace; use Piwik\SettingsServer; use Piwik\Translation\Translator; use Piwik\Unzip; +use Piwik\Url; use Piwik\Version; class Updater @@ -114,21 +115,6 @@ class Updater $this->verifyDecompressedArchive($extractedArchiveDirectory); $messages[] = $this->translator->translate('CoreUpdater_VerifyingUnpackedFiles'); - if (Marketplace::isMarketplaceEnabled()) { - // we need to load the marketplace already here, otherwise it will use the new, updated file in Piwik 3 - - // we also need to make sure to create a new instance here as otherwise we would change the "global" - // environment, but we only want to change piwik version temporarily for this task here - $environment = StaticContainer::getContainer()->make('Piwik\Plugins\Marketplace\Environment'); - $environment->setPiwikVersion($newVersion); - /** @var \Piwik\Plugins\Marketplace\Api\Client $marketplaceClient */ - $marketplaceClient = StaticContainer::getContainer()->make('Piwik\Plugins\Marketplace\Api\Client', array( - 'environment' => $environment - )); - require_once PIWIK_DOCUMENT_ROOT . '/plugins/CorePluginsAdmin/PluginInstaller.php'; - require_once PIWIK_DOCUMENT_ROOT . '/plugins/Marketplace/Api/Exception.php'; - } - $this->installNewFiles($extractedArchiveDirectory); $messages[] = $this->translator->translate('CoreUpdater_InstallingTheLatestVersion'); @@ -138,9 +124,45 @@ class Updater throw new UpdaterException($e, $messages); } + $partTwoUrl = Url::getCurrentUrlWithoutQueryString() . Url::getCurrentQueryStringWithParametersModified([ + 'action' => 'oneClickUpdatePartTwo', + ]); + + $response = Http::sendHttpRequest($partTwoUrl, 300); + $response = @json_decode($response, $assoc = true); + + $messages = array_merge($messages, $response); + + try { + $disabledPluginNames = $this->disableIncompatiblePlugins($newVersion); + if (!empty($disabledPluginNames)) { + $messages[] = $this->translator->translate('CoreUpdater_DisablingIncompatiblePlugins', implode(', ', $disabledPluginNames)); + } + } catch (Exception $e) { + throw new UpdaterException($e, $messages); + } + + return $messages; + } + + public function oneClickUpdatePartTwo() + { + $messages = []; + + $newVersion = Version::VERSION; + + // we also need to make sure to create a new instance here as otherwise we would change the "global" + // environment, but we only want to change piwik version temporarily for this task here + $environment = StaticContainer::getContainer()->make('Piwik\Plugins\Marketplace\Environment'); + $environment->setPiwikVersion($newVersion); + /** @var \Piwik\Plugins\Marketplace\Api\Client $marketplaceClient */ + $marketplaceClient = StaticContainer::getContainer()->make('Piwik\Plugins\Marketplace\Api\Client', array( + 'environment' => $environment + )); + try { - if (Marketplace::isMarketplaceEnabled() && !empty($marketplaceClient)) { + if (Marketplace::isMarketplaceEnabled()) { $messages[] = $this->translator->translate('CoreUpdater_CheckingForPluginUpdates'); $pluginManager = PluginManager::getInstance(); $pluginManager->loadAllPluginsAndGetTheirInfo(); @@ -152,7 +174,7 @@ class Updater foreach ($pluginsWithUpdate as $pluginWithUpdate) { $pluginName = $pluginWithUpdate['name']; $messages[] = $this->translator->translate('CoreUpdater_UpdatingPluginXToVersionY', - array($pluginName, $pluginWithUpdate['version'])); + array($pluginName, $pluginWithUpdate['version'])); $pluginInstaller = new PluginInstaller($marketplaceClient); $pluginInstaller->installOrUpdatePluginFromMarketplace($pluginName); } @@ -163,15 +185,6 @@ class Updater throw new UpdaterException($e, $messages); } - try { - $disabledPluginNames = $this->disableIncompatiblePlugins($newVersion); - if (!empty($disabledPluginNames)) { - $messages[] = $this->translator->translate('CoreUpdater_DisablingIncompatiblePlugins', implode(', ', $disabledPluginNames)); - } - } catch (Exception $e) { - throw new UpdaterException($e, $messages); - } - return $messages; } diff --git a/plugins/Events/Columns/EventAction.php b/plugins/Events/Columns/EventAction.php index 791a45e52e..166d0b03b7 100644 --- a/plugins/Events/Columns/EventAction.php +++ b/plugins/Events/Columns/EventAction.php @@ -24,6 +24,7 @@ class EventAction extends ActionDimension protected $segmentName = 'eventAction'; protected $nameSingular = 'Events_EventAction'; protected $namePlural = 'Events_EventActions'; + protected $suggestedValuesApi = 'Events.getAction'; protected $category = 'Events_Events'; protected $sqlFilter = '\Piwik\Tracker\TableLogAction::getIdActionFromSegment'; diff --git a/plugins/Events/Columns/EventCategory.php b/plugins/Events/Columns/EventCategory.php index fe417d2db8..98c717e689 100644 --- a/plugins/Events/Columns/EventCategory.php +++ b/plugins/Events/Columns/EventCategory.php @@ -24,6 +24,7 @@ class EventCategory extends ActionDimension protected $category = 'Events_Events'; protected $sqlFilter = '\Piwik\Tracker\TableLogAction::getIdActionFromSegment'; protected $segmentName = 'eventCategory'; + protected $suggestedValuesApi = 'Events.getCategory'; protected $nameSingular = 'Events_EventCategory'; protected $namePlural = 'Events_EventCategories'; diff --git a/plugins/Events/Columns/EventName.php b/plugins/Events/Columns/EventName.php index 720bb700c1..62a441e601 100644 --- a/plugins/Events/Columns/EventName.php +++ b/plugins/Events/Columns/EventName.php @@ -22,6 +22,8 @@ class EventName extends ActionDimension protected $category = 'Events_Events'; protected $sqlFilter = '\Piwik\Tracker\TableLogAction::getIdActionFromSegment'; protected $segmentName = 'eventName'; + protected $suggestedValuesApi = 'Events.getName'; + protected $nameSingular = 'Events_EventName'; protected $namePlural = 'Events_EventNames'; |