Skip to content

Commit bd10f61

Browse files
author
Roman Lytvynenko
committed
Merge branch '2.3-develop' of https://github.com/magento/magento2ce into MAGETWO-99370
2 parents df4b041 + d3fdecf commit bd10f61

File tree

58 files changed

+875
-676
lines changed

Some content is hidden

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

58 files changed

+875
-676
lines changed

app/code/Magento/AuthorizenetAcceptjs/Gateway/Validator/TransactionResponseValidator.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ public function validate(array $validationSubject): ResultInterface
5454
if (isset($transactionResponse['messages']['message']['code'])) {
5555
$errorCodes[] = $transactionResponse['messages']['message']['code'];
5656
$errorMessages[] = $transactionResponse['messages']['message']['text'];
57-
} elseif ($transactionResponse['messages']['message']) {
57+
} elseif (isset($transactionResponse['messages']['message'])) {
5858
foreach ($transactionResponse['messages']['message'] as $message) {
5959
$errorCodes[] = $message['code'];
6060
$errorMessages[] = $message['description'];
6161
}
6262
} elseif (isset($transactionResponse['errors'])) {
6363
foreach ($transactionResponse['errors'] as $message) {
6464
$errorCodes[] = $message['errorCode'];
65-
$errorMessages[] = $message['errorCode'];
65+
$errorMessages[] = $message['errorText'];
6666
}
6767
}
6868

@@ -85,8 +85,10 @@ private function isResponseCodeAnError(array $transactionResponse): bool
8585
?? $transactionResponse['errors'][0]['errorCode']
8686
?? null;
8787

88-
return in_array($transactionResponse['responseCode'], [self::RESPONSE_CODE_APPROVED, self::RESPONSE_CODE_HELD])
89-
&& $code
88+
return !in_array($transactionResponse['responseCode'], [
89+
self::RESPONSE_CODE_APPROVED, self::RESPONSE_CODE_HELD
90+
])
91+
|| $code
9092
&& !in_array(
9193
$code,
9294
[

app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Validator/TransactionResponseValidatorTest.php

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
use PHPUnit\Framework\MockObject\MockObject;
1616
use PHPUnit\Framework\TestCase;
1717

18+
/**
19+
* Tests for the transaction response validator
20+
*/
1821
class TransactionResponseValidatorTest extends TestCase
1922
{
2023
private const RESPONSE_CODE_APPROVED = 1;
2124
private const RESPONSE_CODE_HELD = 4;
25+
private const RESPONSE_CODE_DENIED = 2;
2226
private const RESPONSE_REASON_CODE_APPROVED = 1;
2327
private const RESPONSE_REASON_CODE_PENDING_REVIEW_AUTHORIZED = 252;
2428
private const RESPONSE_REASON_CODE_PENDING_REVIEW = 253;
29+
private const ERROR_CODE_AVS_MISMATCH = 27;
2530

2631
/**
2732
* @var ResultInterfaceFactory|MockObject
@@ -86,16 +91,6 @@ public function testValidateScenarios($transactionResponse, $isValid, $errorCode
8691
public function scenarioProvider()
8792
{
8893
return [
89-
// This validator only cares about successful edge cases so test for default behavior
90-
[
91-
[
92-
'responseCode' => 'foo',
93-
],
94-
true,
95-
[],
96-
[]
97-
],
98-
9994
// Test for acceptable reason codes
10095
[
10196
[
@@ -208,6 +203,29 @@ public function scenarioProvider()
208203
['foo'],
209204
['bar']
210205
],
206+
[
207+
[
208+
'responseCode' => self::RESPONSE_CODE_DENIED,
209+
'errors' => [
210+
[
211+
'errorCode' => self::ERROR_CODE_AVS_MISMATCH,
212+
'errorText' => 'bar'
213+
]
214+
]
215+
],
216+
false,
217+
[self::ERROR_CODE_AVS_MISMATCH],
218+
['bar']
219+
],
220+
// This validator only cares about successful edge cases so test for default behavior
221+
[
222+
[
223+
'responseCode' => 'foo',
224+
],
225+
false,
226+
[],
227+
[]
228+
],
211229
];
212230
}
213231
}

app/code/Magento/Backup/etc/adminhtml/system.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,22 @@
2626
<label>Scheduled Backup Type</label>
2727
<depends>
2828
<field id="enabled">1</field>
29+
<field id="functionality_enabled">1</field>
2930
</depends>
3031
<source_model>Magento\Backup\Model\Config\Source\Type</source_model>
3132
</field>
3233
<field id="time" translate="label" type="time" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0">
3334
<label>Start Time</label>
3435
<depends>
3536
<field id="enabled">1</field>
37+
<field id="functionality_enabled">1</field>
3638
</depends>
3739
</field>
3840
<field id="frequency" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
3941
<label>Frequency</label>
4042
<depends>
4143
<field id="enabled">1</field>
44+
<field id="functionality_enabled">1</field>
4245
</depends>
4346
<source_model>Magento\Cron\Model\Config\Source\Frequency</source_model>
4447
<backend_model>Magento\Backup\Model\Config\Backend\Cron</backend_model>
@@ -48,6 +51,7 @@
4851
<comment>Please put your store into maintenance mode during backup.</comment>
4952
<depends>
5053
<field id="enabled">1</field>
54+
<field id="functionality_enabled">1</field>
5155
</depends>
5256
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
5357
</field>

app/code/Magento/Catalog/Controller/Category/View.php

Lines changed: 87 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,28 @@
66
*/
77
namespace Magento\Catalog\Controller\Category;
88

9-
use Magento\Framework\App\Action\HttpPostActionInterface;
10-
use Magento\Framework\App\Action\HttpGetActionInterface;
119
use Magento\Catalog\Api\CategoryRepositoryInterface;
10+
use Magento\Catalog\Model\Category;
11+
use Magento\Catalog\Model\Design;
1212
use Magento\Catalog\Model\Layer\Resolver;
1313
use Magento\Catalog\Model\Product\ProductList\ToolbarMemorizer;
14+
use Magento\Catalog\Model\Session;
15+
use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
16+
use Magento\Framework\App\Action\Action;
17+
use Magento\Framework\App\Action\Context;
18+
use Magento\Framework\App\Action\HttpGetActionInterface;
19+
use Magento\Framework\App\Action\HttpPostActionInterface;
20+
use Magento\Framework\App\ActionInterface;
21+
use Magento\Framework\Controller\Result\ForwardFactory;
22+
use Magento\Framework\Controller\ResultInterface;
23+
use Magento\Framework\DataObject;
24+
use Magento\Framework\Exception\LocalizedException;
1425
use Magento\Framework\Exception\NoSuchEntityException;
26+
use Magento\Framework\Registry;
27+
use Magento\Framework\View\Result\Page;
1528
use Magento\Framework\View\Result\PageFactory;
16-
use Magento\Framework\App\Action\Action;
29+
use Magento\Store\Model\StoreManagerInterface;
30+
use Psr\Log\LoggerInterface;
1731

1832
/**
1933
* View a category on storefront. Needs to be accessible by POST because of the store switching.
@@ -25,41 +39,41 @@ class View extends Action implements HttpGetActionInterface, HttpPostActionInter
2539
/**
2640
* Core registry
2741
*
28-
* @var \Magento\Framework\Registry
42+
* @var Registry
2943
*/
3044
protected $_coreRegistry = null;
3145

3246
/**
3347
* Catalog session
3448
*
35-
* @var \Magento\Catalog\Model\Session
49+
* @var Session
3650
*/
3751
protected $_catalogSession;
3852

3953
/**
4054
* Catalog design
4155
*
42-
* @var \Magento\Catalog\Model\Design
56+
* @var Design
4357
*/
4458
protected $_catalogDesign;
4559

4660
/**
47-
* @var \Magento\Store\Model\StoreManagerInterface
61+
* @var StoreManagerInterface
4862
*/
4963
protected $_storeManager;
5064

5165
/**
52-
* @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator
66+
* @var CategoryUrlPathGenerator
5367
*/
5468
protected $categoryUrlPathGenerator;
5569

5670
/**
57-
* @var \Magento\Framework\View\Result\PageFactory
71+
* @var PageFactory
5872
*/
5973
protected $resultPageFactory;
6074

6175
/**
62-
* @var \Magento\Framework\Controller\Result\ForwardFactory
76+
* @var ForwardFactory
6377
*/
6478
protected $resultForwardFactory;
6579

@@ -83,28 +97,28 @@ class View extends Action implements HttpGetActionInterface, HttpPostActionInter
8397
/**
8498
* Constructor
8599
*
86-
* @param \Magento\Framework\App\Action\Context $context
87-
* @param \Magento\Catalog\Model\Design $catalogDesign
88-
* @param \Magento\Catalog\Model\Session $catalogSession
89-
* @param \Magento\Framework\Registry $coreRegistry
90-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
91-
* @param \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator
92-
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
93-
* @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
100+
* @param Context $context
101+
* @param Design $catalogDesign
102+
* @param Session $catalogSession
103+
* @param Registry $coreRegistry
104+
* @param StoreManagerInterface $storeManager
105+
* @param CategoryUrlPathGenerator $categoryUrlPathGenerator
106+
* @param PageFactory $resultPageFactory
107+
* @param ForwardFactory $resultForwardFactory
94108
* @param Resolver $layerResolver
95109
* @param CategoryRepositoryInterface $categoryRepository
96110
* @param ToolbarMemorizer|null $toolbarMemorizer
97111
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
98112
*/
99113
public function __construct(
100-
\Magento\Framework\App\Action\Context $context,
101-
\Magento\Catalog\Model\Design $catalogDesign,
102-
\Magento\Catalog\Model\Session $catalogSession,
103-
\Magento\Framework\Registry $coreRegistry,
104-
\Magento\Store\Model\StoreManagerInterface $storeManager,
105-
\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator,
114+
Context $context,
115+
Design $catalogDesign,
116+
Session $catalogSession,
117+
Registry $coreRegistry,
118+
StoreManagerInterface $storeManager,
119+
CategoryUrlPathGenerator $categoryUrlPathGenerator,
106120
PageFactory $resultPageFactory,
107-
\Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory,
121+
ForwardFactory $resultForwardFactory,
108122
Resolver $layerResolver,
109123
CategoryRepositoryInterface $categoryRepository,
110124
ToolbarMemorizer $toolbarMemorizer = null
@@ -125,7 +139,7 @@ public function __construct(
125139
/**
126140
* Initialize requested category object
127141
*
128-
* @return \Magento\Catalog\Model\Category|bool
142+
* @return Category|bool
129143
*/
130144
protected function _initCategory()
131145
{
@@ -150,8 +164,8 @@ protected function _initCategory()
150164
'catalog_controller_category_init_after',
151165
['category' => $category, 'controller_action' => $this]
152166
);
153-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
154-
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
167+
} catch (LocalizedException $e) {
168+
$this->_objectManager->get(LoggerInterface::class)->critical($e);
155169
return false;
156170
}
157171

@@ -161,13 +175,12 @@ protected function _initCategory()
161175
/**
162176
* Category view action
163177
*
164-
* @return \Magento\Framework\Controller\ResultInterface
165-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
166-
* @SuppressWarnings(PHPMD.NPathComplexity)
178+
* @return ResultInterface
179+
* @throws NoSuchEntityException
167180
*/
168181
public function execute()
169182
{
170-
if ($this->_request->getParam(\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED)) {
183+
if ($this->_request->getParam(ActionInterface::PARAM_NAME_URL_ENCODED)) {
171184
return $this->resultRedirectFactory->create()->setUrl($this->_redirect->getRedirectUrl());
172185
}
173186
$category = $this->_initCategory();
@@ -188,29 +201,18 @@ public function execute()
188201
$page->getConfig()->setPageLayout($settings->getPageLayout());
189202
}
190203

191-
$hasChildren = $category->hasChildren();
192-
if ($category->getIsAnchor()) {
193-
$type = $hasChildren ? 'layered' : 'layered_without_children';
194-
} else {
195-
$type = $hasChildren ? 'default' : 'default_without_children';
196-
}
204+
$pageType = $this->getPageType($category);
197205

198-
if (!$hasChildren) {
206+
if (!$category->hasChildren()) {
199207
// Two levels removed from parent. Need to add default page type.
200-
$parentType = strtok($type, '_');
201-
$page->addPageLayoutHandles(['type' => $parentType], null, false);
208+
$parentPageType = strtok($pageType, '_');
209+
$page->addPageLayoutHandles(['type' => $parentPageType], null, false);
202210
}
203-
$page->addPageLayoutHandles(['type' => $type], null, false);
211+
$page->addPageLayoutHandles(['type' => $pageType], null, false);
204212
$page->addPageLayoutHandles(['id' => $category->getId()]);
205213

206214
// apply custom layout update once layout is loaded
207-
$layoutUpdates = $settings->getLayoutUpdates();
208-
if ($layoutUpdates && is_array($layoutUpdates)) {
209-
foreach ($layoutUpdates as $layoutUpdate) {
210-
$page->addUpdate($layoutUpdate);
211-
$page->addPageLayoutHandles(['layout_update' => sha1($layoutUpdate)], null, false);
212-
}
213-
}
215+
$this->applyLayoutUpdates($page, $settings);
214216

215217
$page->getConfig()->addBodyClass('page-products')
216218
->addBodyClass('categorypath-' . $this->categoryUrlPathGenerator->getUrlPath($category))
@@ -221,4 +223,40 @@ public function execute()
221223
return $this->resultForwardFactory->create()->forward('noroute');
222224
}
223225
}
226+
227+
/**
228+
* Get page type based on category
229+
*
230+
* @param Category $category
231+
* @return string
232+
*/
233+
private function getPageType(Category $category) : string
234+
{
235+
$hasChildren = $category->hasChildren();
236+
if ($category->getIsAnchor()) {
237+
return $hasChildren ? 'layered' : 'layered_without_children';
238+
}
239+
240+
return $hasChildren ? 'default' : 'default_without_children';
241+
}
242+
243+
/**
244+
* Apply custom layout updates
245+
*
246+
* @param Page $page
247+
* @param DataObject $settings
248+
* @return void
249+
*/
250+
private function applyLayoutUpdates(
251+
Page $page,
252+
DataObject $settings
253+
) {
254+
$layoutUpdates = $settings->getLayoutUpdates();
255+
if ($layoutUpdates && is_array($layoutUpdates)) {
256+
foreach ($layoutUpdates as $layoutUpdate) {
257+
$page->addUpdate($layoutUpdate);
258+
$page->addPageLayoutHandles(['layout_update' => sha1($layoutUpdate)], null, false);
259+
}
260+
}
261+
}
224262
}

0 commit comments

Comments
 (0)