Post by agasar » Tue May 21, 2024 8:46 pm

Hello

I get errors like the following in opencart system error logs, how do I solve this problem.

I am using “Version 3.0.3.3.9”
PHP Unknown: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/xxxx/ocartdata/storage/modification/system/engine/action.php on line 65

Newbie

Posts

Joined
Thu Apr 04, 2024 11:01 pm

Post by JNeuhoff » Tue May 21, 2024 11:27 pm

Replace line 65 in system/engine/action.php with:

Code: Select all

		$class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', (string)$this->route);
It's already fixed in the upcoming OC 3.0.4.0.

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 agasar » Thu May 23, 2024 10:44 pm

Hello

2024-05-23 0:12:03 - PHP Unknown: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/xxx/ocartdata/storage/modification/system/engine/action.php on line 65

The above errors are still coming up. I changed the code you said and still the error keeps coming.

I am using “Version 3.0.3.3.3.9”

PHP version: 8.2

system/engine/action.php

content is as follows.
<?php
/**
* @package OpenCart
* @author Daniel Kerr
* @copyright Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
* @license https://opensource.org/licenses/GPL-3.0
* @link https://www.opencart.com
*/

/**
* Action class
*/
class Action {
private $id;
private $route;
private $method = 'index';

/**
* Constructor
*
* @param string $route
*/
public function __construct($route) {
$this->id = $route;

$parts = explode('/', preg_replace('/[^a-zA-Z0-9_\/]/', '', (string)$route));

// Break apart the route
while ($parts) {
$file = DIR_APPLICATION . 'controller/' . implode('/', $parts) . '.php';

if (is_file($file)) {
$this->route = implode('/', $parts);

break;
} else {
$this->method = array_pop($parts);
}
}
}

/**
*
*
* @return string
*
*/
public function getId() {
return $this->id;
}

/**
*
*
* @param object $registry
* @param array $args
*/
public function execute($registry, array $args = array()) {
// Stop any magical methods being called
if (substr($this->method, 0, 2) == '__') {
return new \Exception('Error: Calls to magic methods are not allowed!');
}

$file = DIR_APPLICATION . 'controller/' . $this->route . '.php';
$class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', (string)$this->route);

// Initialize the class
if (is_file($file)) {
include_once($file);

$controller = new $class($registry);
} else {
return new \Exception('Error: Could not call ' . $this->route . '/' . $this->method . '!');
}

$reflection = new ReflectionClass($class);

if ($reflection->hasMethod($this->method) && $reflection->getMethod($this->method)->getNumberOfRequiredParameters() <= count($args)) {
return call_user_func_array(array($controller, $this->method), $args);
} else {
return new \Exception('Error: Could not call ' . $this->route . '/' . $this->method . '!');
}
}
}

Newbie

Posts

Joined
Thu Apr 04, 2024 11:01 pm

User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by agasar » Thu May 23, 2024 11:11 pm

extensions/Modifications
Do you mean press the Refresh button inside?
How else to refresh.

Newbie

Posts

Joined
Thu Apr 04, 2024 11:01 pm

User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by paulfeakins » Fri May 24, 2024 6:40 pm

agasar wrote:
Thu May 23, 2024 11:11 pm
How else to refresh.
https://www.antropy.co.uk/blog/how-to-c ... t-3-0-2-0/

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 19 guests