interconnectit/Search-Replace-DB

Unexpected '/'

Closed this issue · 3 comments

Hello. Thank you for your excellent code. I ran into a problem, however, when trying to update a DB. I got the following error:
syntax error, unexpected '\' (T_NS_SEPARATOR), expecting '{'

It seems to happen in various wp_#_options tables and I'm wondering how I can remedy this, or have it skip these tables. I tried using regex to exclude these tables, but it doesn't seem like regex works with the -w switch. Any help would be much appreciated. Thank you.

I was facing the same problem.
The problem is on the object_serializer function.

When we try create classes with namespace the error will be present.
In my case was the class Elementor\Core\Logger\Items\JS.

Something like this should fix the problem.

function object_serializer( $class_name ) {
    
    $prefix = '';

    if (($pos = strrpos($class_name, "\\")) !== false) {
        $namespace = substr($class_name, 0, $pos);
        $class_name = substr($class_name, $pos + 1);
        $prefix = "namespace  {$namespace};";
    }
    
    eval( "{$prefix} class {$class_name} extends \ArrayObject {}" );
}

Plug-in like Elementos are source of trouble for this script, has been discussed several times. Use 3.x or wp-cli :)

For anyone having this problem and stumbling on this thread. It was an error in the code of this project (#356).

It can be fixed by using the latest version of this tool.