Skip to content

Commit 975843c

Browse files
author
Oleksii Korshenko
committed
MAGETWO-71532: Fix swagger-ui on instances of Magento running on a non-standard port #10504
- Merge Pull Request #10504 from aredridel/magento2:fix-swagger-host-on-port - Merged commits: 1. 236bda4
2 parents c955c32 + 236bda4 commit 975843c

File tree

811 files changed

+16566
-8701
lines changed

Some content is hidden

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

811 files changed

+16566
-8701
lines changed

app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,35 @@
66
*/
77
namespace Magento\AdminNotification\Controller\Adminhtml\Notification;
88

9+
use Magento\Backend\App\Action;
10+
use Magento\Framework\Controller\ResultFactory;
11+
912
class AjaxMarkAsRead extends \Magento\AdminNotification\Controller\Adminhtml\Notification
1013
{
14+
/**
15+
* @var \Magento\AdminNotification\Model\NotificationService
16+
*/
17+
private $notificationService;
18+
19+
/**
20+
* @param Action\Context $context
21+
* @param \Magento\AdminNotification\Model\NotificationService|null $notificationService
22+
* @throws \RuntimeException
23+
*/
24+
public function __construct(
25+
Action\Context $context,
26+
\Magento\AdminNotification\Model\NotificationService $notificationService = null
27+
) {
28+
parent::__construct($context);
29+
$this->notificationService = $notificationService?: \Magento\Framework\App\ObjectManager::getInstance()
30+
->get(\Magento\AdminNotification\Model\NotificationService::class);
31+
}
32+
1133
/**
1234
* Mark notification as read (AJAX action)
1335
*
14-
* @return void
36+
* @return \Magento\Framework\Controller\Result\Json|void
37+
* @throws \InvalidArgumentException
1538
*/
1639
public function execute()
1740
{
@@ -21,17 +44,15 @@ public function execute()
2144
$notificationId = (int)$this->getRequest()->getPost('id');
2245
$responseData = [];
2346
try {
24-
$this->_objectManager->create(
25-
\Magento\AdminNotification\Model\NotificationService::class
26-
)->markAsRead(
27-
$notificationId
28-
);
47+
$this->notificationService->markAsRead($notificationId);
2948
$responseData['success'] = true;
3049
} catch (\Exception $e) {
3150
$responseData['success'] = false;
3251
}
33-
$this->getResponse()->representJson(
34-
$this->_objectManager->create(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($responseData)
35-
);
52+
53+
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
54+
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
55+
$resultJson->setData($responseData);
56+
return $resultJson;
3657
}
3758
}

app/code/Magento/AdminNotification/composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
"description": "N/A",
44
"require": {
55
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
6-
"magento/module-store": "100.2.*",
7-
"magento/module-backend": "100.2.*",
8-
"magento/module-media-storage": "100.2.*",
9-
"magento/framework": "100.2.*",
10-
"magento/module-ui": "100.2.*",
6+
"magento/module-store": "100.3.*",
7+
"magento/module-backend": "100.3.*",
8+
"magento/module-media-storage": "100.3.*",
9+
"magento/framework": "100.3.*",
10+
"magento/module-ui": "100.3.*",
1111
"lib-libxml": "*"
1212
},
1313
"type": "magento2-module",
14-
"version": "100.2.0-dev",
14+
"version": "100.3.0-dev",
1515
"license": [
1616
"OSL-3.0",
1717
"AFL-3.0"
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

app/code/Magento/AdvancedPricingImportExport/composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
"description": "N/A",
44
"require": {
55
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
6-
"magento/module-catalog": "101.1.*",
7-
"magento/module-catalog-inventory": "100.2.*",
8-
"magento/module-eav": "100.2.*",
9-
"magento/module-import-export": "100.2.*",
10-
"magento/module-catalog-import-export": "100.2.*",
11-
"magento/module-customer": "100.2.*",
12-
"magento/module-store": "100.2.*",
13-
"magento/framework": "100.2.*"
6+
"magento/module-catalog": "101.2.*",
7+
"magento/module-catalog-inventory": "100.3.*",
8+
"magento/module-eav": "100.3.*",
9+
"magento/module-import-export": "100.3.*",
10+
"magento/module-catalog-import-export": "100.3.*",
11+
"magento/module-customer": "100.3.*",
12+
"magento/module-store": "100.3.*",
13+
"magento/framework": "100.3.*"
1414
},
1515
"type": "magento2-module",
16-
"version": "100.2.0-dev",
16+
"version": "100.3.0-dev",
1717
"license": [
1818
"OSL-3.0",
1919
"AFL-3.0"
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+
}

0 commit comments

Comments
 (0)