Skip to content

Commit 5b86a0e

Browse files
authored
Merge branch '2.4-develop' into AC-14090
2 parents 5464494 + a68324b commit 5b86a0e

File tree

21 files changed

+436
-128
lines changed

21 files changed

+436
-128
lines changed

app/code/Magento/Customer/Model/Address.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Customer\Model;
77

@@ -371,7 +371,9 @@ public function reindex()
371371
{
372372
/** @var \Magento\Framework\Indexer\IndexerInterface $indexer */
373373
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
374-
$indexer->reindexRow($this->getCustomerId());
374+
if (!$indexer->isScheduled()) {
375+
$indexer->reindexRow($this->getCustomerId());
376+
}
375377
}
376378

377379
/**

app/code/Magento/Customer/Model/Customer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,9 @@ public function afterDeleteCommit()
11261126
*/
11271127
public function reindex()
11281128
{
1129-
$this->getIndexer()->reindexRow($this->getId());
1129+
if (!$this->getIndexer()->isScheduled()) {
1130+
$this->getIndexer()->reindexRow($this->getId());
1131+
}
11301132
}
11311133

11321134
/**

app/code/Magento/Customer/etc/di.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2013 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
@@ -593,4 +593,9 @@
593593
type="Magento\Customer\Plugin\AsyncRequestCustomerGroupAuthorization"
594594
/>
595595
</type>
596+
<virtualType name="Magento\Customer\Model\MviewAction" type="\Magento\Framework\Mview\View\BaseAction">
597+
<arguments>
598+
<argument name="indexerId" xsi:type="string">customer_grid</argument>
599+
</arguments>
600+
</virtualType>
596601
</config>
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2015 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Mview/etc/mview.xsd">
9-
<view id="customer_dummy" class="Magento\Framework\Indexer\Action\Dummy" group="indexer"/>
9+
<view id="customer_dummy" class="Magento\Customer\Model\MviewAction" group="indexer">
10+
<subscriptions>
11+
<table name="customer_entity" entity_column="entity_id" />
12+
<table name="customer_entity_datetime" entity_column="entity_id" />
13+
<table name="customer_entity_decimal" entity_column="entity_id" />
14+
<table name="customer_entity_int" entity_column="entity_id" />
15+
<table name="customer_address_entity" entity_column="parent_id" />
16+
</subscriptions>
17+
</view>
1018
</config>

app/code/Magento/GiftMessageGraphQl/Model/Resolver/Product/GiftMessage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public function resolve(
3333
Field $field,
3434
$context,
3535
ResolveInfo $info,
36-
array $value = null,
37-
array $args = null
36+
?array $value = null,
37+
?array $args = null
3838
): bool {
3939
if (!isset($value['model']) || !$value['model'] instanceof ProductInterface) {
4040
throw new LocalizedException(__('The product model is not available.'));

app/code/Magento/Paypal/Controller/Express/AbstractExpress.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Paypal\Controller\Express;
77

@@ -151,6 +151,9 @@ public function __construct(
151151
protected function _initCheckout(?CartInterface $quoteObject = null)
152152
{
153153
$quote = $quoteObject ? $quoteObject : $this->_getQuote();
154+
if ($quote->getId()) {
155+
$this->_getCheckoutSession()->setPayPalQuoteId($quote->getId());
156+
}
154157
if (!$quote->hasItems() || $quote->getHasError()) {
155158
$this->getResponse()->setStatusHeader(403, '1.1', 'Forbidden');
156159
throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t initialize Express Checkout.'));
@@ -248,6 +251,9 @@ protected function _getQuote()
248251
$this->_getCheckoutSession()->replaceQuote($this->_quote);
249252
} else {
250253
$this->_quote = $this->_getCheckoutSession()->getQuote();
254+
if (!$this->_quote->getId() && $this->_getCheckoutSession()->getPayPalQuoteId()) {
255+
$this->_quote = $this->quoteRepository->get($this->_getCheckoutSession()->getPayPalQuoteId());
256+
}
251257
}
252258
}
253259
return $this->_quote;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
/**
3+
* Copyright 2025 Adobe
4+
* All rights reserved.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Paypal\Plugin;
9+
10+
use Magento\Framework\App\RequestInterface;
11+
use Magento\Paypal\Controller\Payflow\ReturnUrl as Subject;
12+
use Magento\Paypal\Model\PayflowlinkFactory;
13+
use Magento\Sales\Model\Order;
14+
use Magento\Sales\Model\OrderFactory;
15+
use Psr\Log\LoggerInterface;
16+
17+
class PayflowSilentPost
18+
{
19+
/**
20+
* @var array
21+
*/
22+
protected array $allowedOrderStates = [
23+
Order::STATE_PROCESSING,
24+
Order::STATE_COMPLETE,
25+
Order::STATE_PAYMENT_REVIEW
26+
];
27+
28+
/**
29+
* @param RequestInterface $request
30+
* @param OrderFactory $orderFactory
31+
* @param PayflowlinkFactory $payflowlinkFactory
32+
* @param LoggerInterface $logger
33+
*/
34+
public function __construct(
35+
private readonly RequestInterface $request,
36+
private readonly OrderFactory $orderFactory,
37+
private readonly PayflowlinkFactory $payflowlinkFactory,
38+
private readonly LoggerInterface $logger,
39+
) {
40+
}
41+
42+
/**
43+
* Process payment if not already done via silent post
44+
*
45+
* @param Subject $subject
46+
* @return void
47+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
48+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
49+
*/
50+
public function beforeExecute(Subject $subject): void
51+
{
52+
$data = $this->request->getParams();
53+
if (!array_key_exists('INVNUM', $data)
54+
|| !array_key_exists('RESPMSG', $data)
55+
|| !array_key_exists('RESULT', $data)) {
56+
return;
57+
}
58+
59+
$orderId = (string)$data['INVNUM'];
60+
if (!$orderId) {
61+
return;
62+
}
63+
64+
$order = $this->orderFactory->create()->loadByIncrementId($orderId);
65+
$payment = $order->getPayment();
66+
if (in_array($order->getState(), $this->allowedOrderStates) || $payment->getLastTransId()
67+
|| trim((string)$data['RESPMSG']) !== 'Approved' || (int)$data['RESULT'] !== 0) {
68+
return;
69+
}
70+
71+
$paymentModel = $this->payflowlinkFactory->create();
72+
try {
73+
$paymentModel->process($data);
74+
} catch (\Exception $e) {
75+
$this->logger->critical($e);
76+
}
77+
}
78+
}

app/code/Magento/Paypal/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,7 @@
291291
</argument>
292292
</arguments>
293293
</type>
294+
<type name="Magento\Paypal\Controller\Payflow\ReturnUrl">
295+
<plugin name="payflow_silentpost" type="Magento\Paypal\Plugin\PayflowSilentPost"/>
296+
</type>
294297
</config>

app/code/Magento/Sales/Helper/Reorder.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Sales\Helper;
@@ -11,12 +11,7 @@
1111
*/
1212
class Reorder extends \Magento\Framework\App\Helper\AbstractHelper
1313
{
14-
const XML_PATH_SALES_REORDER_ALLOW = 'sales/reorder/allow';
15-
16-
/**
17-
* @var \Magento\Customer\Model\Session
18-
*/
19-
protected $customerSession;
14+
public const XML_PATH_SALES_REORDER_ALLOW = 'sales/reorder/allow';
2015

2116
/**
2217
* @var \Magento\Sales\Api\OrderRepositoryInterface
@@ -25,22 +20,21 @@ class Reorder extends \Magento\Framework\App\Helper\AbstractHelper
2520

2621
/**
2722
* @param \Magento\Framework\App\Helper\Context $context
28-
* @param \Magento\Customer\Model\Session $customerSession
2923
* @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
3024
*/
3125
public function __construct(
3226
\Magento\Framework\App\Helper\Context $context,
33-
\Magento\Customer\Model\Session $customerSession,
3427
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository
3528
) {
3629
$this->orderRepository = $orderRepository;
37-
$this->customerSession = $customerSession;
3830
parent::__construct(
3931
$context
4032
);
4133
}
4234

4335
/**
36+
* Check if reorder is allowed
37+
*
4438
* @return bool
4539
*/
4640
public function isAllow()
@@ -78,10 +72,6 @@ public function canReorder($orderId)
7872
if (!$this->isAllowed($order->getStore())) {
7973
return false;
8074
}
81-
if ($this->customerSession->isLoggedIn()) {
82-
return $order->canReorder();
83-
} else {
84-
return true;
85-
}
75+
return $order->canReorder();
8676
}
8777
}

app/code/Magento/Sales/Test/Unit/Helper/ReorderTest.php

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\Sales\Test\Unit\Helper;
99

10-
use Magento\Customer\Model\Session;
1110
use Magento\Framework\App\Config;
1211
use Magento\Framework\App\Config\ScopeConfigInterface;
1312
use Magento\Framework\App\Helper\Context;
@@ -40,11 +39,6 @@ class ReorderTest extends TestCase
4039
*/
4140
protected $orderMock;
4241

43-
/**
44-
* @var MockObject|Session
45-
*/
46-
protected $customerSessionMock;
47-
4842
/**
4943
* @var OrderRepositoryInterface|MockObject
5044
*/
@@ -66,15 +60,10 @@ protected function setUp(): void
6660
->method('getScopeConfig')
6761
->willReturn($this->scopeConfigMock);
6862

69-
$this->customerSessionMock = $this->getMockBuilder(Session::class)
70-
->disableOriginalConstructor()
71-
->getMock();
72-
7363
$this->repositoryMock = $this->getMockBuilder(OrderRepositoryInterface::class)
7464
->getMockForAbstractClass();
7565
$this->helper = new Reorder(
7666
$contextMock,
77-
$this->customerSessionMock,
7867
$this->repositoryMock
7968
);
8069

@@ -156,40 +145,17 @@ public function testCanReorderStoreNotAllowed()
156145
$this->assertFalse($this->helper->canReorder(1));
157146
}
158147

159-
/**
160-
* Tests what happens if the customer is not logged in and the store does allow re-orders.
161-
*
162-
* @return void
163-
*/
164-
public function testCanReorderCustomerNotLoggedIn()
165-
{
166-
$this->setupOrderMock(true);
167-
168-
$this->customerSessionMock->expects($this->once())
169-
->method('isLoggedIn')
170-
->willReturn(false);
171-
$this->repositoryMock->expects($this->once())
172-
->method('get')
173-
->with(1)
174-
->willReturn($this->orderMock);
175-
$this->assertTrue($this->helper->canReorder(1));
176-
}
177-
178148
/**
179149
* Tests what happens if the customer is logged in and the order does or does not allow reorders.
180150
*
181151
* @param bool $orderCanReorder
182152
* @return void
183153
* @dataProvider getOrderCanReorder
184154
*/
185-
public function testCanReorderCustomerLoggedInAndOrderCanReorder($orderCanReorder)
155+
public function testCanReorder($orderCanReorder)
186156
{
187157
$this->setupOrderMock(true);
188158

189-
$this->customerSessionMock->expects($this->once())
190-
->method('isLoggedIn')
191-
->willReturn(true);
192-
193159
$this->orderMock->expects($this->once())
194160
->method('canReorder')
195161
->willReturn($orderCanReorder);

0 commit comments

Comments
 (0)