1 search.admin.inc search_reindex_confirm_submit(&$form, &$form_state)

Handler for rebuild confirmation

File

core/modules/search/search.admin.inc, line 55
Admin page callbacks for the Search module.

Code

function search_reindex_confirm_submit(&$form, &$form_state) {
  $config = config('search.settings');
  $limit_per_pass = $config->get('search_cron_limit');

  $index_stats = search_get_stats();

  if ($form_state['values']['index_type'] == 'total') {
    // Mark all content as needing to be re-indexed.
    search_reindex();
  }

  // Determine how many items need to be indexed.
  $number_of_items = $index_stats[$form_state['values']['index_type']];

  // Determine how many passes are needed to reindex.
  $passes_needed = ceil($number_of_items / $limit_per_pass);
  $search_active_modules = config_get('search.settings', 'search_active_modules');

  // Create the batch if needed.
  if ($passes_needed && isset($search_active_modules)) {
    $batch = array(
      'title' => t('Rebuilding search index'),
      'operations' => array(
        array('search_reindex_batch', array($passes_needed, $search_active_modules)),
      ),
      'progress_message' => '',
      'finished' => 'search_reindex_batch_finished',
    );
    batch_set($batch);
  }

  $form_state['redirect'] = 'admin/config/search/settings';
}