Skip to content

Commit 95d52d3

Browse files
elidrissidevkiatng
andauthored
Handle empty Order increment prefix (#1718)
* Handle empty Order increment prefix A call to `strpos` with an empty needle would throw a warning pre PHP 8.0. This change will check if the prefix is not empty first before performing the call to `strpos`. * Use the string casted prefix in `strlen` call Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com> * Fix syntax error Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
1 parent 24c9fd0 commit 95d52d3

File tree

1 file changed

+2
-2
lines changed
  • app/code/core/Mage/Eav/Model/Entity/Increment

1 file changed

+2
-2
lines changed

app/code/core/Mage/Eav/Model/Entity/Increment/Numeric.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public function getNextId()
4545

4646
if (empty($last)) {
4747
$last = 0;
48-
} else if (strpos($last, (string)$this->getPrefix()) === 0) {
49-
$last = (int)substr($last, strlen($this->getPrefix()));
48+
} else if (!empty($prefix = (string)$this->getPrefix()) && strpos($last, $prefix) === 0) {
49+
$last = (int)substr($last, strlen($prefix));
5050
} else {
5151
$last = (int)$last;
5252
}

0 commit comments

Comments
 (0)