Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle empty Order increment prefix #1718

Merged

Conversation

elidrissidev
Copy link
Member

@elidrissidev elidrissidev commented Jul 4, 2021

Description (*)

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.

Fixed Issues (if relevant)

  1. Fixes strpos(): Empty needle if Order Increment Prefix is an empty string #1645

Manual testing scenarios (*)

  1. Make sure you're on PHP 7.x as this warning is not thrown in PHP 8.0
  2. Execute the following query to set an empty prefix for order increment ids:
update eav_entity_store set increment_prefix = '' where entity_type_id = '5';
  1. Try to create an order from the Admin and a similar error should show up:
Order saving error: Warning: strpos(): Empty needle in /var/www/openmage/app/code/core/Mage/Eav/Model/Entity/Increment/Numeric.php on line 48

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)

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`.
@github-actions github-actions bot added the Component: Eav Relates to Mage_Eav label Jul 4, 2021
Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
kiatng
kiatng previously approved these changes Jul 5, 2021
Copy link
Contributor

@Flyingmana Flyingmana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix Syntax error

@Flyingmana Flyingmana merged commit 95d52d3 into OpenMage:1.9.4.x Jul 13, 2021
@github-actions
Copy link
Contributor

Unit Test Results

1 files  ±0  1 suites  ±0   0s ⏱️ ±0s
0 tests ±0  0 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
6 runs  ±0  4 ✔️ ±0  2 💤 ±0  0 ❌ ±0 

Results for commit 95d52d3. ± Comparison against base commit 7f84c55.

@elidrissidev elidrissidev deleted the handle-empty-order-increment-prefix branch July 13, 2021 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Eav Relates to Mage_Eav
Projects
None yet
Development

Successfully merging this pull request may close these issues.

strpos(): Empty needle if Order Increment Prefix is an empty string
5 participants