Skip to content

Commit

Permalink
Merge branch '2.4-develop' into issue-27358
Browse files Browse the repository at this point in the history
  • Loading branch information
diazwatson committed Mar 30, 2020
2 parents 0e964e4 + 176ba2b commit 3c64566
Show file tree
Hide file tree
Showing 1,676 changed files with 49,395 additions and 28,236 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ If you are a new GitHub user, we recommend that you create your own [free github
This will allow you to collaborate with the Magento 2 development team, fork the Magento 2 project and send pull requests.

1. Search current [listed issues](https://github.com/magento/magento2/issues) (open or closed) for similar proposals of intended contribution before starting work on a new contribution.
2. Review the [Contributor License Agreement](https://magento.com/legaldocuments/mca) if this is your first time contributing.
2. Review the [Contributor License Agreement](https://opensource.adobe.com/cla.html) if this is your first time contributing.
3. Create and test your work.
4. Fork the Magento 2 repository according to the [Fork A Repository instructions](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow the [Create A Pull Request instructions](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#pull_request).
5. Once your contribution is received the Magento 2 development team will review the contribution and collaborate with you as needed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="LoginAdminWithCredentialsActionGroup" deprecated="Use AdminLoginActionGroup instead">
<conditionalClick selector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" dependentSelector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" visible="true" stepKey="clickDontAllowButtonIfVisible" before="closeAdminNotification"/>
</actionGroup>
<actionGroup name="LoginAsAdmin" deprecated="Use AdminLoginActionGroup instead">
<conditionalClick selector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" dependentSelector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" visible="true" stepKey="clickDontAllowButtonIfVisible" before="closeAdminNotification"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="LoginAsAdmin" deprecated="Use AdminLoginActionGroup instead">
<conditionalClick selector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" dependentSelector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" visible="true" stepKey="clickDontAllowButtonIfVisible" before="closeAdminNotification"/>
</actionGroup>
</actionGroups>
11 changes: 7 additions & 4 deletions app/code/Magento/Analytics/Cron/SignUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Analytics\Model\Connector;
use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
Expand Down Expand Up @@ -57,22 +58,24 @@ public function __construct(
}

/**
* Execute scheduled subscription operation
* Execute scheduled subscription operation.
*
* In case of failure writes message to notifications inbox
*
* @return bool
* @throws NotFoundException
*/
public function execute()
{
$attemptsCount = $this->flagManager->getFlagData(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE);
$attemptsCount = (int)$this->flagManager->getFlagData(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE);

if (($attemptsCount === null) || ($attemptsCount <= 0)) {
if ($attemptsCount <= 0) {
$this->deleteAnalyticsCronExpr();
$this->flagManager->deleteFlag(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE);
return false;
}

$attemptsCount -= 1;
$attemptsCount--;
$this->flagManager->saveFlag(SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE, $attemptsCount);
$signUpResult = $this->connector->execute('signUp');
if ($signUpResult === false) {
Expand Down
28 changes: 20 additions & 8 deletions app/code/Magento/Analytics/Cron/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Connector;
use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
Expand Down Expand Up @@ -67,26 +68,37 @@ public function __construct(
* Execute scheduled update operation
*
* @return bool
* @throws NotFoundException
*/
public function execute()
{
$result = false;
$attemptsCount = $this->flagManager
$attemptsCount = (int)$this->flagManager
->getFlagData(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);

if ($attemptsCount) {
$attemptsCount -= 1;
if (($attemptsCount > 0) && $this->analyticsToken->isTokenExist()) {
$attemptsCount--;
$this->flagManager
->saveFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $attemptsCount);
$result = $this->connector->execute('update');
}

if ($result || ($attemptsCount <= 0) || (!$this->analyticsToken->isTokenExist())) {
$this->flagManager
->deleteFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
$this->flagManager->deleteFlag(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE);
$this->configWriter->delete(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH);
$this->reinitableConfig->reinit();
$this->exitFromUpdateProcess();
}

return $result;
}

/**
* Clean-up flags and refresh configuration
*/
private function exitFromUpdateProcess(): void
{
$this->flagManager
->deleteFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
$this->flagManager->deleteFlag(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE);
$this->configWriter->delete(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH);
$this->reinitableConfig->reinit();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Analytics\Setup\Patch\Data;

use Magento\Analytics\Model\Config\Backend\CollectionTime;
use Magento\Analytics\Model\SubscriptionStatusProvider;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Setup\Patch\DataPatchInterface;

/**
* Activate data collection mechanism
*/
class ActivateDataCollection implements DataPatchInterface
{
/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @var SubscriptionStatusProvider
*/
private $subscriptionStatusProvider;

/**
* @var string
*/
private $analyticsCollectionTimeConfigPath = 'analytics/general/collection_time';

/**
* @var CollectionTime
*/
private $collectionTimeBackendModel;

/**
* @param ScopeConfigInterface $scopeConfig
* @param SubscriptionStatusProvider $subscriptionStatusProvider
* @param CollectionTime $collectionTimeBackendModel
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
SubscriptionStatusProvider $subscriptionStatusProvider,
CollectionTime $collectionTimeBackendModel
) {
$this->scopeConfig = $scopeConfig;
$this->subscriptionStatusProvider = $subscriptionStatusProvider;
$this->collectionTimeBackendModel = $collectionTimeBackendModel;
}

/**
* @inheritDoc
*
* @throws LocalizedException
*/
public function apply()
{
$subscriptionStatus = $this->subscriptionStatusProvider->getStatus();
$isCollectionProcessActivated = $this->scopeConfig->getValue(CollectionTime::CRON_SCHEDULE_PATH);
if ($subscriptionStatus !== $this->subscriptionStatusProvider->getStatusForDisabledSubscription()
&& !$isCollectionProcessActivated
) {
$this->collectionTimeBackendModel
->setValue($this->scopeConfig->getValue($this->analyticsCollectionTimeConfigPath));
$this->collectionTimeBackendModel->setPath($this->analyticsCollectionTimeConfigPath);
$this->collectionTimeBackendModel->afterSave();
}

return $this;
}

/**
* @inheritDoc
*/
public function getAliases()
{
return [];
}

/**
* @inheritDoc
*/
public static function getDependencies()
{
return [
PrepareInitialConfig::class,
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Analytics\Setup\Patch\Data;

use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Config\Model\Config\Source\Enabledisable;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;

/**
* Initial patch.
*
* @package Magento\Analytics\Setup\Patch
* Active subscription process for Advanced Reporting
*/
class PrepareInitialConfig implements DataPatchInterface, PatchVersionInterface
{
Expand All @@ -24,66 +25,63 @@ class PrepareInitialConfig implements DataPatchInterface, PatchVersionInterface
private $moduleDataSetup;

/**
* PrepareInitialConfig constructor.
* @var SubscriptionHandler
*/
private $subscriptionHandler;

/**
* @var string
*/
private $subscriptionEnabledConfigPath = 'analytics/subscription/enabled';

/**
* @param ModuleDataSetupInterface $moduleDataSetup
* @param SubscriptionHandler $subscriptionHandler
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup
ModuleDataSetupInterface $moduleDataSetup,
SubscriptionHandler $subscriptionHandler
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->subscriptionHandler = $subscriptionHandler;
}

/**
* {@inheritdoc}
* @inheritDoc
*/
public function apply()
{
$this->moduleDataSetup->getConnection()->insertMultiple(
$this->moduleDataSetup->getConnection()->insert(
$this->moduleDataSetup->getTable('core_config_data'),
[
[
'scope' => 'default',
'scope_id' => 0,
'path' => 'analytics/subscription/enabled',
'value' => 1
],
[
'scope' => 'default',
'scope_id' => 0,
'path' => SubscriptionHandler::CRON_STRING_PATH,
'value' => join(' ', SubscriptionHandler::CRON_EXPR_ARRAY)
]
'path' => $this->subscriptionEnabledConfigPath,
'value' => Enabledisable::ENABLE_VALUE,
]
);

$this->moduleDataSetup->getConnection()->insert(
$this->moduleDataSetup->getTable('flag'),
[
'flag_code' => SubscriptionHandler::ATTEMPTS_REVERSE_COUNTER_FLAG_CODE,
'state' => 0,
'flag_data' => 24,
]
);
$this->subscriptionHandler->processEnabled();

return $this;
}

/**
* {@inheritdoc}
* @inheritDoc
*/
public static function getDependencies()
{
return [];
}

/**
* {@inheritdoc}
* @inheritDoc
*/
public static function getVersion()
{
return '2.0.0';
}

/**
* {@inheritdoc}
* @inheritDoc
*/
public function getAliases()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
<waitForPageLoad time="30" stepKey="wait2"/>
<seeInField selector="{{AdminEditUserSection.usernameTextField}}" userInput="$$noReportUser.username$$" stepKey="seeUsernameInField"/>
<fillField selector="{{AdminEditUserSection.currentPasswordField}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" stepKey="fillCurrentPassword"/>
<click selector="{{AdminEditUserSection.userRoleTab}}" stepKey="clickUserRoleTab"/>
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>

<click selector="{{AdminEditUserSection.userRoleTab}}" stepKey="clickUserRoleTab"/>
<fillField selector="{{AdminEditUserSection.roleNameFilterTextField}}" userInput="$$noReportUserRole.rolename$$" stepKey="fillRoleNameSearch"/>
<click selector="{{AdminEditUserSection.searchButton}}" stepKey="clickSearchButtonUserRole"/>
<waitForPageLoad time="10" stepKey="wait3"/>
Expand Down
Loading

0 comments on commit 3c64566

Please sign in to comment.