Inchoo / Inchoo_PHP7

PHP 7 compatibility extension for Magento 1 (DEPRECATED!!)
MIT License
352 stars 112 forks source link

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

Open ivanweiler opened 7 years ago

ivanweiler commented 7 years ago

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

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 commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

@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?