• erwinbr

    (@erwinbr)


    On creating a clone on another site, the last step offers to update the wp-config.php file of the clone site. However this feature does not (always) work.

    Looking at file xcloner_restore.php, class Xloner_Restore, method update_wp_config(), I see the following regular expressions:
    "/(?<=DB_NAME', ')(.*?)(?='\);)/"
    This fails if that line is written as:
    define( 'DB_NAME', 'wpdb' );
    which in WP is the coding standard. By changing the regular expressions to accept a space, I got it to work:
    "/(?<=DB_NAME', ')(.*?)(?=' \);)/"
    But you might want it make more accepting, something like:
    "/(?<='DB_NAME', '|'DB_NAME',')(.*?)(?=' *\);)/"
    That is, making the spaces optional.

    Full code changes:

    
            $content = preg_replace("/(?<='DB_NAME','|'DB_NAME', ')(.*?)(?=' *\);)/", $remote_mysql_db, $content);
            $content = preg_replace("/(?<='DB_USER','|'DB_USER', ')(.*?)(?=' *\);)/", $remote_mysql_user, $content);
            $content = preg_replace("/(?<='DB_PASSWORD','|'DB_PASSWORD', ')(.*?)(?=' *\);)/", $remote_mysql_pass, $content);
            $content = preg_replace("/(?<='DB_HOST','|'DB_HOST', ')(.*?)(?=' *\);)/", $remote_mysql_host, $content);
    
  • The topic ‘db settings in wp-config not updated’ is closed to new replies.