function _drush_search_index

8.0.x search.drush.inc _drush_search_index()
6.x search.drush.inc _drush_search_index()
7.x search.drush.inc _drush_search_index()
5.x search.drush.inc _drush_search_index()
master search.drush.inc _drush_search_index()
2 string references to '_drush_search_index'

File

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

Code

function _drush_search_index() {
  list($remaining, ) = _drush_search_status();
  register_shutdown_function('search_update_totals');
  $failures = 0;
  while ($remaining > 0) {
    drush_log(dt('Remaining items to be indexed: ' . $remaining), 'ok');
    // Use drush_invoke_process() to start subshell. Avoids out of memory issue.
    $eval = "register_shutdown_function('search_update_totals');";
    if (drush_drupal_major_version() >= 7) {
      // If needed, prod module_implements() to recognize our
      // hook_node_update_index() implementations.
      $implementations = module_implements('node_update_index');
      if (!in_array('system', $implementations)) {
        // Note that this resets module_implements cache.
        module_implements('node_update_index', FALSE, TRUE);
      }

      foreach (variable_get('search_active_modules', array('node', 'user')) as $module) {
        $eval .= " module_invoke('$module', 'update_index');";
      }
    }
    else {
      // If needed, prod module_implements() to recognize our hook_nodeapi()
      // implementations.
      $implementations = module_implements('nodeapi');
      if (!in_array('system', $implementations)) {
        // Note that this resets module_implements cache.
        module_implements('nodeapi', FALSE, TRUE);
      }

      $eval .= " module_invoke_all('update_index');";
    }
    drush_invoke_process('@self', 'php-eval', array($eval));
    $previous_remaining = $remaining;
    list($remaining, ) = _drush_search_status();
    // Make sure we're actually making progress.
    if ($remaining == $previous_remaining) {
      $failures++;
      if ($failures == 3) {
        drush_log(dt('Indexing stalled with @number items remaining.', array(
          '@number' => $remaining,
        )), 'error');
        return;
      }
    }
    // Only count consecutive failures.
    else {
      $failures = 0;
    }
  }
}