
After migrating a PrestaShop website (1.7.x or higher) to a new server, you might encounter this critical error:
bashCopierModifierFatal error: Uncaught Error: Call to undefined function PrestaShop\PrestaShop\Core\Addon\Theme\json_decode()
Donβt worry β this error is usually caused by a PHP JSON extension not being loaded properly, which is required for PrestaShop to function.
π Why does this happen?
Even if you’re running the correct PHP version (7.2β8.x for PrestaShop), this issue can occur when:
- The JSON extension is not enabled
- PHP configuration wasn’t reloaded after a change
- The migration skipped or disrupted PHP extension loading
β Solutions by Hosting Type
πΉ Case 1: Shared Hosting (OVH, LWS, o2switch, etc.)
Shared hosting doesnβt allow you to restart PHP services directly, but you can force a PHP reload this way:
Step 1 β Change the PHP version in your control panel
- Log into your hosting control panel (e.g., OVH Manager)
- Go to Hosting > Multisite > Modify configuration
- Temporarily switch your PHP version (e.g., from 7.2 to 7.3)
- Save, then switch back to your preferred version
π This forces a PHP reload and reactivates extensions like JSON.
Step 2 β Check the website
Reload your site. The error should now be gone.
πΉ Case 2: Dedicated Server or VPS
You have full control here. Just restart the PHP process.
β For Apache:
bashCopierModifiersudo systemctl restart apache2
β For Nginx + PHP-FPM:
bashCopierModifiersudo systemctl restart php7.2-fpm
Adjust
php7.2-fpm
to match your PHP version (e.g.,php8.1-fpm
).
π Check if JSON is enabled:
bashCopierModifierphp -m | grep json
You should see json
listed in the output.
π§© Bonus: Test json_decode Function
- Create a
test.php
file in your siteβs root:
phpCopierModifier<?php
echo json_decode('{"test":1}') ? 'JSON OK' : 'JSON ERROR';
?>
- Open
https://your-site.com/test.php
in a browser.
β Conclusion
This error might surprise you after a migration, but it’s usually a quick fix. Forcing PHP to reload solves it in most cases, especially on shared hosting.
Leave a Reply