Skip to content
This repository has been archived by the owner on Jun 10, 2019. It is now read-only.

PHP 7.1 - Warning: A non-numeric value encountered #97

Open
ivanweiler opened this issue Dec 30, 2016 · 3 comments
Open

PHP 7.1 - Warning: A non-numeric value encountered #97

ivanweiler opened this issue Dec 30, 2016 · 3 comments

Comments

@ivanweiler
Copy link
Contributor

Magento 1.9.3.1 (clean install + sample data), PHP 7.1.0

Warning: A non-numeric value encountered in /app/code/core/Mage/Shipping/Model/Carrier/Abstract.php on line 466 in system.log on shipping calculation on checkout.

Just to be clear, checkout works fine, only logs are bloated.
PHP 7.1 throws warnings on things like 1 + '', so I'm opening this issue to write them down.

In this case default handling_fee config value for all shipping methods should be zero and not blank/null.
$handlingFee = $this->getConfigData('handling_fee');

To avoid warning, we can

  • copy Abstract to local/Mage and cast handling_fee to (float)
  • just set Handling Fee: 0 for enabled shipping methods in administration (write this in wiki?)
  • make field required through system.xml, so zero needs to be entered, set value to zero through config.xml

I'm not sure how many similar cases there are, especially with config values, so it's hard to know best approach.

I think more similar warnings will pop up on 7.1, so please submit them when you see them, we need input :)

@icurdinj
Copy link
Contributor

I guess Wiki for PHP 7.1 + default in config.xml is the least intrusive way, which is one of the principles we've followed so far in this extension. And it will be easy to add fixes for any more cases like this that users report.

@mvscheidt
Copy link

I encountered the same problem with PHP 7.1 for the file app/design/adminhtml/default/default/template/catalog/product/tab/inventory.phtml in Line 80 using Magento 1.9.3.6 when creating a Product. Happens directly when trying to saving the Attribute set and Attribute Type (after the first step basically)

<td class="value"><input type="text" class="input-text validate-number" id="inventory_min_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][min_sale_qty]" value="<?php echo $this->getFieldValue('min_sale_qty')*1 ?>" <?php echo $_readonly;?>/>

The bit which causes this is

value="<?php echo $this->getFieldValue('min_sale_qty')*1 ?>"

I'm not sure if the min_sale_qty is set by default or if we removed it in our project, but fact of the matter is we have no min_sale_qty configured right now and thus the issue is triggered.

One quick fix is to cast to (int) which displays 0 in the min_sale_qty input as expected

value="<?php echo (int)$this->getFieldValue('min_sale_qty')*1 ?>"

Setting it in the config.xml is probably a better idea though (you have to either configure which groups have which min_sale_qty or configure one qty for all - theres a dropdown for that).

@phoenix-bjoern
Copy link

@ivanweiler did a lot of work for PHP7.1 compatibility and the 3.0 release. But these changes are only in the develop branch for now. What is stopping you from merging it to the master branch?

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

No branches or pull requests

4 participants