Jump to content

Warning in "Costumer Service" page


CMeier Software

Recommended Posts

Hello,

the following Warning occures when accessing the page "Customer Service":

Quote

Warning on line 1021 in file ***/controllers/admin/AdminCustomerThreadsController.php
[2] count(): Parameter must be an array or an object that implements Countable

I just checked the file and it is the follwing line:

        $mbox = @imap_open('{' . $url . ':' . $port . $conf_str . '}', $user, $password);

        //checks if there is no error when connecting imap server
        $errors = imap_errors();
        if (is_array($errors)) {
            $errors = array_unique($errors);
        }
        $str_errors = '';
        $str_error_delete = '';
		
        if (count($errors) && is_array($errors)) { // Here the Warning occures
            $str_errors = '';
            foreach ($errors as $error) {
                $str_errors .= $error . ', ';
            }
            $str_errors = rtrim(trim($str_errors), ',');
        }

I checked the variables and "imap_errors();" returns false, if there is no error (like in my case). PHP can not run "count()" on a boolean variable. I think the logical operation need to be swaped.

if (count($errors) && is_array($errors)) // wrong

if (is_array($errors) && count($errors)) // correct

I am using Prestashop 1.7.8.1 and PHP 7.3, cache is deactivated and debug mode enabled.

Regards, Chris

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...