function drush_sitealias_lookup_alias_by_path

8.0.x drush_sitealias_lookup_alias_by_path($path, $allow_best_match = FALSE)
6.x drush_sitealias_lookup_alias_by_path($path)
7.x drush_sitealias_lookup_alias_by_path($path)
master drush_sitealias_lookup_alias_by_path($path, $allow_best_match = FALSE)

Look for a defined alias that points to the specified site directory. The cache is tested first; if nothing is cached, then an exhaustive search is done for the specified site. If the exhaustive search returns a match, then it is cached.


$path: /path/to/drupal/sites/default

Return value

An alias record for the provided path

1 call to drush_sitealias_lookup_alias_by_path()
drush_sitealias_get_record in includes/
Get a site alias record given an alias name or site specification.


includes/, line 2126
The site alias API.


function drush_sitealias_lookup_alias_by_path($path) {
  $result = drush_sitealias_quick_lookup_cached_alias_by_path($path);
  if (empty($result)) {
    $aliases = _drush_sitealias_find_and_load_all_aliases();
    foreach ($aliases as $name => $alias_record) {
      if (!isset($alias_record['remote-host']) && isset($alias_record['root']) && isset($alias_record['uri']) && isset($alias_record['#name']) && isset($alias_record['#file'])) {
        if ($path == drush_sitealias_local_site_path($alias_record)) {
          $result = $alias_record;
          return $result;
  return $result;