Post by septero » Thu Apr 27, 2023 12:11 am

Hi,

In OpenCart's error log I get following error:

Code: Select all

PHP Unknown:  preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in xxx/storage/modification/system/engine/action.php on line 65
OpenCart's version: 3.0.3.8 Maintenance Branch from GitHub - Clean installation, I didnt made any changes
PHP version: 8.1.16

How to fix above error?
OpenCart's Maintenance Branch fixed all errors with PHP 8.1 but this one remains.

With best regards
Lukas
Last edited by septero on Thu Apr 27, 2023 2:21 am, edited 1 time in total.

Newbie

Posts

Joined
Wed Feb 08, 2023 10:33 pm

Post by septero » Thu Apr 27, 2023 2:20 am

Similar error is shown while trying to do a backup:

Code: Select all

PHP Unknown:  str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /xxx/model/tool/backup.php on line 47

Newbie

Posts

Joined
Wed Feb 08, 2023 10:33 pm

Post by JNeuhoff » Thu Apr 27, 2023 4:44 am

If you are serious about getting some help here, then you have to provide some more details, since nobody else has this issue.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by ADD Creative » Thu Apr 27, 2023 7:48 am

septero wrote:
Thu Apr 27, 2023 2:20 am
Similar error is shown while trying to do a backup:

Code: Select all

PHP Unknown:  str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /xxx/model/tool/backup.php on line 47
This seems to be caused by null values in the database. I found some in the oc_googleshopping_product table used by the built in Google Shopping Extension.

Need to add a check for $value being null before line 47 of admin/model/tool/backup.php.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by straightlight » Thu Apr 27, 2023 9:16 am

septero wrote:
Thu Apr 27, 2023 12:11 am
Hi,

In OpenCart's error log I get following error:

Code: Select all

PHP Unknown:  preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in xxx/storage/modification/system/engine/action.php on line 65
OpenCart's version: 3.0.3.8 Maintenance Branch from GitHub - Clean installation, I didnt made any changes
PHP version: 8.1.16

How to fix above error?
OpenCart's Maintenance Branch fixed all errors with PHP 8.1 but this one remains.

With best regards
Lukas
Which route do you see this error message?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by JNeuhoff » Thu Apr 27, 2023 8:29 pm

ADD Creative wrote:
Thu Apr 27, 2023 7:48 am
This seems to be caused by null values in the database. I found some in the oc_googleshopping_product table used by the built in Google Shopping Extension.

Need to add a check for $value being null before line 47 of admin/model/tool/backup.php.
I have now applied a bugfix for it to the 3.0.x.x_Maintenance branch.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by septero » Thu Apr 27, 2023 10:38 pm

Thanks for the fix. Now backup is working without any issues :)

Regarding the error message for action.php I am having it on my main site and on product site. OpenCart is installed on localhost.

There was a topic about this error but without any clear solution: viewtopic.php?t=230071

Below are sample OpenCart shop on which this error is visible:
https://www.pinvoordeel.nl/index.php?route=common/home

I hope that will help fix the error.

Newbie

Posts

Joined
Wed Feb 08, 2023 10:33 pm

Post by ADD Creative » Fri Apr 28, 2023 4:40 am

Check you don't have any missing files. That error could be caused by a missing controller file that is being call by a route, pre_action or an event.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by JNeuhoff » Fri Apr 28, 2023 5:19 am

One of your error messages is about line 103 in catalog/controller/startup/startup.php . There is no code on that line, hence your startup.php appears to be corrupted. All your other error messages are about modified core files, so it looks like these are caused by some of you OCmod-based modifications.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by septero » Fri Apr 28, 2023 1:42 pm

Thanks for the answers. I have further investigated the error.

Code: Select all

PHP Unknown:  preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in xxx/storage/modification/system/engine/action.php on line 65
I have checked server error logs and it seems that OpenCart's googleshopping extension is causing the problem. Error occurs each time where there is some fetching from feed/gshopping ("GET /index.php?route=extension/feed/gshopping HTTP/1.1" 404 123636 "-" "google-xrawler").

Each day I have about two action.php errors which occurs exactly in the same time when gshopping feed is being checked. In previous post there was a notice that this can be caused by some null values in database oc_googleshopping_product table used by the built in Google Shopping Extension.

I have uninstalled Google Shopping extension and I hope it will fix the error. For those which will use gshopping maybe there can be a check for $value being null before line 65 in action.php?

Newbie

Posts

Joined
Wed Feb 08, 2023 10:33 pm

Post by ADD Creative » Fri Apr 28, 2023 6:10 pm

You are right. It's obvious to me now. /index.php?route=extension/feed/gshopping produces a 404 because the extension/feed/gshopping controller file doesn't exist. So even /index.php?route=anything will cause the error in system/engine/action.php.

The Action class constructor only sets $this->route if the file exists. If they is no controller file, $this->route will still be null. So it does need some sort of check. No point trying to include a file that doesn't exist.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by septero » Thu May 04, 2023 4:27 pm

ADD Creative wrote:
Fri Apr 28, 2023 6:10 pm
You are right. It's obvious to me now. /index.php?route=extension/feed/gshopping produces a 404 because the extension/feed/gshopping controller file doesn't exist. So even /index.php?route=anything will cause the error in system/engine/action.php.

The Action class constructor only sets $this->route if the file exists. If they is no controller file, $this->route will still be null. So it does need some sort of check. No point trying to include a file that doesn't exist.
Thank you for clarification. Is there a possibility to fix the error in system/engine/action.php so it will check if there is no controller file ($this->route is null)?

Newbie

Posts

Joined
Wed Feb 08, 2023 10:33 pm

Post by ADD Creative » Thu May 04, 2023 4:41 pm

The simplest way to get stop the error is to change.

Code: Select all

private $route;
To.

Code: Select all

private $route = '';
Maybe a more correct way would be to add a check for the route being null in the execute method.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by riwalker » Thu Aug 10, 2023 9:48 pm

I have the same error.
using 3.0.3.8 maintenance release with PHP 8.1.x
PHP Unknown: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/.../storage/modification/system/engine/action.php on line 65

tried adding to line 15 : private $route = ''; # this doesn't work
The issue arises when i try and press delete on an extension that may have already been deleted (Extensions > Installer > delete an extension)

hence line 65 fails: $class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', $this->route);

**** update
this fix does work, i had forgotten to clear modifications, then refresh. once refreshed, the fix works:
line 15 : private $route = '';

Newbie

Posts

Joined
Thu Nov 23, 2017 9:46 pm

Post by integraa » Thu Mar 14, 2024 11:00 pm

Hey,
I came to the same error but my OC is 3.0.3.9, 3 week old opencart.com download.

Code: Select all

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

Code: Select all

private $route;
Even if this is a newer release, should I change it to solution mentioned above?
I haven't really found the cause of this error, since I do not have the google marketplace enabled...


Thanks for your opinion!

Newbie

Posts

Joined
Sat Aug 20, 2016 2:16 pm

Post by ADD Creative » Fri Mar 15, 2024 1:17 am

The fix for the next version is https://github.com/opencart/opencart/pull/13019, but either will work.

To track down the actual cause of the error I would look at timestamp of the error in the error log and look at your web access logs for that exact time.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by integraa » Fri Mar 15, 2024 4:42 pm

Hey,
thanks for advise ADD creative, I have found my cause of error.
Now I have another question, error comes from paypal express, that I do not have on my new site, but I had on my old one. Since I imported some stuff when going from oc 2 to oc 3, maybe that came along. I can not find where in database that leftover is or is just something else?
Any idea would be appreciated!

OC error log:

Code: Select all

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


access log

Code: Select all

 "POST /index.php?route=extension/payment/pp_express/ipn HTTP/1.1" 404 194100 "-" "PayPal IPN ( https://www.paypal.com/ipn )"

Newbie

Posts

Joined
Sat Aug 20, 2016 2:16 pm

Post by ADD Creative » Fri Mar 15, 2024 6:19 pm

You won't have a catalog/controller/extension/payment/pp_express.php file anymore as PayPal Express isn't included in 3.0.3.9.

You will probably need to change your PayPal IPN settings if you are not using PayPal Express anymore.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by integraa » Fri Mar 15, 2024 6:48 pm

Hey,
ADD Creative thank you for all the info, that did the trick!

Best, Miha

Newbie

Posts

Joined
Sat Aug 20, 2016 2:16 pm
Who is online

Users browsing this forum: No registered users and 15 guests