Skip to content

Commit 22b34da

Browse files
committed
Merge remote-tracking branch 'mainline/2.3-develop' into MAGETWO-99402
2 parents 406bcfd + 3ccf676 commit 22b34da

File tree

335 files changed

+6846
-2925
lines changed

Some content is hidden

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

335 files changed

+6846
-2925
lines changed

app/code/Magento/AdminNotification/view/adminhtml/layout/adminhtml_notification_block.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<block class="Magento\Backend\Block\Widget\Grid" name="adminhtml.notification.container.grid" as="grid">
1212
<arguments>
1313
<argument name="id" xsi:type="string">notificationGrid</argument>
14-
<argument name="dataSource" xsi:type="object">Magento\AdminNotification\Model\ResourceModel\Grid\Collection</argument>
14+
<argument name="dataSource" xsi:type="object" shared="false">Magento\AdminNotification\Model\ResourceModel\Grid\Collection</argument>
1515
<argument name="default_dir" xsi:type="string">DESC</argument>
1616
<argument name="default_sort" xsi:type="string">date_added</argument>
1717
<argument name="save_parameters_in_session" xsi:type="string">1</argument>

app/code/Magento/AdvancedSearch/view/adminhtml/layout/catalog_search_block.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<block class="Magento\AdvancedSearch\Block\Adminhtml\Search\Grid" name="search.edit.grid" as="grid">
1212
<arguments>
1313
<argument name="id" xsi:type="string">catalog_search_grid</argument>
14-
<argument name="dataSource" xsi:type="object">Magento\AdvancedSearch\Model\ResourceModel\Search\Grid\Collection</argument>
14+
<argument name="dataSource" xsi:type="object" shared="false">Magento\AdvancedSearch\Model\ResourceModel\Search\Grid\Collection</argument>
1515
<argument name="default_sort" xsi:type="string">name</argument>
1616
<argument name="default_dir" xsi:type="string">ASC</argument>
1717
<argument name="save_parameters_in_session" xsi:type="string">1</argument>

app/code/Magento/Authorization/Model/Role.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,29 @@ public function __construct(
5151
}
5252

5353
/**
54-
* {@inheritdoc}
54+
* @inheritDoc
55+
*
56+
* @SuppressWarnings(PHPMD.SerializationAware)
57+
* @deprecated Do not use PHP serialization.
5558
*/
5659
public function __sleep()
5760
{
61+
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
62+
5863
$properties = parent::__sleep();
5964
return array_diff($properties, ['_resource', '_resourceCollection']);
6065
}
6166

6267
/**
63-
* {@inheritdoc}
68+
* @inheritDoc
69+
*
70+
* @SuppressWarnings(PHPMD.SerializationAware)
71+
* @deprecated Do not use PHP serialization.
6472
*/
6573
public function __wakeup()
6674
{
75+
trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
76+
6777
parent::__wakeup();
6878
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
6979
$this->_resource = $objectManager->get(\Magento\Authorization\Model\ResourceModel\Role::class);

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/Backend/Model/Auth/Session.php

Lines changed: 193 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,25 @@
55
*/
66
namespace Magento\Backend\Model\Auth;
77

8+
use Magento\Framework\Acl;
9+
use Magento\Framework\AclFactory;
10+
use Magento\Framework\App\ObjectManager;
811
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
912
use Magento\Framework\Stdlib\CookieManagerInterface;
13+
use Magento\Backend\Spi\SessionUserHydratorInterface;
14+
use Magento\Backend\Spi\SessionAclHydratorInterface;
15+
use Magento\User\Model\User;
16+
use Magento\User\Model\UserFactory;
1017

1118
/**
1219
* Backend Auth session model
1320
*
1421
* @api
15-
* @method \Magento\User\Model\User|null getUser()
16-
* @method \Magento\Backend\Model\Auth\Session setUser(\Magento\User\Model\User $value)
17-
* @method \Magento\Framework\Acl|null getAcl()
18-
* @method \Magento\Backend\Model\Auth\Session setAcl(\Magento\Framework\Acl $value)
1922
* @method int getUpdatedAt()
2023
* @method \Magento\Backend\Model\Auth\Session setUpdatedAt(int $value)
2124
*
2225
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2327
* @todo implement solution that keeps is_first_visit flag in session during redirects
2428
* @api
2529
* @since 100.0.2
@@ -55,6 +59,36 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage
5559
*/
5660
protected $_config;
5761

62+
/**
63+
* @var SessionUserHydratorInterface
64+
*/
65+
private $userHydrator;
66+
67+
/**
68+
* @var SessionAclHydratorInterface
69+
*/
70+
private $aclHydrator;
71+
72+
/**
73+
* @var UserFactory
74+
*/
75+
private $userFactory;
76+
77+
/**
78+
* @var AclFactory
79+
*/
80+
private $aclFactory;
81+
82+
/**
83+
* @var User|null
84+
*/
85+
private $user;
86+
87+
/**
88+
* @var Acl|null
89+
*/
90+
private $acl;
91+
5892
/**
5993
* @param \Magento\Framework\App\Request\Http $request
6094
* @param \Magento\Framework\Session\SidResolverInterface $sidResolver
@@ -69,6 +103,10 @@ class Session extends \Magento\Framework\Session\SessionManager implements \Mage
69103
* @param \Magento\Backend\Model\UrlInterface $backendUrl
70104
* @param \Magento\Backend\App\ConfigInterface $config
71105
* @throws \Magento\Framework\Exception\SessionException
106+
* @param SessionUserHydratorInterface|null $userHydrator
107+
* @param SessionAclHydratorInterface|null $aclHydrator
108+
* @param UserFactory|null $userFactory
109+
* @param AclFactory|null $aclFactory
72110
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
73111
*/
74112
public function __construct(
@@ -83,11 +121,19 @@ public function __construct(
83121
\Magento\Framework\App\State $appState,
84122
\Magento\Framework\Acl\Builder $aclBuilder,
85123
\Magento\Backend\Model\UrlInterface $backendUrl,
86-
\Magento\Backend\App\ConfigInterface $config
124+
\Magento\Backend\App\ConfigInterface $config,
125+
?SessionUserHydratorInterface $userHydrator = null,
126+
?SessionAclHydratorInterface $aclHydrator = null,
127+
?UserFactory $userFactory = null,
128+
?AclFactory $aclFactory = null
87129
) {
88130
$this->_config = $config;
89131
$this->_aclBuilder = $aclBuilder;
90132
$this->_backendUrl = $backendUrl;
133+
$this->userHydrator = $userHydrator ?? ObjectManager::getInstance()->get(SessionUserHydratorInterface::class);
134+
$this->aclHydrator = $aclHydrator ?? ObjectManager::getInstance()->get(SessionAclHydratorInterface::class);
135+
$this->userFactory = $userFactory ?? ObjectManager::getInstance()->get(UserFactory::class);
136+
$this->aclFactory = $aclFactory ?? ObjectManager::getInstance()->get(AclFactory::class);
91137
parent::__construct(
92138
$request,
93139
$sidResolver,
@@ -230,6 +276,16 @@ public function processLogin()
230276
return $this;
231277
}
232278

279+
/**
280+
* @inheritDoc
281+
*/
282+
public function destroy(array $options = null)
283+
{
284+
$this->user = null;
285+
$this->acl = null;
286+
parent::destroy($options);
287+
}
288+
233289
/**
234290
* Process of configuring of current auth storage when logout was performed
235291
*
@@ -253,4 +309,136 @@ public function isValidForPath($path)
253309
{
254310
return true;
255311
}
312+
313+
/**
314+
* Logged-in user.
315+
*
316+
* @return User|null
317+
*/
318+
public function getUser()
319+
{
320+
if (!$this->user) {
321+
$userData = $this->getUserData();
322+
if ($userData) {
323+
/** @var User $user */
324+
$user = $this->userFactory->create();
325+
$this->userHydrator->hydrate($user, $userData);
326+
$this->user = $user;
327+
}
328+
}
329+
330+
return $this->user;
331+
}
332+
333+
/**
334+
* Set logged-in user instance.
335+
*
336+
* @param User|null $user
337+
* @return Session
338+
*/
339+
public function setUser($user)
340+
{
341+
$this->setUserData(null);
342+
if ($user) {
343+
$this->setUserData($this->userHydrator->extract($user));
344+
}
345+
$this->user = $user;
346+
347+
return $this;
348+
}
349+
350+
/**
351+
* Is user logged in?
352+
*
353+
* @return bool
354+
*/
355+
public function hasUser()
356+
{
357+
return $this->user || $this->hasUserData();
358+
}
359+
360+
/**
361+
* Remove logged-in user.
362+
*
363+
* @return Session
364+
*/
365+
public function unsUser()
366+
{
367+
$this->user = null;
368+
return $this->unsUserData();
369+
}
370+
371+
/**
372+
* Logged-in user's ACL data.
373+
*
374+
* @return Acl|null
375+
*/
376+
public function getAcl()
377+
{
378+
if (!$this->acl) {
379+
$aclData = $this->getUserAclData();
380+
if ($aclData) {
381+
/** @var Acl $acl */
382+
$acl = $this->aclFactory->create();
383+
$this->aclHydrator->hydrate($acl, $aclData);
384+
$this->acl = $acl;
385+
}
386+
}
387+
388+
return $this->acl;
389+
}
390+
391+
/**
392+
* Set logged-in user's ACL data instance.
393+
*
394+
* @param Acl|null $acl
395+
* @return Session
396+
*/
397+
public function setAcl($acl)
398+
{
399+
$this->setUserAclData(null);
400+
if ($acl) {
401+
$this->setUserAclData($this->aclHydrator->extract($acl));
402+
}
403+
$this->acl = $acl;
404+
405+
return $this;
406+
}
407+
408+
/**
409+
* Whether ACL data is present.
410+
*
411+
* @return bool
412+
*/
413+
public function hasAcl()
414+
{
415+
return $this->acl || $this->hasUserAclData();
416+
}
417+
418+
/**
419+
* Remove ACL data.
420+
*
421+
* @return Session
422+
*/
423+
public function unsAcl()
424+
{
425+
$this->acl = null;
426+
return $this->unsUserAclData();
427+
}
428+
429+
/**
430+
* @inheritDoc
431+
*/
432+
public function writeClose()
433+
{
434+
//Updating data in session in case these objects has been changed.
435+
if ($this->user) {
436+
$this->setUser($this->user);
437+
}
438+
if ($this->acl) {
439+
$this->setAcl($this->acl);
440+
}
441+
442+
parent::writeClose();
443+
}
256444
}

0 commit comments

Comments
 (0)