getminera / minera

Minera is a web interface to monitor and manage mining devices

Home Page:http://getminera.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

count() reports error on non-countable objects in php7.2

PSLLSP opened this issue · comments

Describe the bug
php 7.2 changes behavior of count() function; it is not a bug but the feature! When count() was called with NULL or scalar in the past, it returned 0 or 1. In php-7.2, it throws an exception!

To Reproduce
Several places use count() in "dangerous way", example is minera/application/views/frontpage.php, line 17 ($netMiners could be NULL):

<?php if (count($netMiners) > 0) : ?>

A PHP Error was encountered
Severity: Warning

Message: count(): Parameter must be an array or an object that implements Countable

Filename: views/frontpage.php

Line Number: 17

Solution is to check type of value with gettype() and use count only on array or initialize values with empty arrays...

I installed Minera manually to Ubuntu 18.04.4 with php 7.2 and I see this problem...

BTW, instructions for manual installation doesn't work, they are full of incorrect/outdated instructions, and several steps are missing...

There is a bug in file minera/application/controllers/app.php, one condition is wrong:

class App extends CI_Controller {
....
-               if (count($boxStatuses > 0)) {
+               if (count($boxStatuses) > 0) {

Hey thanks, if you can do a pull request I will review it