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

Fix Division By Zero Warning (PHP7 compatibility) #468

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tremlin
Copy link

@tremlin tremlin commented Jul 22, 2016

In our installation magmi didn't work with PHP7 because of a divison by zero error. Calculation mod 0 is no longer supported by PHP7 (only a warning in PHP5). This change prevents this error.

@tremlin
Copy link
Author

tremlin commented Oct 8, 2016

I haven't tested if this fix is still needed after the latest refactoring of the product import engine.

@tmotyl
Copy link
Collaborator

tmotyl commented Feb 28, 2017

this is not the best way to fix it. The root cause is a bug in the getProp function which doesn't return default value in case of empty string.

around line 936 there is

$pstep = $this->getProp("GLOBAL", "step", 0.5);

And because "step" property is set to empty string and getProp is not handling it correctly $pstep is set to empty string, which then is converted to 0 in the next line

$rstep = ceil(($nitems * $pstep) / 100);

The correct solution for the issue is to fix getProp to return default value (0.5 in this case) when property is an empty string.

@idziakjakub
Copy link

This is a fix for this issue:

#516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants