protected function domain_swap($table, $column, $domain, $search) {
        global $DB;

        $renames = json_decode(get_config('tool_httpsreplace', 'renames'), true);

        if (isset($renames[$domain])) {
            $replace = preg_replace('|http://'.preg_quote($domain).'|i', 'https://' . $renames[$domain], $search);
        } else {
            $replace = preg_replace('|http://|i', 'https://', $search);
        }
        $DB->set_debug(true);
        $DB->replace_all_text($table, $column, $search, $replace);
        $DB->set_debug(false);
    }