Skip to content

Commit 0296083

Browse files
authored
Merge branch '2.4-develop' into cia-2.4-develop-bugfixes-07272022
2 parents 4c825c5 + bfd457c commit 0296083

File tree

13 files changed

+360
-20
lines changed

13 files changed

+360
-20
lines changed

app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ private function convertElementsToSelect($elements, $attributesToConvert)
132132
$elements[$code]['dataType'] = 'select';
133133
$elements[$code]['formElement'] = 'select';
134134

135-
foreach ($options as $key => $value) {
135+
foreach ($options as $value) {
136136
$elements[$code]['options'][] = [
137-
'value' => $key,
137+
'value' => $value,
138138
'label' => $value,
139139
];
140140
}

app/code/Magento/Checkout/Controller/Cart/EstimatePost.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
namespace Magento\Checkout\Controller\Cart;
77

88
use Magento\Framework;
9+
use Magento\Framework\App\Action\HttpPostActionInterface;
910
use Magento\Checkout\Model\Cart as CustomerCart;
1011

11-
class EstimatePost extends \Magento\Checkout\Controller\Cart
12+
class EstimatePost extends \Magento\Checkout\Controller\Cart implements HttpPostActionInterface
1213
{
1314
/**
1415
* @var \Magento\Quote\Api\CartRepositoryInterface
@@ -63,9 +64,7 @@ public function execute()
6364
->setCity($city)
6465
->setPostcode($postcode)
6566
->setRegionId($regionId)
66-
->setRegion($region)
67-
->setCollectShippingRates(true);
68-
$this->quoteRepository->save($this->cart->getQuote());
67+
->setRegion($region);
6968
$this->cart->save();
7069
return $this->_goBack();
7170
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CustomerGraphQl\Model\Customer;
9+
10+
use Magento\Customer\Api\CustomerRepositoryInterface;
11+
use Magento\Customer\Api\Data\CustomerInterface;
12+
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
14+
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
15+
16+
/**
17+
* Delete customer
18+
* @codingStandardsIgnoreStart
19+
*/
20+
class DeleteCustomer
21+
{
22+
/**
23+
* @var CustomerRepositoryInterface
24+
*/
25+
private $customerRepository;
26+
27+
/**
28+
* @param CustomerRepositoryInterface $customerRepository
29+
*/
30+
public function __construct(
31+
CustomerRepositoryInterface $customerRepository
32+
) {
33+
$this->customerRepository = $customerRepository;
34+
}
35+
36+
/**
37+
* Delete customer
38+
*
39+
* @param CustomerInterface $customer
40+
* @return void
41+
* @throws GraphQlInputException
42+
* @throws GraphQlNoSuchEntityException
43+
*/
44+
public function execute(CustomerInterface $customer): void
45+
{
46+
try {
47+
$this->customerRepository->delete($customer);
48+
} catch (LocalizedException $e) {
49+
throw new GraphQlInputException(__($e->getMessage()), $e);
50+
}
51+
}
52+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CustomerGraphQl\Model\Resolver;
9+
10+
use Magento\CustomerGraphQl\Model\Customer\DeleteCustomer as DeleteCustomerModel;
11+
use Magento\CustomerGraphQl\Model\Customer\GetCustomer;
12+
use Magento\Framework\GraphQl\Config\Element\Field;
13+
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
14+
use Magento\Framework\GraphQl\Query\ResolverInterface;
15+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
16+
use Magento\Framework\Registry;
17+
use Magento\GraphQl\Model\Query\ContextInterface;
18+
19+
/**
20+
* Delete customer, used for GraphQL request processing.
21+
*/
22+
class DeleteCustomer implements ResolverInterface
23+
{
24+
/**
25+
* @var GetCustomer
26+
*/
27+
private $getCustomer;
28+
29+
/**
30+
* @var DeleteCustomerModel
31+
*/
32+
private $deleteCustomer;
33+
34+
/**
35+
* @var Registry
36+
*/
37+
private $registry;
38+
39+
/**
40+
* @param GetCustomer $getCustomer
41+
* @param DeleteCustomerModel $deleteCustomer
42+
* @param Registry $registry
43+
*/
44+
public function __construct(
45+
GetCustomer $getCustomer,
46+
DeleteCustomerModel $deleteCustomer,
47+
Registry $registry
48+
) {
49+
$this->getCustomer = $getCustomer;
50+
$this->deleteCustomer = $deleteCustomer;
51+
$this->registry = $registry;
52+
}
53+
54+
/**
55+
* @inheritdoc
56+
*/
57+
public function resolve(
58+
Field $field,
59+
$context,
60+
ResolveInfo $info,
61+
array $value = null,
62+
array $args = null
63+
) {
64+
/** @var ContextInterface $context */
65+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
66+
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
67+
}
68+
69+
$isSecure = $this->registry->registry('isSecureArea');
70+
71+
$this->registry->unregister('isSecureArea');
72+
$this->registry->register('isSecureArea', true);
73+
74+
$customer = $this->getCustomer->execute($context);
75+
$this->deleteCustomer->execute($customer);
76+
77+
$this->registry->unregister('isSecureArea');
78+
$this->registry->register('isSecureArea', $isSecure);
79+
return true;
80+
}
81+
}

app/code/Magento/CustomerGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type Mutation {
2121
createCustomerV2 (input: CustomerCreateInput! @doc(description: "An input object that defines the customer to be created.")): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\CreateCustomer") @doc(description:"Create a customer account.")
2222
updateCustomer (input: CustomerInput! @doc(description: "An input object that defines the customer characteristics to update.")): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\UpdateCustomer") @doc(description:"Use `updateCustomerV2` instead.")
2323
updateCustomerV2 (input: CustomerUpdateInput! @doc(description: "An input object that defines the customer characteristics to update.")): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\UpdateCustomer") @doc(description:"Update the customer's personal information.")
24+
deleteCustomer: Boolean @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\DeleteCustomer") @doc(description:"Delete customer account")
2425
revokeCustomerToken: RevokeCustomerTokenOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\RevokeCustomerToken") @doc(description:"Revoke the customer token.")
2526
createCustomerAddress(input: CustomerAddressInput!): CustomerAddress @resolver(class: "Magento\\CustomerGraphQl\\Model\\Resolver\\CreateCustomerAddress") @doc(description: "Create a billing or shipping address for a customer or guest.")
2627
updateCustomerAddress(id: Int! @doc(description: "The ID assigned to the customer address."), input: CustomerAddressInput @doc(description: "An input object that contains changes to the customer address.")): CustomerAddress @resolver(class: "Magento\\CustomerGraphQl\\Model\\Resolver\\UpdateCustomerAddress") @doc(description: "Update the billing or shipping address of a customer or guest.")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
10+
<policies>
11+
<policy id="script-src">
12+
<values>
13+
<value id="newrelic-agent" type="host">*.newrelic.com</value>
14+
<value id="newrelic-agent-data" type="host">*.nr-data.net</value>
15+
</values>
16+
</policy>
17+
<policy id="connect-src">
18+
<values>
19+
<value id="newrelic-agent" type="host">*.newrelic.com</value>
20+
<value id="newrelic-agent-data" type="host">*.nr-data.net</value>
21+
</values>
22+
</policy>
23+
</policies>
24+
</csp_whitelist>

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractForm
2121
{
2222
/**
23-
* Customer form factory
23+
* Customer Metadata form factory
2424
*
2525
* @var \Magento\Customer\Model\Metadata\FormFactory
2626
*/
2727
protected $_customerFormFactory;
2828

2929
/**
30-
* Json encoder
30+
* Framework Json encoder
3131
*
3232
* @var \Magento\Framework\Json\EncoderInterface
3333
*/
3434
protected $_jsonEncoder;
3535

3636
/**
37-
* Directory helper
37+
* Directory helper Data
3838
*
3939
* @var \Magento\Directory\Helper\Data
4040
*/
@@ -48,28 +48,28 @@ class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractF
4848
protected $options;
4949

5050
/**
51-
* Address service
51+
* Address service - AddressRepositoryInterface
5252
*
5353
* @var \Magento\Customer\Api\AddressRepositoryInterface
5454
*/
5555
protected $addressService;
5656

5757
/**
58-
* Address helper
58+
* Customer Address helper
5959
*
6060
* @var \Magento\Customer\Helper\Address
6161
*/
6262
protected $_addressHelper;
6363

6464
/**
65-
* Search criteria builder
65+
* Search criteria builder for getList calls
6666
*
6767
* @var \Magento\Framework\Api\SearchCriteriaBuilder
6868
*/
6969
protected $searchCriteriaBuilder;
7070

7171
/**
72-
* Filter builder
72+
* Filter builder for getList calls
7373
*
7474
* @var \Magento\Framework\Api\FilterBuilder
7575
*/
@@ -235,9 +235,13 @@ protected function _prepareForm()
235235
if ($prefixElement) {
236236
$prefixOptions = $this->options->getNamePrefixOptions($this->getStore());
237237
if (!empty($prefixOptions)) {
238+
$mappedPrefixOptions = [];
239+
foreach ($prefixOptions as $prefix) {
240+
$mappedPrefixOptions[$prefix] = $prefix;
241+
}
238242
$fieldset->removeField($prefixElement->getId());
239243
$prefixField = $fieldset->addField($prefixElement->getId(), 'select', $prefixElement->getData(), '^');
240-
$prefixField->setValues($prefixOptions);
244+
$prefixField->setValues($mappedPrefixOptions);
241245
if ($this->getAddressId()) {
242246
$prefixField->addElementValues($this->getAddress()->getPrefix());
243247
}
@@ -322,6 +326,7 @@ private function processCountryOptions(\Magento\Framework\Data\Form\Element\Abst
322326
* Retrieve Directory Countries collection
323327
*
324328
* @deprecated 100.1.3
329+
* @see MAGETWO-711174: Introduce deprecated and since doc blocks.
325330
* @return \Magento\Directory\Model\ResourceModel\Country\Collection
326331
*/
327332
private function getCountriesCollection()
@@ -338,6 +343,7 @@ private function getCountriesCollection()
338343
* Retrieve Backend Quote Session
339344
*
340345
* @deprecated 100.1.3
346+
* @see MAGETWO-711174: Introduce deprecated and since doc blocks.
341347
* @return Quote
342348
*/
343349
private function getBackendQuoteSession()

app/code/Magento/User/Model/ResourceModel/User.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ public function recordLogin(ModelUser $user)
123123
'logdate' => (new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT),
124124
'lognum' => $user->getLognum() + 1,
125125
];
126+
127+
$user->setLogdate($data['logdate']);
128+
$user->setLognum($data['lognum']);
126129

127130
$condition = ['user_id = ?' => (int)$user->getUserId()];
128131

0 commit comments

Comments
 (0)