function _drush_search_status

8.0.x search.drush.inc _drush_search_status()
6.x search.drush.inc _drush_search_status()
7.x search.drush.inc _drush_search_status()
5.x search.drush.inc _drush_search_status()
master search.drush.inc _drush_search_status()
2 calls to _drush_search_status()

File

commands/core/search.drush.inc, line 54

Code

function _drush_search_status() {
  $remaining = 0;
  $total = 0;
  if (drush_drupal_major_version() >= 8) {
    $search_page_repository = \Drupal::service('search.search_page_repository');
    foreach ($search_page_repository->getIndexableSearchPages() as $entity) {
      $status = $entity->getPlugin()->indexStatus();
      $remaining += $status['remaining'];
      $total += $status['total'];
    }
  }
  elseif (drush_drupal_major_version() == 7) {
    foreach (variable_get('search_active_modules', array('node', 'user')) as $module) {
      drush_include_engine('drupal', 'environment');
      $status = drush_module_invoke($module, 'search_status');
      $remaining += $status['remaining'];
      $total += $status['total'];
    }
  }
  else {
    drush_include_engine('drupal', 'environment');
    foreach (drush_module_implements('search') as $module) {
      // Special case. Apachesolr recommends disabling core indexing with
      // search_cron_limit = 0. Need to avoid infinite status loop.
      if ($module == 'node' && variable_get('search_cron_limit', 10) == 0) {
        continue;
      }
      $status = drush_module_invoke($module, 'search', 'status');
      if (isset($status['remaining']) && isset($status['total'])) {
        $remaining += $status['remaining'];
        $total += $status['total'];
      }
    }
  }
  return array($remaining, $total);
}