Skip to content

Fix Division By Zero Warning (PHP7 compatibility)#468

Open
tremlin wants to merge 1 commit into
dweeves:masterfrom
initOS:master-PHP7
Open

Fix Division By Zero Warning (PHP7 compatibility)#468
tremlin wants to merge 1 commit into
dweeves:masterfrom
initOS:master-PHP7

Conversation

@tremlin

@tremlin tremlin commented Jul 22, 2016

Copy link
Copy Markdown

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

tremlin commented Oct 8, 2016

Copy link
Copy Markdown
Author

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

@tmotyl

tmotyl commented Feb 28, 2017

Copy link
Copy Markdown
Collaborator

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
Copy Markdown

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