Ana22 Posted September 7, 2020 Share Posted September 7, 2020 (edited) Hello friends, I have the following problem, when I see the articles that I have saved as favorites I see the following message: Warning: sizeof(): Parameter must be an array or an object that implements Countable in /var/www/ blockwishlist/managewishlist.php on line 102 If I can see the products but that message appears, I hope you can help me, thank you. Edited September 7, 2020 by Ana22 (see edit history) Link to comment Share on other sites More sharing options...
Daresh Posted September 8, 2020 Share Posted September 8, 2020 Your PHP version may be too high for your prestashop version. Link to comment Share on other sites More sharing options...
Ana22 Posted September 8, 2020 Author Share Posted September 8, 2020 Hi @Daresh I am using PHP 7.2 and prestashop 1.7.6.5 do you think it is the php problem? Link to comment Share on other sites More sharing options...
Daresh Posted September 9, 2020 Share Posted September 9, 2020 Or maybe the blockwishlist module is not up to date with that PHP version. Link to comment Share on other sites More sharing options...
nawres Posted February 3, 2022 Share Posted February 3, 2022 (edited) Same error with prestashop 1.7.8.2 and php version 7.3 have you found solution please ? Edited February 3, 2022 by nawres (see edit history) Link to comment Share on other sites More sharing options...
Luis C Posted February 3, 2022 Share Posted February 3, 2022 On 9/7/2020 at 7:56 PM, Ana22 said: Hello friends, I have the following problem, when I see the articles that I have saved as favorites I see the following message: Warning: sizeof(): Parameter must be an array or an object that implements Countable in /var/www/ blockwishlist/managewishlist.php on line 102 If I can see the products but that message appears, I hope you can help me, thank you. Starting PHP 7.2, sizeof() ( or count() ) can only count arrays or countable objects, not being able to count, for example, strings, true or false booleans, empty or null variables. Please check line 102 and below in your managewishlist.php file and trace the object or variable it's trying to reach. If it's not a countable element it will return an error. You could either rollback your server's PHP version, or adapt the code. Link to comment Share on other sites More sharing options...
janoo Posted August 22, 2022 Share Posted August 22, 2022 (edited) On 9/7/2020 at 7:56 PM, Ana22 said: Hello friends, I have the following problem, when I see the articles that I have saved as favorites I see the following message: Warning: sizeof(): Parameter must be an array or an object that implements Countable in /var/www/ blockwishlist/managewishlist.php on line 102 If I can see the products but that message appears, I hope you can help me, thank you. I hope PS authors already fixed this long time ago. But for those who experiencing similar error message..SOLUTION 1: on: https://github.com/PrestaShop/PrestaShop/pull/9358/files is solution how to adapt old code for new PHP on many pages, just you have to understand principle (do not copy/paste automatically!): OLD CODE: if (isset($this->_list['addons']) && count($this->_list['addons'])) { NEW CODE: if ($this->isCountableAndNotEmpty($this->_list, 'addons')) { Plus add new function into same file, or implement generally through override something: /** * Check if key is present in array, is countable and has data. * * @param array $array Array * @param string $key Key * * @return boolean */ protected function isCountableAndNotEmpty(array $array, $key) { return isset($array[$key]) && ( $array[$key] instanceof Countable || is_array($array[$key]) ) && count($array[$key]); } SOLUTION 2: I´ve found couple handy shorter solutions like: if (is_array($children) && sizeof($children) <= 0) { or: if ( (is_array($children) || $children instanceof \Countable) && sizeof($children) > 0) { but still pay atention - you have to understand principle (do not copy/paste automatically!) Edited August 22, 2022 by janoo new ideas (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now