Skip to content

Commit 7e11422

Browse files
committed
Merge remote-tracking branch 'origin/AC-3110-p4' into delivery-bunch-w21
2 parents fcb22a3 + cf1d676 commit 7e11422

File tree

12 files changed

+93
-77
lines changed

12 files changed

+93
-77
lines changed

app/code/Magento/Customer/Controller/Plugin/Account.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function aroundExecute(AccountInterface $controllerAction, Closure $proce
7272
*/
7373
private function isActionAllowed(): bool
7474
{
75-
$action = strtolower($this->request->getActionName());
75+
$action = strtolower($this->request->getActionName() ?? '');
7676
$pattern = '/^(' . implode('|', $this->allowedActions) . ')$/i';
7777

7878
return (bool)preg_match($pattern, $action);

app/code/Magento/Customer/CustomerData/SectionConfigConverter.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
*/
66
namespace Magento\Customer\CustomerData;
77

8+
use Magento\Framework\Config\ConverterInterface;
9+
810
/**
911
* Class that receives xml merged source and process it.
1012
*/
11-
class SectionConfigConverter implements \Magento\Framework\Config\ConverterInterface
13+
class SectionConfigConverter implements ConverterInterface
1214
{
1315
/**
1416
* Invalidate all sections marker
1517
*/
16-
const INVALIDATE_ALL_SECTIONS_MARKER = '*';
18+
public const INVALIDATE_ALL_SECTIONS_MARKER = '*';
1719

1820
/**
1921
* @inheritdoc
@@ -22,9 +24,11 @@ public function convert($source)
2224
{
2325
$sections = [];
2426
foreach ($source->getElementsByTagName('action') as $action) {
25-
$actionName = strtolower($action->getAttribute('name'));
27+
$actionName = $action->getAttribute('name') === null ? '' : strtolower($action->getAttribute('name'));
2628
foreach ($action->getElementsByTagName('section') as $section) {
27-
$sections[$actionName][] = strtolower($section->getAttribute('name'));
29+
$sections[$actionName][] = $section->getAttribute('name') === null ?
30+
''
31+
: strtolower($section->getAttribute('name'));
2832
}
2933
if (!isset($sections[$actionName])) {
3034
$sections[$actionName][] = self::INVALIDATE_ALL_SECTIONS_MARKER;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AccountConfirmation
1717
/**
1818
* Configuration path for email confirmation.
1919
*/
20-
const XML_PATH_IS_CONFIRM = 'customer/create_account/confirm';
20+
public const XML_PATH_IS_CONFIRM = 'customer/create_account/confirm';
2121

2222
/**
2323
* @var ScopeConfigInterface
@@ -73,7 +73,7 @@ public function isConfirmationRequired($websiteId, $customerId, $customerEmail):
7373
*/
7474
private function canSkipConfirmation($customerId, $customerEmail): bool
7575
{
76-
if (!$customerId) {
76+
if (!$customerId || $customerEmail === null) {
7777
return false;
7878
}
7979

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,8 @@ protected function checkPasswordStrength($password)
759759
)
760760
);
761761
}
762-
if ($this->stringHelper->strlen(trim($password)) != $length) {
762+
$trimmedPassLength = $this->stringHelper->strlen($password === null ? '' : trim($password));
763+
if ($trimmedPassLength != $length) {
763764
throw new InputException(
764765
__("The password can't begin or end with a space. Verify the password and try again.")
765766
);
@@ -789,17 +790,19 @@ protected function makeRequiredCharactersCheck($password)
789790
$requiredNumber = $this->scopeConfig->getValue(self::XML_PATH_REQUIRED_CHARACTER_CLASSES_NUMBER);
790791
$return = 0;
791792

792-
if (preg_match('/[0-9]+/', $password)) {
793-
$counter++;
794-
}
795-
if (preg_match('/[A-Z]+/', $password)) {
796-
$counter++;
797-
}
798-
if (preg_match('/[a-z]+/', $password)) {
799-
$counter++;
800-
}
801-
if (preg_match('/[^a-zA-Z0-9]+/', $password)) {
802-
$counter++;
793+
if ($password !== null) {
794+
if (preg_match('/[0-9]+/', $password)) {
795+
$counter++;
796+
}
797+
if (preg_match('/[A-Z]+/', $password)) {
798+
$counter++;
799+
}
800+
if (preg_match('/[a-z]+/', $password)) {
801+
$counter++;
802+
}
803+
if (preg_match('/[^a-zA-Z0-9]+/', $password)) {
804+
$counter++;
805+
}
803806
}
804807

805808
if ($counter < $requiredNumber) {
@@ -1387,7 +1390,7 @@ protected function isConfirmationRequired($customer)
13871390
*/
13881391
protected function canSkipConfirmation($customer)
13891392
{
1390-
if (!$customer->getId()) {
1393+
if (!$customer->getId() || $customer->getEmail() === null) {
13911394
return false;
13921395
}
13931396

app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function __construct(
7474
*/
7575
protected function _getAttributeCode()
7676
{
77-
return str_replace('_show', '', $this->getField());
77+
return $this->getField() === null ? '' : str_replace('_show', '', $this->getField());
7878
}
7979

8080
/**
@@ -137,7 +137,7 @@ public function afterDelete()
137137
$attributeObject->setData('scope_is_visible', null);
138138
$attributeObject->save();
139139
}
140-
} else if ($this->getScope() == ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
140+
} elseif ($this->getScope() == ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
141141
$valueConfig = $this->getValueConfig($this->telephoneShowDefaultValue);
142142
foreach ($this->_getAttributeObjects() as $attributeObject) {
143143
$attributeObject->setData('is_required', $valueConfig['is_required']);

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,41 +50,42 @@ class Customer extends \Magento\Framework\Model\AbstractModel
5050
/**
5151
* Configuration paths for email templates and identities
5252
*/
53-
const XML_PATH_REGISTER_EMAIL_TEMPLATE = 'customer/create_account/email_template';
53+
public const XML_PATH_REGISTER_EMAIL_TEMPLATE = 'customer/create_account/email_template';
5454

55-
const XML_PATH_REGISTER_EMAIL_IDENTITY = 'customer/create_account/email_identity';
55+
public const XML_PATH_REGISTER_EMAIL_IDENTITY = 'customer/create_account/email_identity';
5656

57-
const XML_PATH_REMIND_EMAIL_TEMPLATE = 'customer/password/remind_email_template';
57+
public const XML_PATH_REMIND_EMAIL_TEMPLATE = 'customer/password/remind_email_template';
5858

59-
const XML_PATH_FORGOT_EMAIL_TEMPLATE = 'customer/password/forgot_email_template';
59+
public const XML_PATH_FORGOT_EMAIL_TEMPLATE = 'customer/password/forgot_email_template';
6060

61-
const XML_PATH_FORGOT_EMAIL_IDENTITY = 'customer/password/forgot_email_identity';
61+
public const XML_PATH_FORGOT_EMAIL_IDENTITY = 'customer/password/forgot_email_identity';
6262

63-
const XML_PATH_RESET_PASSWORD_TEMPLATE = 'customer/password/reset_password_template';
63+
public const XML_PATH_RESET_PASSWORD_TEMPLATE = 'customer/password/reset_password_template';
6464

6565
/**
6666
* @deprecated @see \Magento\Customer\Model\AccountConfirmation::XML_PATH_IS_CONFIRM
6767
*/
68-
const XML_PATH_IS_CONFIRM = 'customer/create_account/confirm';
68+
public const XML_PATH_IS_CONFIRM = 'customer/create_account/confirm';
6969

70-
const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'customer/create_account/email_confirmation_template';
70+
public const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'customer/create_account/email_confirmation_template';
7171

72-
const XML_PATH_CONFIRMED_EMAIL_TEMPLATE = 'customer/create_account/email_confirmed_template';
72+
public const XML_PATH_CONFIRMED_EMAIL_TEMPLATE = 'customer/create_account/email_confirmed_template';
7373

74-
const XML_PATH_GENERATE_HUMAN_FRIENDLY_ID = 'customer/create_account/generate_human_friendly_id';
74+
public const XML_PATH_GENERATE_HUMAN_FRIENDLY_ID = 'customer/create_account/generate_human_friendly_id';
7575

76-
const SUBSCRIBED_YES = 'yes';
76+
public const SUBSCRIBED_YES = 'yes';
7777

78-
const SUBSCRIBED_NO = 'no';
78+
public const SUBSCRIBED_NO = 'no';
7979

80-
const ENTITY = 'customer';
80+
public const ENTITY = 'customer';
8181

82-
const CUSTOMER_GRID_INDEXER_ID = 'customer_grid';
82+
public const CUSTOMER_GRID_INDEXER_ID = 'customer_grid';
8383

8484
/**
8585
* Configuration path to expiration period of reset password link
8686
*/
87-
const XML_PATH_CUSTOMER_RESET_PASSWORD_LINK_EXPIRATION_PERIOD = 'customer/password/reset_link_expiration_period';
87+
public const XML_PATH_CUSTOMER_RESET_PASSWORD_LINK_EXPIRATION_PERIOD =
88+
'customer/password/reset_link_expiration_period';
8889

8990
/**
9091
* Model event prefix
@@ -1203,7 +1204,7 @@ public function setIsReadonly($value)
12031204
*/
12041205
protected function canSkipConfirmation()
12051206
{
1206-
if (!$this->getId()) {
1207+
if (!$this->getId() || $this->getEmail() === null) {
12071208
return false;
12081209
}
12091210

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function __construct(
119119
*/
120120
public function getBase64EncodedData($fileName)
121121
{
122-
$filePath = $this->entityTypeCode . '/' . ltrim($fileName, '/');
122+
$filePath = $this->entityTypeCode . '/' . ($fileName === null ? '' : ltrim($fileName, '/'));
123123

124124
$fileContent = $this->mediaDirectory->readFile($filePath);
125125

@@ -134,7 +134,7 @@ public function getBase64EncodedData($fileName)
134134
*/
135135
public function getStat($fileName)
136136
{
137-
$filePath = $this->entityTypeCode . '/' . ltrim($fileName, '/');
137+
$filePath = $this->entityTypeCode . '/' . ($fileName === null ? '' : ltrim($fileName, '/'));
138138

139139
return $this->mediaDirectory->stat($filePath);
140140
}
@@ -147,7 +147,7 @@ public function getStat($fileName)
147147
*/
148148
public function getMimeType($fileName)
149149
{
150-
$filePath = $this->entityTypeCode . '/' . ltrim($fileName, '/');
150+
$filePath = $this->entityTypeCode . '/' . ($fileName === null ? '' : ltrim($fileName, '/'));
151151
$absoluteFilePath = $this->mediaDirectory->getAbsolutePath($filePath);
152152

153153
return $this->mime->getMimeType($absoluteFilePath);
@@ -161,7 +161,7 @@ public function getMimeType($fileName)
161161
*/
162162
public function isExist($fileName)
163163
{
164-
$filePath = $this->entityTypeCode . '/' . ltrim($fileName, '/');
164+
$filePath = $this->entityTypeCode . '/' . ($fileName === null ? '' : ltrim($fileName, '/'));
165165

166166
return $this->mediaDirectory->isExist($filePath);
167167
}
@@ -180,14 +180,14 @@ public function getViewUrl($filePath, $type)
180180
if ($this->entityTypeCode == AddressMetadataInterface::ENTITY_TYPE_ADDRESS) {
181181
$viewUrl = $this->urlBuilder->getUrl(
182182
$this->customerAddressFileUrlPath,
183-
[$type => $this->urlEncoder->encode(ltrim($filePath, '/'))]
183+
[$type => $filePath === null ? '' : $this->urlEncoder->encode(ltrim($filePath, '/'))]
184184
);
185185
}
186186

187187
if ($this->entityTypeCode == CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER) {
188188
$viewUrl = $this->urlBuilder->getUrl(
189189
$this->customerFileUrlPath,
190-
[$type => $this->urlEncoder->encode(ltrim($filePath, '/'))]
190+
[$type => $filePath === null ? '' : $this->urlEncoder->encode(ltrim($filePath, '/'))]
191191
);
192192
}
193193

@@ -283,7 +283,7 @@ public function moveTemporaryFile($fileName)
283283
*/
284284
public function removeUploadedFile($fileName)
285285
{
286-
$filePath = $this->entityTypeCode . '/' . ltrim($fileName, '/');
286+
$filePath = $this->entityTypeCode . '/' . ($fileName === null ? '' : ltrim($fileName, '/'));
287287

288288
return $this->mediaDirectory->delete($filePath);
289289
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ public function uploadFile($useScope = true)
129129
$result = $fileProcessor->saveTemporaryFile($fileId);
130130

131131
// Update tmp_name param. Required for attribute validation!
132-
$result['tmp_name'] = ltrim($result['file'], '/');
132+
$result['tmp_name'] = ltrim($result['file'] ?? '', '/');
133133

134134
$result['url'] = $fileProcessor->getViewUrl(
135-
FileProcessor::TMP_DIR . '/' . ltrim($result['name'], '/'),
135+
FileProcessor::TMP_DIR . '/' . ltrim($result['name'] ?? '', '/'),
136136
$this->attributeMetadata->getFrontendInput()
137137
);
138138

@@ -191,7 +191,7 @@ private function getAllowedExtensions()
191191
$validationRules = $this->attributeMetadata->getValidationRules();
192192
foreach ($validationRules as $validationRule) {
193193
if ($validationRule->getName() == 'file_extensions') {
194-
$allowedExtensions = explode(',', $validationRule->getValue());
194+
$allowedExtensions = explode(',', $validationRule->getValue() ?? '');
195195
array_walk(
196196
$allowedExtensions,
197197
function (&$value) {

app/code/Magento/Customer/Model/Metadata/Form/File.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function extractValue(\Magento\Framework\App\RequestInterface $request)
131131
$value = $uploadedFile;
132132
} elseif ($this->_requestScope || !isset($_FILES[$attrCode])) {
133133
$value = [];
134-
if (strpos($this->_requestScope, DIRECTORY_SEPARATOR) !== false) {
134+
if ($this->_requestScope !== null && strpos($this->_requestScope, DIRECTORY_SEPARATOR) !== false) {
135135
$scopes = explode(DIRECTORY_SEPARATOR, $this->_requestScope);
136136
$mainScope = array_shift($scopes);
137137
} else {
@@ -299,6 +299,7 @@ public function validateValue($value)
299299
/**
300300
* @inheritdoc
301301
*
302+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
302303
* @return ImageContentInterface|array|string|null
303304
*/
304305
public function compactValue($value)
@@ -367,7 +368,7 @@ protected function processInputFieldValue($value)
367368

368369
if ($toDelete) {
369370
$mediaDir->delete($this->_entityTypeCode . DIRECTORY_SEPARATOR .
370-
ltrim($this->_value, DIRECTORY_SEPARATOR));
371+
ltrim($this->_value ?? '', DIRECTORY_SEPARATOR));
371372
$result = '';
372373
}
373374

app/code/Magento/Customer/Model/Metadata/Form/Multiline.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
<?php
22
/**
3-
* Form Element Multiline Data Model
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
86
namespace Magento\Customer\Model\Metadata\Form;
97

8+
use Magento\Customer\Model\Metadata\ElementFactory;
9+
use Magento\Framework\App\RequestInterface;
10+
11+
/**
12+
* Form Element Multiline Data Model
13+
*/
1014
class Multiline extends Text
1115
{
1216
/**
1317
* @inheritDoc
1418
*/
15-
public function extractValue(\Magento\Framework\App\RequestInterface $request)
19+
public function extractValue(RequestInterface $request)
1620
{
1721
$value = $this->_getRequestValue($request);
1822
if (!is_array($value)) {
@@ -37,7 +41,7 @@ public function validateValue($value)
3741
// try to load original value and validate it
3842
$value = $this->_value;
3943
if (!is_array($value)) {
40-
$value = explode("\n", $value);
44+
$value = explode("\n", (string)$value);
4145
}
4246
}
4347

@@ -96,21 +100,21 @@ public function restoreValue($value)
96100
/**
97101
* @inheritDoc
98102
*/
99-
public function outputValue($format = \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT)
103+
public function outputValue($format = ElementFactory::OUTPUT_FORMAT_TEXT)
100104
{
101105
$values = $this->_value;
102106
if (!is_array($values)) {
103-
$values = explode("\n", $values);
107+
$values = explode("\n", (string)$values);
104108
}
105109
$values = array_map([$this, '_applyOutputFilter'], $values);
106110
switch ($format) {
107-
case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_ARRAY:
111+
case ElementFactory::OUTPUT_FORMAT_ARRAY:
108112
$output = $values;
109113
break;
110-
case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_HTML:
114+
case ElementFactory::OUTPUT_FORMAT_HTML:
111115
$output = implode("<br />", $values);
112116
break;
113-
case \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_ONELINE:
117+
case ElementFactory::OUTPUT_FORMAT_ONELINE:
114118
$output = implode(" ", $values);
115119
break;
116120
default:

0 commit comments

Comments
 (0)