OpenCart 3.0.3.9 Fix: Resolving 'Passing null to parameter #3 ($subject)' Error

OpenCart 3.0.3.9 error message related to preg_replace and null subject
OpenCart 3.0.3.9 error message related to preg_replace and null subject

OpenCart store owners on version 3.0.3.9 often encounter a specific PHP deprecation error related to extensions, particularly quick checkout modules. This insight article, drawing directly from community discussions on the OpenCart forum, details the common causes and provides clear, actionable steps to resolve the "Passing null to parameter #3 ($subject) of type array|string is deprecated in /storage/modification/system/engine/action.php on line 65" error.

Understanding the OpenCart 3.0.3.9 PHP Deprecation Error

The error message itself provides crucial clues:

PHP Unknown: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /storage/modification/system/engine/action.php on line 65

This message indicates that a preg_replace() function call is receiving null as its $subject parameter, where it expects a string or an array. This is a PHP 8.x deprecation warning, meaning while it might not halt execution, it signals a potential issue that could become a fatal error in future PHP versions. The file path, /storage/modification/system/engine/action.php, points directly to an OCMod/VQMod modification that is altering the core action.php file.

Common Triggers for This Error

As highlighted by forum users like s3eed and trickyzxr, this error frequently arises from:

  • Quick Checkout Extensions: Many one-page or quick checkout modules modify core OpenCart files and events. Issues can occur if they are poorly coded, conflict with other extensions, or are not fully uninstalled, leaving behind problematic event triggers.
  • Leftover Modifications: Even after uninstalling an extension, its associated OCMod/VQMod XML files or database entries (especially for events) might remain active, leading to conflicts.
  • Conflicting Events: OpenCart's Event system allows extensions to hook into core processes. If an event listener expects certain data that isn't provided (e.g., a `null` string), this error can occur.

Step-by-Step Solution: Disabling Problematic OpenCart Events

The most effective solution, as demonstrated in the forum discussion, involves identifying and disabling the specific OpenCart Events responsible for triggering this error.

General Approach: Identifying and Disabling Events

Forum user s3eed initially solved the problem by disabling "event quick checkout" after uninstalling a one-page checkout extension. This suggests a direct conflict with an active event.

Detailed Fix by trickyzxr

trickyzxr provided a more precise breakdown, identifying two distinct scenarios and their respective event culprits:

Scenario 1: Error on Checkout Page (index.php?route=checkout/checkout)

If the error appears when accessing the checkout page, the likely cause is an event related to PayPal Express Checkout or similar payment/checkout integrations.

Solution: Disable the extension_pp_express_checkout_js event.

Instructions:

  1. Log in to your OpenCart admin panel.
  2. Navigate to System > Design > Events.
  3. Locate the event named extension_pp_express_checkout_js.
  4. Click the Disable button next to it.
  5. Clear your OpenCart modifications cache by going to Extensions > Modifications and clicking the Refresh button.

Scenario 2: Error on Modification Page (index.php?route=marketplace/modification)

If the error occurs when accessing the Modifications page in the admin, it points to an issue with a VQMod integration module or a problematic modification trying to process its data.

Solution: Disable the module_integrated_vqmod event.

Instructions:

  1. Log in to your OpenCart admin panel.
  2. Navigate to System > Design > Events.
  3. Locate the event named module_integrated_vqmod.
  4. Click the Disable button next to it.
  5. Clear your OpenCart modifications cache by going to Extensions > Modifications and clicking the Refresh button.

Preventative Measures and Best Practices

  • Thorough Uninstallation: Always ensure extensions are fully uninstalled, including removing their OCMod/VQMod files and disabling associated events.
  • Test on Dev Environment: Before deploying any new extension or making significant changes, test them on a staging or development server with the same PHP version as your production environment.
  • PHP Version Compatibility: Ensure all installed extensions are compatible with your server's PHP version (especially PHP 8.x, which introduced many deprecations).
  • Regular Cache Clearing: After any extension installation, uninstallation, or modification, always clear your OpenCart modifications cache.

By following these steps, OpenCart users can effectively resolve the "Passing null to parameter #3 ($subject) is deprecated" error, ensuring a stable and error-free operation of their e-commerce store.

Start with the tools

Explore migration tools

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

Explore migration tools