Skip to content

Commit 5fb5345

Browse files
author
Sergii Kovalenko
committed
Merge branch '2.2-develop' of https://github.com/magento/magento2ce into MAGETWO-69521
2 parents 2f97020 + 47361f8 commit 5fb5345

File tree

415 files changed

+7768
-5449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

415 files changed

+7768
-5449
lines changed
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"Read Details","Read Details"
22
"Mark as Read","Mark as Read"
33
"Are you sure?","Are you sure?"
4-
"Remove","Remove"
4+
Remove,Remove
55
"Messages Inbox","Messages Inbox"
66
"You have %1 new system messages","You have %1 new system messages"
77
"You have %1 new system message","You have %1 new system message"
88
"Incoming Message","Incoming Message"
9-
"close","close"
10-
"Notifications","Notifications"
9+
close,close
10+
Notifications,Notifications
1111
"The message has been marked as Read.","The message has been marked as Read."
1212
"We couldn't mark the notification as Read because of an error.","We couldn't mark the notification as Read because of an error."
1313
"Please select messages.","Please select messages."
@@ -20,10 +20,10 @@
2020
"6 Hours","6 Hours"
2121
"12 Hours","12 Hours"
2222
"24 Hours","24 Hours"
23-
"critical","critical"
24-
"major","major"
25-
"minor","minor"
26-
"notice","notice"
23+
critical,critical
24+
major,major
25+
minor,minor
26+
notice,notice
2727
"Wrong message type","Wrong message type"
2828
"Wrong notification ID specified.","Wrong notification ID specified."
2929
"{{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>."
@@ -32,20 +32,19 @@
3232
"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."
3333
"Synchronization of media storages has been completed.","Synchronization of media storages has been completed."
3434
"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."
35-
"Close popup","Close popup"
36-
"Close","Close"
3735
"System Messages:","System Messages:"
3836
"Critical System Messages","Critical System Messages"
3937
"Major System Messages","Major System Messages"
4038
"System messages","System messages"
39+
Close,Close
4140
"See All (","See All ("
4241
" unread)"," unread)"
4342
"Show Toolbar","Show Toolbar"
4443
"Show List","Show List"
4544
"Use HTTPS to Get Feed","Use HTTPS to Get Feed"
4645
"Update Frequency","Update Frequency"
4746
"Last Update","Last Update"
48-
"Severity","Severity"
47+
Severity,Severity
4948
"Date Added","Date Added"
50-
"Message","Message"
51-
"Actions","Actions"
49+
Message,Message
50+
Actions,Actions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"Please correct the data sent.","Please correct the data sent."
2-
"Entity type model \'%1\' is not found","Entity type model \'%1\' is not found"
2+
"Entity type model '%1' is not found","Entity type model '%1' is not found"
33
"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"
44
"There are no product types available for export","There are no product types available for export"

app/code/Magento/Analytics/Controller/Adminhtml/Reports/Show.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Analytics\Controller\Adminhtml\Reports;
77

8+
use Magento\Analytics\Model\Exception\State\SubscriptionUpdateException;
89
use Magento\Analytics\Model\ReportUrlProvider;
910
use Magento\Backend\App\Action;
1011
use Magento\Backend\App\Action\Context;
@@ -55,6 +56,9 @@ public function execute()
5556
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
5657
try {
5758
$resultRedirect->setUrl($this->reportUrlProvider->getUrl());
59+
} catch (SubscriptionUpdateException $e) {
60+
$this->getMessageManager()->addNoticeMessage($e->getMessage());
61+
$resultRedirect->setPath('adminhtml');
5862
} catch (LocalizedException $e) {
5963
$this->getMessageManager()->addExceptionMessage($e, $e->getMessage());
6064
$resultRedirect->setPath('adminhtml');

app/code/Magento/Analytics/Cron/Update.php

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
*/
66
namespace Magento\Analytics\Cron;
77

8+
use Magento\Analytics\Model\AnalyticsToken;
9+
use Magento\Analytics\Model\Config\Backend\Baseurl\SubscriptionUpdateHandler;
810
use Magento\Analytics\Model\Connector;
9-
use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
1011
use Magento\Framework\FlagManager;
1112
use Magento\Framework\App\Config\ReinitableConfigInterface;
1213
use Magento\Framework\App\Config\Storage\WriterInterface;
1314

1415
/**
15-
* Class Update
1616
* Executes by cron schedule in case base url was changed
1717
*/
1818
class Update
@@ -28,8 +28,6 @@ class Update
2828
private $configWriter;
2929

3030
/**
31-
* Reinitable Config Model.
32-
*
3331
* @var ReinitableConfigInterface
3432
*/
3533
private $reinitableConfig;
@@ -40,22 +38,29 @@ class Update
4038
private $flagManager;
4139

4240
/**
43-
* Update constructor.
41+
* @var AnalyticsToken
42+
*/
43+
private $analyticsToken;
44+
45+
/**
4446
* @param Connector $connector
4547
* @param WriterInterface $configWriter
4648
* @param ReinitableConfigInterface $reinitableConfig
4749
* @param FlagManager $flagManager
50+
* @param AnalyticsToken $analyticsToken
4851
*/
4952
public function __construct(
5053
Connector $connector,
5154
WriterInterface $configWriter,
5255
ReinitableConfigInterface $reinitableConfig,
53-
FlagManager $flagManager
56+
FlagManager $flagManager,
57+
AnalyticsToken $analyticsToken
5458
) {
5559
$this->connector = $connector;
5660
$this->configWriter = $configWriter;
5761
$this->reinitableConfig = $reinitableConfig;
5862
$this->flagManager = $flagManager;
63+
$this->analyticsToken = $analyticsToken;
5964
}
6065

6166
/**
@@ -65,13 +70,23 @@ public function __construct(
6570
*/
6671
public function execute()
6772
{
68-
$updateResult = $this->connector->execute('update');
69-
if ($updateResult === false) {
70-
return false;
73+
$result = false;
74+
$attemptsCount = $this->flagManager
75+
->getFlagData(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
76+
77+
if ($attemptsCount) {
78+
$attemptsCount -= 1;
79+
$result = $this->connector->execute('update');
80+
}
81+
82+
if ($result || ($attemptsCount <= 0) || (!$this->analyticsToken->isTokenExist())) {
83+
$this->flagManager
84+
->deleteFlag(SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE);
85+
$this->flagManager->deleteFlag(SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE);
86+
$this->configWriter->delete(SubscriptionUpdateHandler::UPDATE_CRON_STRING_PATH);
87+
$this->reinitableConfig->reinit();
7188
}
72-
$this->configWriter->delete(BaseUrlConfigPlugin::UPDATE_CRON_STRING_PATH);
73-
$this->flagManager->deleteFlag(BaseUrlConfigPlugin::OLD_BASE_URL_FLAG_CODE);
74-
$this->reinitableConfig->reinit();
75-
return true;
89+
90+
return $result;
7691
}
7792
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Analytics\Model\Config\Backend\Baseurl;
8+
9+
use Magento\Analytics\Model\AnalyticsToken;
10+
use Magento\Framework\App\Config\ReinitableConfigInterface;
11+
use Magento\Framework\App\Config\Storage\WriterInterface;
12+
use Magento\Framework\FlagManager;
13+
14+
/**
15+
* Class for processing of change of Base URL.
16+
*/
17+
class SubscriptionUpdateHandler
18+
{
19+
/**
20+
* Flag code for a reserve counter to update subscription.
21+
*/
22+
const SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE = 'analytics_link_subscription_update_reverse_counter';
23+
24+
/**
25+
* Config path for schedule setting of update handler.
26+
*/
27+
const UPDATE_CRON_STRING_PATH = "crontab/default/jobs/analytics_update/schedule/cron_expr";
28+
29+
/**
30+
* Flag code for the previous Base URL.
31+
*/
32+
const PREVIOUS_BASE_URL_FLAG_CODE = 'analytics_previous_base_url';
33+
34+
/**
35+
* Max value for a reserve counter to update subscription.
36+
*
37+
* @var int
38+
*/
39+
private $attemptsInitValue = 48;
40+
41+
/**
42+
* @var WriterInterface
43+
*/
44+
private $configWriter;
45+
46+
/**
47+
* Cron expression for a update handler.
48+
*
49+
* @var string
50+
*/
51+
private $cronExpression = '0 * * * *';
52+
53+
/**
54+
* @var FlagManager
55+
*/
56+
private $flagManager;
57+
58+
/**
59+
* @var ReinitableConfigInterface
60+
*/
61+
private $reinitableConfig;
62+
63+
/**
64+
* @var AnalyticsToken
65+
*/
66+
private $analyticsToken;
67+
68+
/**
69+
* @param AnalyticsToken $analyticsToken
70+
* @param FlagManager $flagManager
71+
* @param ReinitableConfigInterface $reinitableConfig
72+
* @param WriterInterface $configWriter
73+
*/
74+
public function __construct(
75+
AnalyticsToken $analyticsToken,
76+
FlagManager $flagManager,
77+
ReinitableConfigInterface $reinitableConfig,
78+
WriterInterface $configWriter
79+
) {
80+
$this->analyticsToken = $analyticsToken;
81+
$this->flagManager = $flagManager;
82+
$this->reinitableConfig = $reinitableConfig;
83+
$this->configWriter = $configWriter;
84+
}
85+
86+
/**
87+
* Activate process of subscription update handling.
88+
*
89+
* @param string $url
90+
* @return bool
91+
*/
92+
public function processUrlUpdate(string $url)
93+
{
94+
if ($this->analyticsToken->isTokenExist()) {
95+
if (!$this->flagManager->getFlagData(self::PREVIOUS_BASE_URL_FLAG_CODE)) {
96+
$this->flagManager->saveFlag(self::PREVIOUS_BASE_URL_FLAG_CODE, $url);
97+
}
98+
99+
$this->flagManager
100+
->saveFlag(self::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE, $this->attemptsInitValue);
101+
$this->configWriter->save(self::UPDATE_CRON_STRING_PATH, $this->cronExpression);
102+
$this->reinitableConfig->reinit();
103+
}
104+
105+
return true;
106+
}
107+
}

app/code/Magento/Analytics/Model/Connector/NotifyDataChangedCommand.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
namespace Magento\Analytics\Model\Connector;
77

88
use Magento\Analytics\Model\AnalyticsToken;
9+
use Magento\Framework\App\Config\ScopeConfigInterface;
910
use Magento\Framework\HTTP\ZendClient;
10-
use Magento\Config\Model\Config;
1111
use Psr\Log\LoggerInterface;
1212
use Magento\Store\Model\Store;
1313
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
@@ -33,7 +33,7 @@ class NotifyDataChangedCommand implements CommandInterface
3333
private $httpClient;
3434

3535
/**
36-
* @var Config
36+
* @var ScopeConfigInterface
3737
*/
3838
private $config;
3939

@@ -51,14 +51,14 @@ class NotifyDataChangedCommand implements CommandInterface
5151
* NotifyDataChangedCommand constructor.
5252
* @param AnalyticsToken $analyticsToken
5353
* @param Http\ClientInterface $httpClient
54-
* @param Config $config
54+
* @param ScopeConfigInterface $config
5555
* @param ResponseResolver $responseResolver
5656
* @param LoggerInterface $logger
5757
*/
5858
public function __construct(
5959
AnalyticsToken $analyticsToken,
6060
Http\ClientInterface $httpClient,
61-
Config $config,
61+
ScopeConfigInterface $config,
6262
ResponseResolver $responseResolver,
6363
LoggerInterface $logger
6464
) {
@@ -80,16 +80,14 @@ public function execute()
8080
if ($this->analyticsToken->isTokenExist()) {
8181
$response = $this->httpClient->request(
8282
ZendClient::POST,
83-
$this->config->getConfigDataValue($this->notifyDataChangedUrlPath),
83+
$this->config->getValue($this->notifyDataChangedUrlPath),
8484
[
8585
"access-token" => $this->analyticsToken->getToken(),
86-
"url" => $this->config->getConfigDataValue(
87-
Store::XML_PATH_SECURE_BASE_URL
88-
),
86+
"url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL),
8987
]
9088
);
9189
$result = $this->responseResolver->getResult($response);
9290
}
93-
return $result;
91+
return (bool)$result;
9492
}
9593
}

app/code/Magento/Analytics/Model/Connector/SignUpCommand.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Magento\Analytics\Model\AnalyticsToken;
99
use Magento\Analytics\Model\Connector\Http\ResponseResolver;
1010
use Magento\Analytics\Model\IntegrationManager;
11-
use Magento\Config\Model\Config;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
1212
use Psr\Log\LoggerInterface;
1313
use Magento\Framework\HTTP\ZendClient;
1414
use Magento\Store\Model\Store;
@@ -36,7 +36,7 @@ class SignUpCommand implements CommandInterface
3636
private $integrationManager;
3737

3838
/**
39-
* @var Config
39+
* @var ScopeConfigInterface
4040
*/
4141
private $config;
4242

@@ -60,15 +60,15 @@ class SignUpCommand implements CommandInterface
6060
*
6161
* @param AnalyticsToken $analyticsToken
6262
* @param IntegrationManager $integrationManager
63-
* @param Config $config
63+
* @param ScopeConfigInterface $config
6464
* @param Http\ClientInterface $httpClient
6565
* @param LoggerInterface $logger
6666
* @param ResponseResolver $responseResolver
6767
*/
6868
public function __construct(
6969
AnalyticsToken $analyticsToken,
7070
IntegrationManager $integrationManager,
71-
Config $config,
71+
ScopeConfigInterface $config,
7272
Http\ClientInterface $httpClient,
7373
LoggerInterface $logger,
7474
ResponseResolver $responseResolver
@@ -101,12 +101,10 @@ public function execute()
101101
$this->integrationManager->activateIntegration();
102102
$response = $this->httpClient->request(
103103
ZendClient::POST,
104-
$this->config->getConfigDataValue($this->signUpUrlPath),
104+
$this->config->getValue($this->signUpUrlPath),
105105
[
106106
"token" => $integrationToken->getData('token'),
107-
"url" => $this->config->getConfigDataValue(
108-
Store::XML_PATH_SECURE_BASE_URL
109-
)
107+
"url" => $this->config->getValue(Store::XML_PATH_SECURE_BASE_URL),
110108
]
111109
);
112110

@@ -121,6 +119,6 @@ public function execute()
121119
}
122120
}
123121

124-
return $result;
122+
return (bool)$result;
125123
}
126124
}

0 commit comments

Comments
 (0)