Uncaught TypeError: count()

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
krolli
Posts: 8
Joined: Tue Feb 01, 2022 6:48 pm

Uncaught TypeError: count()

Post by krolli »

Script: admin_ticket.php
Hesk version: 3.4.3

Hey! :D

Code: Select all

PHP Warning:  Undefined variable $attachments in (...) /admin/admin_ticket.php on line 378
PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in (...) /admin/admin_ticket.php:378
This error happens if you have attachments turned Off and you want to post a note and also you are on >=PHP8.0 ("count() will now throw TypeError on invalid countable types passed to the value parameter.").

Line 378:

Code: Select all

if ( count($attachments) || strlen($msg) || count($hesk_error_buffer) )
My quick-fix solution:

Code: Select all

if ( (!empty($attachments) && count($attachments)) || strlen($msg) || count($hesk_error_buffer) )
Thanks :wink:
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Re: Uncaught TypeError: count()

Post by Klemen »

Thanks for reporting it - the fix will be included in the next release.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply