PrestaShop 1.6.x全新安装后多端报错问题求助
Hey there, these errors you're hitting are almost definitely tied to PrestaShop 1.6.x not playing nice with modern PHP versions (7.2+). Let's break down each issue and fix them one by one:
Admin Panel Errors
1. count(): Parameter must be an array or an object that implements Countable (AdminController.php line 551)
PHP 7.2+ tightened up rules for the count() function—it only accepts countable arrays or objects now. The line in question is probably trying to count a variable that might be null or a non-countable type.
Fix:
Open C:\xampp\htdocs\Shop\classes\controller\AdminController.php and tweak line 551 to add a safety check:
// Replace the original count() call with this: if (is_countable($this->fields_value) ? count($this->fields_value) : 0) { // Keep the existing code inside this block }
For broader compatibility with older PHP versions, you can also cast the variable to an array:
if (count((array)$this->fields_value)) { // Keep the existing code inside this block }
2. Function create_function() is deprecated (Module.php line 1554)
create_function() got phased out in PHP 7.2 because it's insecure and inefficient. We'll swap it out for a modern anonymous function instead.
Fix:
Open C:\xampp\htdocs\Shop\classes\module\Module.php and find line 1554. The original code will look something like this:
$custom_function = create_function('$matches', 'return strtoupper($matches[1]);');
Replace it with an anonymous function (adjust the body to match what your original code was doing):
$custom_function = function($matches) { return strtoupper($matches[1]); };
3. Warning at line 56 (partial path provided)
Since the full path is missing, this is likely another PHP 7.2+ compatibility hiccup. Common causes include:
- Uninitialized variables (PHP now warns about these more strictly)
- Deprecated functions like
each()
Fix:
- Turn on full error reporting temporarily to see the exact warning message—add this to your
config/config.inc.php:error_reporting(E_ALL); ini_set('display_errors', 1); - Once you have the full message:
- If it's an uninitialized variable, assign a default value (e.g.,
$my_var = [];before using it) - If it's a deprecated function, swap it for a modern alternative (like replacing
each()with aforeachloop)
- If it's an uninitialized variable, assign a default value (e.g.,
Frontend Error
Since you didn't share the full details, this is almost certainly another PHP compatibility issue. Follow the same steps as the third admin error: enable full error reporting to get the exact message, then patch it using the same compatibility fixes outlined above.
Quick Alternative
If you don't want to manually patch files, you can:
- Downgrade your PHP version to 7.1 (the highest version officially supported by PrestaShop 1.6.x)
- Look for community-maintained PHP 7.2+ compatibility patches for PrestaShop 1.6 (always test patches on a staging site first!)
内容的提问来源于stack exchange,提问作者Car Paradise

