Skip to content

Commit

Permalink
Handle empty Order increment prefix (#1718)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
elidrissidev and kiatng authored Jul 13, 2021
1 parent 24c9fd0 commit 95d52d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/code/core/Mage/Eav/Model/Entity/Increment/Numeric.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public function getNextId()

if (empty($last)) {
$last = 0;
} else if (strpos($last, (string)$this->getPrefix()) === 0) {
$last = (int)substr($last, strlen($this->getPrefix()));
} else if (!empty($prefix = (string)$this->getPrefix()) && strpos($last, $prefix) === 0) {
$last = (int)substr($last, strlen($prefix));
} else {
$last = (int)$last;
}
Expand Down

0 comments on commit 95d52d3

Please sign in to comment.