Page 1 of 1

action.php on line 65

Posted: Tue May 21, 2024 8:46 pm
by agasar
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

Re: action.php on line 65

Posted: Tue May 21, 2024 11:27 pm
by JNeuhoff
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.

Re: action.php on line 65

Posted: Thu May 23, 2024 10:44 pm
by agasar
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 . '!');
}
}
}

Re: action.php on line 65

Posted: Thu May 23, 2024 10:58 pm
by JNeuhoff
Also do a refresh of your modifications.

Re: action.php on line 65

Posted: Thu May 23, 2024 11:11 pm
by agasar
extensions/Modifications
Do you mean press the Refresh button inside?
How else to refresh.

Re: action.php on line 65

Posted: Fri May 24, 2024 12:25 am
by JNeuhoff
Yes, the Extensions > Modifications > Refresh

Re: action.php on line 65

Posted: Fri May 24, 2024 6:40 pm
by paulfeakins
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/