Skip to content

Commit 511f0f1

Browse files
authored
Merge pull request #6704 from magento-cia/cia-2.4.3-3172021
cia-2.4.3-bugfixes
2 parents 7efaa47 + 397ae82 commit 511f0f1

File tree

12 files changed

+607
-86
lines changed

12 files changed

+607
-86
lines changed

app/code/Magento/ConfigurableProduct/Plugin/Model/Attribute/Backend/AttributeValidation.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\ConfigurableProduct\Plugin\Model\Attribute\Backend;
78

9+
use Closure;
810
use Magento\Catalog\Api\Data\ProductInterface;
911
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
12+
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
13+
use Magento\Framework\DataObject;
1014

1115
/**
12-
* Skip validate attributes used for create configurable product
16+
* Skip validate attributes used for create configurable product.
1317
*/
1418
class AttributeValidation
1519
{
@@ -19,29 +23,36 @@ class AttributeValidation
1923
private $configurableProductType;
2024

2125
/**
22-
* AttributeValidation constructor.
26+
* @var array
27+
*/
28+
private $unskippableAttributes;
29+
30+
/**
2331
* @param Configurable $configurableProductType
32+
* @param array|null $unskippableAttributes
2433
*/
2534
public function __construct(
26-
Configurable $configurableProductType
35+
Configurable $configurableProductType,
36+
array $unskippableAttributes = []
2737
) {
2838
$this->configurableProductType = $configurableProductType;
39+
$this->unskippableAttributes = $unskippableAttributes;
2940
}
3041

3142
/**
32-
* @param \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend $subject
43+
* Around plugin to skip attribute validation used for create configurable product.
44+
*
45+
* @param AbstractBackend $subject
3346
* @param \Closure $proceed
34-
* @param \Magento\Framework\DataObject $entity
47+
* @param DataObject $entity
3548
* @return bool
3649
*/
37-
public function aroundValidate(
38-
\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend $subject,
39-
\Closure $proceed,
40-
\Magento\Framework\DataObject $entity
41-
) {
50+
public function aroundValidate(AbstractBackend $subject, Closure $proceed, DataObject $entity)
51+
{
4252
$attribute = $subject->getAttribute();
4353
if ($entity instanceof ProductInterface
4454
&& $entity->getTypeId() == Configurable::TYPE_CODE
55+
&& !in_array($attribute->getAttributeCode(), $this->unskippableAttributes)
4556
&& in_array(
4657
$attribute->getAttributeId(),
4758
$this->configurableProductType->getUsedProductAttributeIds($entity),
@@ -50,6 +61,7 @@ public function aroundValidate(
5061
) {
5162
return true;
5263
}
64+
5365
return $proceed($entity);
5466
}
5567
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
<type name="Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend">
3434
<plugin name="ConfigurableProduct::skipValidation" type="Magento\ConfigurableProduct\Plugin\Model\Attribute\Backend\AttributeValidation"/>
3535
</type>
36+
<type name="Magento\ConfigurableProduct\Plugin\Model\Attribute\Backend\AttributeValidation">
37+
<arguments>
38+
<argument name="unskippableAttributes" xsi:type="array">
39+
<item name="custom_layout_update" xsi:type="string">custom_layout_update</item>
40+
</argument>
41+
</arguments>
42+
</type>
3643
<type name="Magento\Catalog\Model\Entity\Product\Attribute\Group\AttributeMapperInterface">
3744
<plugin name="configurable_product" type="Magento\ConfigurableProduct\Model\Entity\Product\Attribute\Group\AttributeMapper\Plugin" sortOrder="50" />
3845
</type>

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

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
use Magento\Store\Model\ScopeInterface;
5656
use Magento\Store\Model\StoreManagerInterface;
5757
use Psr\Log\LoggerInterface as PsrLogger;
58+
use Magento\Framework\AuthorizationInterface;
5859

5960
/**
6061
* Handle various customer account actions
@@ -69,104 +70,104 @@ class AccountManagement implements AccountManagementInterface
6970
/**
7071
* Configuration paths for create account email template
7172
*
72-
* @deprecated get rid of Helpers in Password Security Management.
73-
* @see \Magento\Customer\Model\EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE
73+
* @deprecated Get rid of Helpers in Password Security Management
74+
* @see EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE
7475
*/
7576
const XML_PATH_REGISTER_EMAIL_TEMPLATE = 'customer/create_account/email_template';
7677

7778
/**
7879
* Configuration paths for register no password email template
7980
*
80-
* @deprecated get rid of Helpers in Password Security Management.
81-
* @see \Magento\Customer\Model\EmailNotification::XML_PATH_REGISTER_NO_PASSWORD_EMAIL_TEMPLATE
81+
* @deprecated Get rid of Helpers in Password Security Management
82+
* @see EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE
8283
*/
8384
const XML_PATH_REGISTER_NO_PASSWORD_EMAIL_TEMPLATE = 'customer/create_account/email_no_password_template';
8485

8586
/**
8687
* Configuration paths for remind email identity
8788
*
88-
* @deprecated get rid of Helpers in Password Security Management.
89-
* @see \Magento\Customer\Model\EmailNotification::XML_PATH_REGISTER_EMAIL_IDENTITY
89+
* @deprecated Get rid of Helpers in Password Security Management
90+
* @see EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE
9091
*/
9192
const XML_PATH_REGISTER_EMAIL_IDENTITY = 'customer/create_account/email_identity';
9293

9394
/**
9495
* Configuration paths for remind email template
9596
*
96-
* @deprecated get rid of Helpers in Password Security Management.
97-
* @see \Magento\Customer\Model\EmailNotification::XML_PATH_REMIND_EMAIL_TEMPLATE
97+
* @deprecated Get rid of Helpers in Password Security Management
98+
* @see EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE
9899
*/
99100
const XML_PATH_REMIND_EMAIL_TEMPLATE = 'customer/password/remind_email_template';
100101

101102
/**
102103
* Configuration paths for forgot email email template
103104
*
104-
* @deprecated get rid of Helpers in Password Security Management.
105-
* @see \Magento\Customer\Model\EmailNotification::XML_PATH_FORGOT_EMAIL_TEMPLATE
105+
* @deprecated Get rid of Helpers in Password Security Management
106+
* @see EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE
106107
*/
107108
const XML_PATH_FORGOT_EMAIL_TEMPLATE = 'customer/password/forgot_email_template';
108109

109110
/**
110111
* Configuration paths for forgot email identity
111112
*
112-
* @deprecated get rid of Helpers in Password Security Management.
113-
* @see \Magento\Customer\Model\EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY
113+
* @deprecated Get rid of Helpers in Password Security Management
114+
* @see EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE
114115
*/
115116
const XML_PATH_FORGOT_EMAIL_IDENTITY = 'customer/password/forgot_email_identity';
116117

117118
/**
118119
* Configuration paths for account confirmation required
119120
*
120-
* @deprecated get rid of Helpers in Password Security Management.
121+
* @deprecated Get rid of Helpers in Password Security Management
121122
* @see AccountConfirmation::XML_PATH_IS_CONFIRM
122123
*/
123124
const XML_PATH_IS_CONFIRM = 'customer/create_account/confirm';
124125

125126
/**
126127
* Configuration paths for account confirmation email template
127128
*
128-
* @deprecated get rid of Helpers in Password Security Management.
129-
* @see \Magento\Customer\Model\EmailNotification::XML_PATH_CONFIRM_EMAIL_TEMPLATE
129+
* @deprecated Get rid of Helpers in Password Security Management
130+
* @see EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE
130131
*/
131132
const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'customer/create_account/email_confirmation_template';
132133

133134
/**
134135
* Configuration paths for confirmation confirmed email template
135136
*
136-
* @deprecated get rid of Helpers in Password Security Management.
137-
* @see \Magento\Customer\Model\EmailNotification::XML_PATH_CONFIRMED_EMAIL_TEMPLATE
137+
* @deprecated Get rid of Helpers in Password Security Management
138+
* @see EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE
138139
*/
139140
const XML_PATH_CONFIRMED_EMAIL_TEMPLATE = 'customer/create_account/email_confirmed_template';
140141

141142
/**
142143
* Constants for the type of new account email to be sent
143144
*
144-
* @deprecated get rid of Helpers in Password Security Management.
145-
* @see \Magento\Customer\Model\EmailNotificationInterface::NEW_ACCOUNT_EMAIL_REGISTERED
145+
* @deprecated Get rid of Helpers in Password Security Management
146+
* @see EmailNotificationInterface::NEW_ACCOUNT_EMAIL_REGISTERED
146147
*/
147148
const NEW_ACCOUNT_EMAIL_REGISTERED = 'registered';
148149

149150
/**
150151
* Welcome email, when password setting is required
151152
*
152-
* @deprecated get rid of Helpers in Password Security Management.
153-
* @see \Magento\Customer\Model\EmailNotificationInterface::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD
153+
* @deprecated Get rid of Helpers in Password Security Management
154+
* @see EmailNotificationInterface::NEW_ACCOUNT_EMAIL_REGISTERED
154155
*/
155156
const NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD = 'registered_no_password';
156157

157158
/**
158159
* Welcome email, when confirmation is enabled
159160
*
160-
* @deprecated get rid of Helpers in Password Security Management.
161-
* @see \Magento\Customer\Model\EmailNotificationInterface::NEW_ACCOUNT_EMAIL_CONFIRMATION
161+
* @deprecated Get rid of Helpers in Password Security Management
162+
* @see EmailNotificationInterface::NEW_ACCOUNT_EMAIL_REGISTERED
162163
*/
163164
const NEW_ACCOUNT_EMAIL_CONFIRMATION = 'confirmation';
164165

165166
/**
166167
* Confirmation email, when account is confirmed
167168
*
168-
* @deprecated get rid of Helpers in Password Security Management.
169-
* @see \Magento\Customer\Model\EmailNotificationInterface::NEW_ACCOUNT_EMAIL_CONFIRMED
169+
* @deprecated Get rid of Helpers in Password Security Management
170+
* @see EmailNotificationInterface::NEW_ACCOUNT_EMAIL_REGISTERED
170171
*/
171172
const NEW_ACCOUNT_EMAIL_CONFIRMED = 'confirmed';
172173

@@ -192,19 +193,26 @@ class AccountManagement implements AccountManagementInterface
192193
/**
193194
* Configuration path to customer reset password email template
194195
*
195-
* @deprecated get rid of Helpers in Password Security Management.
196-
* @see \Magento\Customer\Model\EmailNotification::XML_PATH_RESET_PASSWORD_TEMPLATE
196+
* @deprecated Get rid of Helpers in Password Security Management
197+
* @see Magento/Customer/Model/EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE
197198
*/
198199
const XML_PATH_RESET_PASSWORD_TEMPLATE = 'customer/password/reset_password_template';
199200

200201
/**
201202
* Minimum password length
202203
*
203-
* @deprecated get rid of Helpers in Password Security Management.
204+
* @deprecated Get rid of Helpers in Password Security Management
204205
* @see \Magento\Customer\Model\AccountManagement::XML_PATH_MINIMUM_PASSWORD_LENGTH
205206
*/
206207
const MIN_PASSWORD_LENGTH = 6;
207208

209+
/**
210+
* Authorization level of a basic admin session
211+
*
212+
* @see _isAllowed()
213+
*/
214+
const ADMIN_RESOURCE = 'Magento_Customer::manage';
215+
208216
/**
209217
* @var CustomerFactory
210218
*/
@@ -375,6 +383,11 @@ class AccountManagement implements AccountManagementInterface
375383
*/
376384
private $sessionCleaner;
377385

386+
/**
387+
* @var AuthorizationInterface
388+
*/
389+
private $authorization;
390+
378391
/**
379392
* @param CustomerFactory $customerFactory
380393
* @param ManagerInterface $eventManager
@@ -410,6 +423,7 @@ class AccountManagement implements AccountManagementInterface
410423
* @param GetCustomerByToken|null $getByToken
411424
* @param AllowedCountries|null $allowedCountriesReader
412425
* @param SessionCleanerInterface|null $sessionCleaner
426+
* @param AuthorizationInterface|null $authorization
413427
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
414428
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
415429
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -450,7 +464,8 @@ public function __construct(
450464
AddressRegistry $addressRegistry = null,
451465
GetCustomerByToken $getByToken = null,
452466
AllowedCountries $allowedCountriesReader = null,
453-
SessionCleanerInterface $sessionCleaner = null
467+
SessionCleanerInterface $sessionCleaner = null,
468+
AuthorizationInterface $authorization = null
454469
) {
455470
$this->customerFactory = $customerFactory;
456471
$this->eventManager = $eventManager;
@@ -490,6 +505,7 @@ public function __construct(
490505
$this->allowedCountriesReader = $allowedCountriesReader
491506
?: $objectManager->get(AllowedCountries::class);
492507
$this->sessionCleaner = $sessionCleaner ?? $objectManager->get(SessionCleanerInterface::class);
508+
$this->authorization = $authorization ?? $objectManager->get(AuthorizationInterface::class);
493509
}
494510

495511
/**
@@ -836,6 +852,11 @@ public function getConfirmationStatus($customerId)
836852
*/
837853
public function createAccount(CustomerInterface $customer, $password = null, $redirectUrl = '')
838854
{
855+
$groupId = $customer->getGroupId();
856+
if (isset($groupId) && !$this->authorization->isAllowed(self::ADMIN_RESOURCE)) {
857+
$customer->setGroupId(null);
858+
}
859+
839860
if ($password !== null) {
840861
$this->checkPasswordStrength($password);
841862
$customerEmail = $customer->getEmail();

0 commit comments

Comments
 (0)