Skip to content

Commit d7d67ab

Browse files
committed
Merge branch 'ACP2E-2949' of https://github.com/adobe-commerce-tier-4/magento2ce into T4-PR-04-08-2024
2 parents 0ede4c4 + dfc54f9 commit d7d67ab

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/internal/Magento/Framework/Model/AbstractModel.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,12 +1040,14 @@ public function getEventPrefix()
10401040
private function checkAndConvertNumericValue(mixed $key, mixed $value): void
10411041
{
10421042
if (array_key_exists($key, $this->_data) && is_numeric($this->_data[$key])
1043-
&& $value != null
1043+
&& $value !== null
10441044
) {
1045-
if (is_int($value)) {
1046-
$this->_data[$key] = (int) $this->_data[$key];
1047-
} elseif (is_float($value)) {
1045+
if (is_float($value) ||
1046+
(is_string($value) && preg_match('/^-?\d*\.\d+$/', $value))
1047+
) {
10481048
$this->_data[$key] = (float) $this->_data[$key];
1049+
} elseif (is_int($value)) {
1050+
$this->_data[$key] = (int) $this->_data[$key];
10491051
}
10501052
}
10511053
}

lib/internal/Magento/Framework/Model/Test/Unit/AbstractModelTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ public function getKeyValueDataPairs(): array
233233
'when test data and compare data are float' => [['key' => 1.0], 'key', 1.0, false],
234234
'when test data is 0 and compare data is null' => [['key' => 0], 'key', null, false],
235235
'when test data is null and compare data is 0' => [['key' => null], 'key', 0, false],
236+
'when test data is string array and compare data is int' => [['key' => '10'], 'key', 10, false],
237+
'when test data is string array and compare data is float' => [['key' => '22.00'], 'key', 22.00, false]
236238
];
237239
}
238240
}

0 commit comments

Comments
 (0)