Skip to content

Commit 978369c

Browse files
committed
MCP-767: Improve Consumers Order Creation Throughput
- Fix issue with underscore between alphanumerical characters in data objects;
1 parent 7d18dcd commit 978369c

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

app/code/Magento/Sales/Model/Order/Payment.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,6 +2272,21 @@ public function setCcLast4($ccLast4)
22722272
return $this->setData(OrderPaymentInterface::CC_LAST_4, $ccLast4);
22732273
}
22742274

2275+
/**
2276+
* @inheritDoc
2277+
*
2278+
* Because cc_last_4 data attribute violates data contract (use underscore (_) between alphanumerical characters),
2279+
* this ad hoc method is for setting cc_last_4 data value in \Magento\Framework\Api\DataObjectHelper::_setDataValues
2280+
*/
2281+
public function setCustomAttribute($attributeCode, $attributeValue)
2282+
{
2283+
if ($attributeCode === OrderPaymentInterface::CC_LAST_4) {
2284+
return parent::setData(OrderPaymentInterface::CC_LAST_4, $attributeValue);
2285+
}
2286+
2287+
return parent::setCustomAttribute($attributeCode, $attributeValue);
2288+
}
2289+
22752290
/**
22762291
* @inheritdoc
22772292
*/

lib/internal/Magento/Framework/Api/DataObjectHelper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public function populateWithArray($dataObject, array $data, $interfaceName)
9494
* @param string $interfaceName
9595
* @return $this
9696
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
97+
* @SuppressWarnings(PHPMD.NPathComplexity)
9798
*/
9899
protected function _setDataValues($dataObject, array $data, $interfaceName)
99100
{
@@ -300,11 +301,11 @@ private function getSetters(object $dataObject): array
300301
',',
301302
strtolower(
302303
// (0) remove all not setter
303-
// (1) add _ before upper letter or digits
304+
// (1) add _ before upper letter
304305
// (2) remove set_ in start of name
305306
// (3) add name without is_ prefix
306307
preg_replace(
307-
['/(^|,)(?!set)[^,]*/S','/(.)([A-Z]|[0-9]+)/S', '/(^|,)set_/iS', '/(^|,)is_([^,]+)/is'],
308+
['/(^|,)(?!set)[^,]*/S','/(.)([A-Z])/S', '/(^|,)set_/iS', '/(^|,)is_([^,]+)/is'],
308309
['', '$1_$2', '$1', '$1$2,is_$2'],
309310
implode(',', $dataObjectMethods)
310311
)

lib/internal/Magento/Framework/Api/ImageContent.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ public function setBase64EncodedData($data)
5656
return $this->setData(self::BASE64_ENCODED_DATA, $data);
5757
}
5858

59-
/**
60-
* {@inheritdoc}
61-
*/
62-
public function setData($key, $value)
63-
{
64-
if ($key === 'base_64_encoded_data') {
65-
return parent::setData(self::BASE64_ENCODED_DATA, $value);
66-
}
67-
68-
return parent::setData($key, $value);
69-
}
70-
7159
/**
7260
* {@inheritdoc}
7361
*

0 commit comments

Comments
 (0)