You are here

function search_by_page_reset_blank in Search by Page 7

Same name and namespace in other branches
  1. 8 search_by_page.module \search_by_page_reset_blank()
  2. 6 search_by_page.module \search_by_page_reset_blank()

Resets pages that have no words in search index, so they'll be reindexed.

Page callback for the 'admin/config/search/search_by_page/resetblank' path.

1 string reference to 'search_by_page_reset_blank'
search_by_page_menu in ./search_by_page.module
Implements hook_menu().

File

./search_by_page.module, line 1592
Main module file for Drupal module Search by Page.

Code

function search_by_page_reset_blank() {
  $sel = db_select('search_index', 'si')
    ->fields('si')
    ->condition('type', 'search_by_page');
  $query = db_select('sbp_path', 'sp');
  $query
    ->addField('sp', 'pid');
  $query
    ->leftJoin($sel, 'sisp', 'sisp.sid = sp.pid');
  $query
    ->isNull('sisp.word');
  $result = $query
    ->execute()
    ->fetchAll();
  $count = 0;
  foreach ($result as $item) {
    _search_by_page_update_last_time($item->pid);
    $count++;
  }
  drupal_set_message(t('Blank pages have been reset to index at next cron run (%num)', array(
    '%num' => $count,
  )));
  drupal_goto('admin/config/search/search_by_page');
}