function drush_sitealias_get_record

8.0.x drush_sitealias_get_record($alias, $alias_context = NULL)
6.x drush_sitealias_get_record($alias, $alias_context = NULL)
7.x drush_sitealias_get_record($alias, $alias_context = NULL)
3.x drush_sitealias_get_record($alias)
4.x drush_sitealias_get_record($alias)
5.x drush_sitealias_get_record($alias, $alias_context = NULL)
master drush_sitealias_get_record($alias, $alias_context = NULL)

Get a site alias record given an alias name or site specification.

If it is the name of a site alias, return the alias record from the site aliases array.

If it is the name of a folder in the 'sites' folder, construct an alias record from values stored in settings.php.

If it is a site specification, construct an alias record from the values in the specification.

Site specifications come in several forms:

  • /path/to/drupal#sitename
  • user@server/path/to/drupal#sitename
  • user@server/path/to/drupal (sitename == server)
  • user@server#sitename (only if $option['r'] set in some drushrc file on server)
  • #sitename (only if $option['r'] already set, and 'sitename' is a folder in $option['r']/sites)
  • sitename (only if $option['r'] already set, and 'sitename' is a folder in $option['r']/sites)

Note that in the case of the first four forms, it is also possible to add additional site variable to the specification using uri query syntax. For example:



alias: An alias name or site specification

Return value

array An alias record, or empty if none found.

27 calls to drush_sitealias_get_record()
drush_backend_invoke_concurrent in includes/
Execute a new local or remote command in a new process.
drush_backend_output in includes/
Print the json-encoded output of this command, including the encoded log records, context information, etc.
drush_browse in commands/core/
Command callback.
drush_core_execute in commands/core/
Command callback. Execute specified shell code. Often used by shell aliases that start with !.
drush_core_pre_site_install in commands/core/
Perform setup tasks for installation.

... See full list


includes/, line 215
The site alias API.


function drush_sitealias_get_record($alias, $alias_context = NULL) {
  // Check to see if the alias contains commas.  If it does, then
  // we will go ahead and make a site list record
  $alias_record = array();
  if (strpos($alias, ',') !== false) {
    // TODO:  If the site list contains any site lists, or site
    // search paths, then we should expand those and merge them
    // into this list longhand.
    $alias_record['site-list'] = explode(',', $alias);
  else {
    $alias_record = _drush_sitealias_get_record($alias, $alias_context);
  if (!empty($alias_record)) {
    if (array_key_exists('#name', $alias_record)) {
      if ($alias_record['#name'] == 'self') {
        $path = drush_sitealias_local_site_path($alias_record);
        if ($path) {
          $cached_alias_record = drush_sitealias_lookup_alias_by_path($path);
          $alias_record = array_merge($alias_record, $cached_alias_record);
    else {
      $alias_record['#name'] = drush_sitealias_uri_to_site_dir($alias);
  return $alias_record;