Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293910

php 7.1 Warning: A non-numeric value encountered in theme_pager()

$
0
0

PHP 7.1 and Drupal commerce, navigating to /admin/commerce/orders to view orders generates the following warning:

Warning: A non-numeric value encountered in theme_pager() (line 329 of /includes/pager.inc).

This is directly the result of the new warnings in php 7.1 performing arithmetic operations on variables that are empty or not integer. While I found this in Drupal commerce, the file generating the warning is in core so I suspect the same would occur outside diurnal commerce.

The code causing the problem is:

$pager_middle = ceil($quantity / 2);

and will generate the warning if $quantity is empty. To fix the problem, I replace the line where $quantity is set :

$quantity = $variables['quantity'];

with

$quantity = empty($variables['quantity']) ? 0 : $variables['quantity'];

I have attached the patch. This is the first time I submit a patch for core, apologies if I'm not following the correct protocol.


Viewing all articles
Browse latest Browse all 293910

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>