1 search.module search_reindex_batch_finished($success, $results, $operations)

Batch 'finished' callback for rebuilding the search index.

See also

search_reindex_batch()

File

core/modules/search/search.module, line 1491
Enables site-wide keyword searching.

Code

function search_reindex_batch_finished($success, $results, $operations) {
  if ($success) {
    $config = config('search.settings');
    // Collect some stats
    $remaining = 0;
    $total = 0;
    foreach ($config->get('search_active_modules') as $module) {
      if ($status = module_invoke($module, 'search_status')) {
        $remaining += $status['remaining'];
        $total += $status['total'];
      }
    }
    $count = format_plural($remaining, 'There is 1 item left to index.', 'There are @count items left to index.');
    $percentage = ((int) min(100, 100 * ($total - $remaining) / max(1, $total))) . '%';
    $message = '<p><strong>' . t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) . ' ' . $count . '</strong></p>';
    backdrop_set_message($message);
  }
  else {
    // An error occurred.
    $error_operation = reset($operations);
    backdrop_set_message(
    t('An error occurred while processing @operation with arguments : @args', 
    array(
      '@operation' => $error_operation[0],
      '@args' => print_r($error_operation[0], TRUE),
    )
    )
    );
  }
}