Fix Call to undefined function json_decode() Error in PrestaShop After Migration

Fatal error:

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

  1. Create a test.php file in your site’s root:
phpCopierModifier<?php
echo json_decode('{"test":1}') ? 'JSON OK' : 'JSON ERROR';
?>
  1. 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

Your email address will not be published. Required fields are marked *