Skip to content

Commit

Permalink
Merge branch 'develop' into bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Voskoboinikov committed Aug 4, 2017
2 parents 05d1579 + 249863e commit 77a07fb
Show file tree
Hide file tree
Showing 586 changed files with 12,685 additions and 6,768 deletions.
23 changes: 11 additions & 12 deletions app/code/Magento/AdminNotification/i18n/en_US.csv
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"Read Details","Read Details"
"Mark as Read","Mark as Read"
"Are you sure?","Are you sure?"
"Remove","Remove"
Remove,Remove
"Messages Inbox","Messages Inbox"
"You have %1 new system messages","You have %1 new system messages"
"You have %1 new system message","You have %1 new system message"
"Incoming Message","Incoming Message"
"close","close"
"Notifications","Notifications"
close,close
Notifications,Notifications
"The message has been marked as Read.","The message has been marked as Read."
"We couldn't mark the notification as Read because of an error.","We couldn't mark the notification as Read because of an error."
"Please select messages.","Please select messages."
Expand All @@ -20,10 +20,10 @@
"6 Hours","6 Hours"
"12 Hours","12 Hours"
"24 Hours","24 Hours"
"critical","critical"
"major","major"
"minor","minor"
"notice","notice"
critical,critical
major,major
minor,minor
notice,notice
"Wrong message type","Wrong message type"
"Wrong notification ID specified.","Wrong notification ID specified."
"{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure URL / Base Secure URL. We highly recommend changing this value in your Magento <a href=""%1"">configuration</a>.","{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure URL / Base Secure URL. We highly recommend changing this value in your Magento <a href=""%1"">configuration</a>."
Expand All @@ -32,20 +32,19 @@
"We were unable to synchronize one or more media files. Please refer to the log file for details.","We were unable to synchronize one or more media files. Please refer to the log file for details."
"Synchronization of media storages has been completed.","Synchronization of media storages has been completed."
"Your web server is set up incorrectly and allows unauthorized access to sensitive files. Please contact your hosting provider.","Your web server is set up incorrectly and allows unauthorized access to sensitive files. Please contact your hosting provider."
"Close popup","Close popup"
"Close","Close"
"System Messages:","System Messages:"
"Critical System Messages","Critical System Messages"
"Major System Messages","Major System Messages"
"System messages","System messages"
Close,Close
"See All (","See All ("
" unread)"," unread)"
"Show Toolbar","Show Toolbar"
"Show List","Show List"
"Use HTTPS to Get Feed","Use HTTPS to Get Feed"
"Update Frequency","Update Frequency"
"Last Update","Last Update"
"Severity","Severity"
Severity,Severity
"Date Added","Date Added"
"Message","Message"
"Actions","Actions"
Message,Message
Actions,Actions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"Please correct the data sent.","Please correct the data sent."
"Entity type model \'%1\' is not found","Entity type model \'%1\' is not found"
"Entity type model '%1' is not found","Entity type model '%1' is not found"
"Entity type model must be an instance of \Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType","Entity type model must be an instance of \Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType"
"There are no product types available for export","There are no product types available for export"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\Analytics\Controller\Adminhtml\Reports;

use Magento\Analytics\Model\Exception\State\SubscriptionUpdateException;
use Magento\Analytics\Model\ReportUrlProvider;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
Expand Down Expand Up @@ -55,6 +56,9 @@ public function execute()
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
try {
$resultRedirect->setUrl($this->reportUrlProvider->getUrl());
} catch (SubscriptionUpdateException $e) {
$this->getMessageManager()->addNoticeMessage($e->getMessage());
$resultRedirect->setPath('adminhtml');
} catch (LocalizedException $e) {
$this->getMessageManager()->addExceptionMessage($e, $e->getMessage());
$resultRedirect->setPath('adminhtml');
Expand Down
41 changes: 28 additions & 13 deletions app/code/Magento/Analytics/Cron/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
*/
namespace Magento\Analytics\Cron;

use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
use Magento\Analytics\Model\Connector;
use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;

/**
* Class Update
* Executes by cron schedule in case base url was changed
*/
class Update
Expand All @@ -28,8 +28,6 @@ class Update
private $configWriter;

/**
* Reinitable Config Model.
*
* @var ReinitableConfigInterface
*/
private $reinitableConfig;
Expand All @@ -40,22 +38,29 @@ class Update
private $flagManager;

/**
* Update constructor.
* @var AnalyticsToken
*/
private $analyticsToken;

/**
* @param Connector $connector
* @param WriterInterface $configWriter
* @param ReinitableConfigInterface $reinitableConfig
* @param FlagManager $flagManager
* @param AnalyticsToken $analyticsToken
*/
public function __construct(
Connector $connector,
WriterInterface $configWriter,
ReinitableConfigInterface $reinitableConfig,
FlagManager $flagManager
FlagManager $flagManager,
AnalyticsToken $analyticsToken
) {
$this->connector = $connector;
$this->configWriter = $configWriter;
$this->reinitableConfig = $reinitableConfig;
$this->flagManager = $flagManager;
$this->analyticsToken = $analyticsToken;
}

/**
Expand All @@ -65,13 +70,23 @@ public function __construct(
*/
public function execute()
{
$updateResult = $this->connector->execute('update');
if ($updateResult === false) {
return false;
$result = false;
$attemptsCount = $this->flagManager
->getFlagData(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);

if ($attemptsCount) {
$attemptsCount -= 1;
$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->configWriter->delete(BaseUrlConfigPlugin::UPDATE_CRON_STRING_PATH);
$this->flagManager->deleteFlag(BaseUrlConfigPlugin::OLD_BASE_URL_FLAG_CODE);
$this->reinitableConfig->reinit();
return true;

return $result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Analytics\Model\Config\Backend\Baseurl;

use Magento\Analytics\Model\AnalyticsToken;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;

/**
* Class for processing of change of Base URL.
*/
class SubscriptionUpdateHandler
{
/**
* Flag code for a reserve counter to update subscription.
*/
const SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE = 'analytics_link_subscription_update_reverse_counter';

/**
* Config path for schedule setting of update handler.
*/
const UPDATE_CRON_STRING_PATH = "crontab/default/jobs/analytics_update/schedule/cron_expr";

/**
* Flag code for the previous Base URL.
*/
const PREVIOUS_BASE_URL_FLAG_CODE = 'analytics_previous_base_url';

/**
* Max value for a reserve counter to update subscription.
*
* @var int
*/
private $attemptsInitValue = 48;

/**
* @var WriterInterface
*/
private $configWriter;

/**
* Cron expression for a update handler.
*
* @var string
*/
private $cronExpression = '0 * * * *';

/**
* @var FlagManager
*/
private $flagManager;

/**
* @var ReinitableConfigInterface
*/
private $reinitableConfig;

/**
* @var AnalyticsToken
*/
private $analyticsToken;

/**
* @param AnalyticsToken $analyticsToken
* @param FlagManager $flagManager
* @param ReinitableConfigInterface $reinitableConfig
* @param WriterInterface $configWriter
*/
public function __construct(
AnalyticsToken $analyticsToken,
FlagManager $flagManager,
ReinitableConfigInterface $reinitableConfig,
WriterInterface $configWriter
) {
$this->analyticsToken = $analyticsToken;
$this->flagManager = $flagManager;
$this->reinitableConfig = $reinitableConfig;
$this->configWriter = $configWriter;
}

/**
* Activate process of subscription update handling.
*
* @param string $url
* @return bool
*/
public function processUrlUpdate(string $url)
{
if ($this->analyticsToken->isTokenExist()) {
if (!$this->flagManager->getFlagData(self::PREVIOUS_BASE_URL_FLAG_CODE)) {
$this->flagManager->saveFlag(self::PREVIOUS_BASE_URL_FLAG_CODE, $url);
}

$this->flagManager
->saveFlag(self::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue);
$this->configWriter->save(self::UPDATE_CRON_STRING_PATH, $this->cronExpression);
$this->reinitableConfig->reinit();
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
namespace Magento\Analytics\Model\Connector;

use Magento\Analytics\Model\AnalyticsToken;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\HTTP\ZendClient;
use Magento\Config\Model\Config;
use Psr\Log\LoggerInterface;
use Magento\Store\Model\Store;
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
Expand All @@ -33,7 +33,7 @@ class NotifyDataChangedCommand implements CommandInterface
private $httpClient;

/**
* @var Config
* @var ScopeConfigInterface
*/
private $config;

Expand All @@ -51,14 +51,14 @@ class NotifyDataChangedCommand implements CommandInterface
* NotifyDataChangedCommand constructor.
* @param AnalyticsToken $analyticsToken
* @param Http\ClientInterface $httpClient
* @param Config $config
* @param ScopeConfigInterface $config
* @param ResponseResolver $responseResolver
* @param LoggerInterface $logger
*/
public function __construct(
AnalyticsToken $analyticsToken,
Http\ClientInterface $httpClient,
Config $config,
ScopeConfigInterface $config,
ResponseResolver $responseResolver,
LoggerInterface $logger
) {
Expand All @@ -80,16 +80,14 @@ public function execute()
if ($this->analyticsToken->isTokenExist()) {
$response = $this->httpClient->request(
ZendClient::POST,
$this->config->getConfigDataValue($this->notifyDataChangedUrlPath),
$this->config->getValue($this->notifyDataChangedUrlPath),
[
"access-token" => $this->analyticsToken->getToken(),
"url" => $this->config->getConfigDataValue(
Store::XML_PATH_SECURE_BASE_URL
),
"url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL),
]
);
$result = $this->responseResolver->getResult($response);
}
return $result;
return (bool)$result;
}
}
16 changes: 7 additions & 9 deletions app/code/Magento/Analytics/Model/Connector/SignUpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
use Magento\Analytics\Model\IntegrationManager;
use Magento\Config\Model\Config;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Psr\Log\LoggerInterface;
use Magento\Framework\HTTP\ZendClient;
use Magento\Store\Model\Store;
Expand Down Expand Up @@ -36,7 +36,7 @@ class SignUpCommand implements CommandInterface
private $integrationManager;

/**
* @var Config
* @var ScopeConfigInterface
*/
private $config;

Expand All @@ -60,15 +60,15 @@ class SignUpCommand implements CommandInterface
*
* @param AnalyticsToken $analyticsToken
* @param IntegrationManager $integrationManager
* @param Config $config
* @param ScopeConfigInterface $config
* @param Http\ClientInterface $httpClient
* @param LoggerInterface $logger
* @param ResponseResolver $responseResolver
*/
public function __construct(
AnalyticsToken $analyticsToken,
IntegrationManager $integrationManager,
Config $config,
ScopeConfigInterface $config,
Http\ClientInterface $httpClient,
LoggerInterface $logger,
ResponseResolver $responseResolver
Expand Down Expand Up @@ -101,12 +101,10 @@ public function execute()
$this->integrationManager->activateIntegration();
$response = $this->httpClient->request(
ZendClient::POST,
$this->config->getConfigDataValue($this->signUpUrlPath),
$this->config->getValue($this->signUpUrlPath),
[
"token" => $integrationToken->getData('token'),
"url" => $this->config->getConfigDataValue(
Store::XML_PATH_SECURE_BASE_URL
)
"url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL),
]
);

Expand All @@ -121,6 +119,6 @@ public function execute()
}
}

return $result;
return (bool)$result;
}
}
Loading

0 comments on commit 77a07fb

Please sign in to comment.