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

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
zarthan
Newcomer
Posts: 11
Joined: Tue Sep 25, 2018 8:15 pm
United States of America

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

Post by zarthan »

I am getting some mythweb errors on the Schedule a recording page.
Warning at /usr/share/mythtv/bindings/php/MythBackend.php, line 194:
!!NoTrans: count(): Parameter must be an array or an object that implements Countable!!

They don't seem to be causing any problems so far that I have noticed but not positive.

Fresh install of Xubuntu 18.04.1
MythTV Version : v29.1-38-gb9c5f8b
MythTV Branch : fixes/29
Network Protocol : 91
Library API : 29.20180316-1
QT Version : 5.9.5
zarthan
Newcomer
Posts: 11
Joined: Tue Sep 25, 2018 8:15 pm
United States of America

Re: !!NoTrans: count(): Parameter must be an array or an object that implements Countable!!

Post by zarthan »

Thanks, I had seen that and there wasn't a fix. The original problem in the link you provided was that Mythweb wouldn't start and the changes that are listed in the fix to recorded.php were already included in my install.
zarthan
Newcomer
Posts: 11
Joined: Tue Sep 25, 2018 8:15 pm
United States of America

Re: !!NoTrans: count(): Parameter must be an array or an object that implements Countable!!

Post by zarthan »

A Google search indicates this may be an issue with PHP 7.2 which is what I have with Xubuntu 18.04.1
I suppose I should report this.
User avatar
bill6502
Developer
Posts: 2307
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: !!NoTrans: count(): Parameter must be an array or an object that implements Countable!!

Post by bill6502 »

Hi,

You're right, there were a couple of issues in that thread. Just to be clear, what
is the output of:

Code: Select all

ls -ld  /etc/apache2/mods-enabled/php7.2*
zarthan
Newcomer
Posts: 11
Joined: Tue Sep 25, 2018 8:15 pm
United States of America

Re: !!NoTrans: count(): Parameter must be an array or an object that implements Countable!!

Post by zarthan »

ls -ld /etc/apache2/mods-enabled/php7.2*
lrwxrwxrwx 1 root root 29 Sep 21 20:41 /etc/apache2/mods-enabled/php7.2.conf -> ../mods-available/php7.2.conf
lrwxrwxrwx 1 root root 29 Sep 21 20:41 /etc/apache2/mods-enabled/php7.2.load -> ../mods-available/php7.2.load
daraden
Senior
Posts: 175
Joined: Tue Feb 23, 2016 7:33 am
United States of America

Re: !!NoTrans: count(): Parameter must be an array or an object that implements Countable!!

Post by daraden »

I may have found a possible solution to this issue. looks like replacing line 194

Code: Select all

        $count = count($records);
with

Code: Select all

       if (is_array($records)) $count = count($records);
       else $count = 0;
may resolve this issue in PHP 7.2. Not a PHP programmer so I'm not aware of any issues with implementing this solution.
zarthan
Newcomer
Posts: 11
Joined: Tue Sep 25, 2018 8:15 pm
United States of America

Re: !!NoTrans: count(): Parameter must be an array or an object that implements Countable!!

Post by zarthan »

Thanks. I made the change and that does make the error message go away. If there was, in fact, a real underlying issue I didn't see anything very obvious. I will keep watch and update this if there are any issues.
If you don't mind I will add this as a comment to my bug report with reference to your post.
daraden
Senior
Posts: 175
Joined: Tue Feb 23, 2016 7:33 am
United States of America

Re: !!NoTrans: count(): Parameter must be an array or an object that implements Countable!!

Post by daraden »

the count() error is listed in the PHP manual as an incompatible change in 7.2https://secure.php.net/manual/en/migrat ... atible.php. Basically in previous versions the code produced the desired result, but probably should have been an error and in 7.2 it is an error.

This error is likely to pop up in a few places throughout the Mythweb code. I have made a similar change to the recording details page to deal with having an empty job queue entry.

This should also work and run slightly faster. The previous change just seems more correct to me. Both should be compatible with earlier versions of PHP:

Code: Select all

       if ($records) $count = count($records);
       else $count = 0;
Post Reply