src/tad/WPBrowser/Module/Support/DbDump.php
public function replaceSiteDomainInSqlString($sql, $debug = false)
    {
        $optionsTable = $this->tablePrefix . 'options';

        $matches = [];
        preg_match("/INSERT\\s+INTO\\s+`{$optionsTable}`.*'home'\\s*,\\s*'(.*)',/uiU", $sql, $matches);

        if (empty($matches) || empty($matches[1])) {
            if ($debug) {
                codecept_debug('Dump file does not contain an `options` table INSERT instruction, not replacing');
            }

            return $sql;
        }

        $dumpSiteUrl = $matches[1];

        if (empty($dumpSiteUrl)) {
            if ($debug) {
                codecept_debug('Dump file does not contain dump of `home` option, not replacing.');
            }

            return $sql;
        }

        $thisSiteUrl = $this->url;

        if ($dumpSiteUrl === $thisSiteUrl) {
            if ($debug) {
                codecept_debug('Dump file domain not replaced as identical to the one specified in the configuration.');
            }

            return $sql;
        }

        $sql = str_replace($dumpSiteUrl, $thisSiteUrl, $sql);

        codecept_debug('Dump file domain [' . $dumpSiteUrl . '] replaced with [' . $thisSiteUrl . ']');

        return $sql;
    }
public function replaceSiteDomainInSqlString($sql, $debug = false)
    {
        $optionsTable = $this->tablePrefix . 'options';

        $matches = [];
        preg_match("/INSERT\\s+INTO\\s+`{$optionsTable}`.*'home'\\s*,\\s*'(.*)',/uiU", $sql, $matches);

        if (empty($matches) || empty($matches[1])) {
            if ($debug) {
                codecept_debug('Dump file does not contain an `options` table INSERT instruction, not replacing');
            }

            return $sql;
        }

        $dumpSiteUrl = $matches[1];

        if (empty($dumpSiteUrl)) {
            if ($debug) {
                codecept_debug('Dump file does not contain dump of `home` option, not replacing.');
            }

            return $sql;
        }

        $thisSiteUrl = $this->url;

        if ($dumpSiteUrl === $thisSiteUrl) {
            if ($debug) {
                codecept_debug('Dump file domain not replaced as identical to the one specified in the configuration.');
            }

            return $sql;
        }

        $sql = str_replace($dumpSiteUrl, $thisSiteUrl, $sql);

        codecept_debug('Dump file domain [' . $dumpSiteUrl . '] replaced with [' . $thisSiteUrl . ']');

        return $sql;
    }
public function replaceSiteDomainInSqlString ( $ sql , $ debug = false ) { $ optionsTable = $ this -> tablePrefix . 'options' ; $ matches = [ ] ; preg_match ( "/INSERT\\s+INTO\\s+`{$optionsTable}`.*'home'\\s*,\\s*'(.*)',/uiU" , $ sql , $ matches ) ; if ( empty ( $ matches ) || empty ( $ matches [ 1 ] ) ) { if ( $ debug ) { codecept_debug ( 'Dump file does not contain an `options` table INSERT instruction, not replacing' ) ; } return $ sql ; } $ dumpSiteUrl = $ matches [ 1 ] ; if ( empty ( $ dumpSiteUrl ) ) { if ( $ debug ) { codecept_debug ( 'Dump file does not contain dump of `home` option, not replacing.' ) ; } return $ sql ; } $ thisSiteUrl = $ this -> url ; if ( $ dumpSiteUrl === $ thisSiteUrl ) { if ( $ debug ) { codecept_debug ( 'Dump file domain not replaced as identical to the one specified in the configuration.' ) ; } return $ sql ; } $ sql = str_replace ( $ dumpSiteUrl , $ thisSiteUrl , $ sql ) ; codecept_debug ( 'Dump file domain [' . $ dumpSiteUrl . '] replaced with [' . $ thisSiteUrl . ']' ) ; return $ sql ; }
Replaces the WordPress domains in a SQL dump string.

@param string $sql   The input SQL dump string.
@param bool   $debug Whether a debug message should be printed or not.

@return string The modified SQL string.
Replaces the WordPress domains in a SQL dump string .