PrestaShop

PrestaShop 9.0.3 Upgrade Nightmare: Solving the Back Office Redirection and PayPal Module Error

Debugging PrestaShop code with a magnifying glass, focusing on an error.
Debugging PrestaShop code with a magnifying glass, focusing on an error.

PrestaShop 9.0.3 Upgrade Nightmare: Solving the Back Office Redirection and PayPal Module Error

Upgrading your e-commerce platform should be a seamless step towards enhanced features and security. However, as many PrestaShop merchants know, sometimes updates can introduce unexpected challenges. One such critical issue recently surfaced after an upgrade to PrestaShop 9.0.3, leaving store owners locked out of their Back Office (BO) and facing perplexing module errors. At Migrate My Shop, your PrestaShop Migration Hub, we understand the urgency of these situations and are here to dissect this problem and provide a clear path to resolution.

The Back Office Blackout: A Common Upgrade Pitfall

A user, Mostyma, reported a classic upgrade nightmare: after moving from PrestaShop 9.0 to 9.0.3, their Back Office became completely inaccessible. Instead of the familiar admin login, navigating to the BO URL resulted in an immediate redirection to the front office. This scenario is particularly alarming as it cripples a merchant's ability to manage orders, products, and store settings. Initial troubleshooting steps, such as activating debug mode and clearing the cache, proved futile – a common first reaction that often doesn't address deeper underlying issues.

Diving Deeper: The PayPal Clue and the RecursiveDirectoryIterator Error

Frustrated but persistent, Mostyma took a crucial step: attempting to rename the PayPal module. This action, while seemingly arbitrary, triggered a critical error message that provided the first real clue:

RecursiveDirectoryIterator::__construct(/usr/local/lsws/mt.com/http/current/public/modules/paypal): Failed to open directory: No such file or directory

UnexpectedValueException

in /usr/local/lsws/mt.com/http/current/public/src/PrestaShopBundle/DependencyInjection/Compiler/ModuleControllerRegisterPass.php (line 56)

This error message is highly technical but reveals a lot. It indicates that PrestaShop's core system, specifically during the compilation of modules (managed by Symfony's Dependency Injection component), was attempting to iterate through the PayPal module's directory but couldn't find it. The RecursiveDirectoryIterator is a PHP class used to traverse directory structures. Its failure here suggests a fundamental problem with how PrestaShop was trying to load or register its modules, not necessarily an issue with PayPal itself, but rather with the system's ability to locate and process any module.

The reference to ModuleControllerRegisterPass.php is key. This file is part of PrestaShop's core framework, responsible for discovering and registering controllers provided by modules. If it can't even open a module's directory, it means the entire module registration process is failing, leading to a cascade of problems.

The Missing Piece: Payment Modules Disappearing Act

Further confirming the severity of the issue, Mostyma observed that "plus aucun module de paiement n'est activé ou dispo sur le site" (no payment modules were activated or available on the site). This directly correlates with the RecursiveDirectoryIterator error. If PrestaShop cannot properly scan and register modules, it logically follows that payment modules – which are critical components – would fail to load or appear as available. This is a critical blow to any e-commerce operation, rendering the store unable to process transactions.

The Community Steps In: Diagnosis and the Definitive Solution

Fortunately, the PrestaShop community quickly rallied to provide solutions. Mediacom87 pointed to a relevant GitHub issue (PrestaShop/PrestaShop#40688), indicating that this was a known problem within the PrestaShop ecosystem. Prestashop Addict's question about the specific PrestaShop edition (open source vs. Classic) was a good diagnostic step, though ultimately not the root cause in this instance.

The definitive answer came from yama: the issue was tied to the ps_apiresources module. The solution was to update this module to version 0.4.0. A link to the module's release page on GitHub (https://github.com/PrestaShop/ps_apiresources/releases/tag/v0.4.0) was provided, offering a direct path to resolution.

The ps_apiresources module is crucial for PrestaShop as it handles various API interactions and resource management, often playing a role in how other modules (especially payment and integration modules) communicate with the core system. An outdated or incompatible version of this module after a core upgrade can indeed disrupt the entire module compilation and loading process, leading to the RecursiveDirectoryIterator error and the subsequent Back Office and payment module failures.

Actionable Steps for Merchants: Fixing Your PrestaShop 9.0.3 Back Office

If you find yourself in a similar predicament after upgrading to PrestaShop 9.0.3, here's a step-by-step guide to resolve the issue:

  1. Access Your Server: You'll need FTP/SFTP access or SSH access to your PrestaShop installation files.
  2. Download the Correct Module Version: Go to the official ps_apiresources GitHub releases page (v0.4.0 release) and download the .zip file for version 0.4.0.
  3. Backup (Crucial!): Before making any changes, always create a full backup of your PrestaShop files and database. This is non-negotiable for any development task.
  4. Replace the Module Files:
    • Unzip the downloaded ps_apiresources-0.4.0.zip file.
    • Using your FTP/SFTP client, navigate to your PrestaShop installation's /modules/ directory.
    • Locate the existing ps_apiresources folder.
    • Rename or Delete: Rename the existing ps_apiresources folder (e.g., to ps_apiresources_old) or delete it entirely.
    • Upload New Version: Upload the unzipped ps_apiresources folder (from the 0.4.0 download) into your /modules/ directory.
  5. Clear Cache: After replacing the module, it's vital to clear PrestaShop's cache. If you can't access the BO, you can do this manually by deleting the contents of /var/cache/prod/ and /var/cache/dev/ (but not the folders themselves) via FTP/SFTP, or using the PrestaShop CLI command: php bin/console cache:clear.
  6. Check Back Office Access: Attempt to access your PrestaShop Back Office again. It should now load correctly.
  7. Verify Payment Modules: Once in the BO, navigate to Modules > Module Manager and ensure your payment modules are present and correctly configured. Re-enable any that might have been deactivated.

A magnifying glass hovering over lines of PHP code, highlighting an error message within a PrestaShop module directory.

Preventive Measures and Best Practices for PrestaShop Upgrades

To avoid such critical issues in the future, consider these best practices:

  • Staging Environment: Always perform major PrestaShop upgrades on a staging or development environment first. This allows you to identify and resolve issues without impacting your live store.
  • Module Compatibility: Before upgrading, thoroughly check the compatibility of all your installed modules and themes with the target PrestaShop version. Developers often release updates for new PrestaShop versions.
  • Full Backups: Maintain a robust backup strategy. Regular, automated backups of both your database and files are your safety net.
  • Server Environment: Ensure your server meets the minimum requirements for the new PrestaShop version, including PHP version, memory limits, and extensions.
  • Professional Assistance: For complex upgrades or if you're unsure, consider engaging PrestaShop migration and development experts like Migrate My Shop. We specialize in smooth, error-free transitions and can handle the intricacies of your e-commerce platform.

Conclusion

While PrestaShop 9.0.3 brings valuable improvements, the reported Back Office redirection and module compilation errors highlight the importance of careful planning and execution during upgrades. The quick resolution provided by the community, centered on updating the ps_apiresources module, is a testament to the power of open-source collaboration. By following the steps outlined above and adopting preventive measures, you can safeguard your PrestaShop store against similar disruptions. If you need assistance with your next PrestaShop upgrade or migration, don't hesitate to reach out to the experts at Migrate My Shop for a seamless experience.

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools