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