When Domain Alias module saves domain alias with wildcards it replaces wildcards with mysql-compatible placeholders, see

domain_alias.admin.inc

function domain_alias_form_submit($form, &$form_state) {
  ...
  $alias['pattern'] = _domain_alias_placeholders_to_sql($alias['pattern']);
}

and domain_alias.module

/**
 * Replace placeholders * and ? with SQL placeholders % and _
 */
function _domain_alias_placeholders_to_sql($subdomain, $reverse = FALSE) {
  $placeholders = array('*' => '%', '?' => '_');
  if ($reverse) {
    return str_replace($placeholders, array_keys($placeholders), $subdomain);
  }
  else {
    return str_replace(array_keys($placeholders), $placeholders, $subdomain);
  }
}

But, when Feature module recreates saved aliases it does not: it puts 'example.com.*' instead of 'example.com.%' and such aliases don't work.

Comments

Sergii’s picture

StatusFileSize
new1 KB

And here's the patch (see attachment).

In domain_alias.feature.inc was a comment describing this behavior:

function domain_alias_features_rebuild($module) {
  // Note that we don't have to use placeholder_sql functions because
  // these records came straight from the db.
}

But that's not correct.
When domain alias prepares feature export it uses internal function that returns alias pattern containing not mysql placeholders, but original string:

domain_alias.feature.inc:

/**
 * Implements hook_features_export_render().
 */
function domain_alias_features_export_render($module_name, $data, $export = NULL) {
   ...
    $list = domain_alias_prepare_export($name);
    $code[] = "  \$domain_aliases['{$name}'] = " . features_var_export($list) .";";
  ...
}

function domain_alias_prepare_export($machine_name) {
  ...
  $list = domain_alias_list($domain_id);
  ...
}

domain_alias.module:

function domain_alias_list($domain_id, $reset = FALSE) {
  ...
      $data['pattern'] = _domain_alias_placeholders_from_sql($data['pattern']);
  ...
}
agentrickard’s picture

Status: Active » Needs review

Nice catch.

agentrickard’s picture

Patch is malformed. Contrib patches should be rolled from the module's root directory.

agentrickard’s picture

Status: Needs review » Fixed
StatusFileSize
new651 bytes
Sergii’s picture

Sorry, this is my very first path :)

agentrickard’s picture

No problem. It worked just fine, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

fix typo