Issue #1496510 by swentel, jvns, cosmicdreams, marcingy, alexpott, heyrocker, sun: Convert search settings to configuration system.

8.0.x
webchick 2012-07-27 22:18:02 -05:00
parent 0e4742c536
commit 3642d7f58e
16 changed files with 113 additions and 80 deletions

View File

@ -2621,7 +2621,7 @@ function node_page_view(Node $node) {
* Implements hook_update_index(). * Implements hook_update_index().
*/ */
function node_update_index() { function node_update_index() {
$limit = (int)variable_get('search_cron_limit', 100); $limit = (int) config('search.settings')->get('index.cron_limit');
$result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit, array(), array('target' => 'slave')); $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit, array(), array('target' => 'slave'));
$nids = $result->fetchCol(); $nids = $result->fetchCol();

View File

@ -0,0 +1,22 @@
active_modules:
- node
- user
and_or_limit: '7'
default_module: node
index:
cron_limit: '100'
overlap_cjk: '1'
minimum_word_size: '3'
tag_weights:
h1: '25'
h2: '18'
h3: '15'
h4: '14'
h5: '9'
h6: '6'
u: '3'
b: '3'
i: '3'
strong: '3'
em: '3'
a: '10'

View File

@ -203,7 +203,7 @@ class SearchQuery extends SelectExtender {
// Classify tokens. // Classify tokens.
$or = FALSE; $or = FALSE;
$warning = ''; $warning = '';
$limit_combinations = variable_get('search_and_or_limit', 7); $limit_combinations = config('search.settings')->get('and_or_limit');
// The first search expression does not count as AND. // The first search expression does not count as AND.
$and_count = -1; $and_count = -1;
$or_count = 0; $or_count = 0;
@ -326,7 +326,7 @@ class SearchQuery extends SelectExtender {
$split = explode(' ', $word); $split = explode(' ', $word);
foreach ($split as $s) { foreach ($split as $s) {
$num = is_numeric($s); $num = is_numeric($s);
if ($num || drupal_strlen($s) >= variable_get('minimum_word_size', 3)) { if ($num || drupal_strlen($s) >= config('search.settings')->get('index.minimum_word_size')) {
if (!isset($this->words[$s])) { if (!isset($this->words[$s])) {
$this->words[$s] = $s; $this->words[$s] = $s;
$num_new_scores++; $num_new_scores++;
@ -352,11 +352,11 @@ class SearchQuery extends SelectExtender {
$this->parseSearchExpression(); $this->parseSearchExpression();
if (count($this->words) == 0) { if (count($this->words) == 0) {
form_set_error('keys', format_plural(variable_get('minimum_word_size', 3), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.')); form_set_error('keys', format_plural(config('search.settings')->get('index.minimum_word_size'), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
return FALSE; return FALSE;
} }
if ($this->expressionsIgnored) { if ($this->expressionsIgnored) {
drupal_set_message(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => variable_get('search_and_or_limit', 7))), 'warning'); drupal_set_message(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => config('search.settings')->get('and_or_limit'))), 'warning');
} }
$this->executedFirstPass = TRUE; $this->executedFirstPass = TRUE;

View File

@ -112,9 +112,9 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
$info = $module_info[$module]; $info = $module_info[$module];
$edit = array(); $edit = array();
foreach ($modules as $other) { foreach ($modules as $other) {
$edit['search_active_modules[' . $other . ']'] = (($other == $module) ? $module : FALSE); $edit['active_modules[' . $other . ']'] = (($other == $module) ? $module : FALSE);
} }
$edit['search_default_module'] = $module; $edit['default_module'] = $module;
$this->drupalPost('admin/config/search/settings', $edit, t('Save configuration')); $this->drupalPost('admin/config/search/settings', $edit, t('Save configuration'));
// Run a search from the correct search URL. // Run a search from the correct search URL.
@ -151,9 +151,9 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
// page or run search, all modules should be shown. // page or run search, all modules should be shown.
$edit = array(); $edit = array();
foreach ($modules as $module) { foreach ($modules as $module) {
$edit['search_active_modules[' . $module . ']'] = $module; $edit['active_modules[' . $module . ']'] = $module;
} }
$edit['search_default_module'] = 'node'; $edit['default_module'] = 'node';
$this->drupalPost('admin/config/search/settings', $edit, t('Save configuration')); $this->drupalPost('admin/config/search/settings', $edit, t('Save configuration'));

View File

@ -42,8 +42,7 @@ class SearchEmbedFormTest extends SearchTestBase {
search_update_totals(); search_update_totals();
// Set up a dummy initial count of times the form has been submitted. // Set up a dummy initial count of times the form has been submitted.
$this->submit_count = 12; $this->submit_count = config('search_embedded_form.settings')->get('submitted');
variable_set('search_embedded_form_submitted', $this->submit_count);
$this->refreshVariables(); $this->refreshVariables();
} }
@ -56,7 +55,7 @@ class SearchEmbedFormTest extends SearchTestBase {
array('name' => 'John'), array('name' => 'John'),
t('Send away')); t('Send away'));
$this->assertText(t('Test form was submitted'), 'Form message appears'); $this->assertText(t('Test form was submitted'), 'Form message appears');
$count = variable_get('search_embedded_form_submitted', 0); $count = config('search_embedded_form.settings')->get('submitted');
$this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct'); $this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct');
$this->submit_count = $count; $this->submit_count = $count;
@ -67,7 +66,7 @@ class SearchEmbedFormTest extends SearchTestBase {
array('name' => 'John'), array('name' => 'John'),
t('Send away')); t('Send away'));
$this->assertText(t('Test form was submitted'), 'Form message appears'); $this->assertText(t('Test form was submitted'), 'Form message appears');
$count = variable_get('search_embedded_form_submitted', 0); $count = config('search_embedded_form.settings')->get('submitted');
$this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct'); $this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct');
$this->submit_count = $count; $this->submit_count = $count;
@ -77,7 +76,7 @@ class SearchEmbedFormTest extends SearchTestBase {
array('keys' => 'foo'), array('keys' => 'foo'),
t('Search')); t('Search'));
$this->assertNoText(t('Test form was submitted'), 'Form message does not appear'); $this->assertNoText(t('Test form was submitted'), 'Form message does not appear');
$count = variable_get('search_embedded_form_submitted', 0); $count = config('search_embedded_form.settings')->get('submitted');
$this->assertEqual($this->submit_count, $count, 'Form submission count is correct'); $this->assertEqual($this->submit_count, $count, 'Form submission count is correct');
$this->submit_count = $count; $this->submit_count = $count;
} }

View File

@ -26,7 +26,7 @@ class SearchKeywordsConditionsTest extends SearchTestBase {
// Login with sufficient privileges. // Login with sufficient privileges.
$this->drupalLogin($this->searching_user); $this->drupalLogin($this->searching_user);
// Test with all search modules enabled. // Test with all search modules enabled.
variable_set('search_active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type')); config('search.settings')->set('active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type'))->save();
menu_router_rebuild(); menu_router_rebuild();
} }

View File

@ -34,7 +34,7 @@ class SearchMatchTest extends SearchTestBase {
* Set up a small index of items to test against. * Set up a small index of items to test against.
*/ */
function _setup() { function _setup() {
variable_set('minimum_word_size', 3); config('search.settings')->set('index.minimum_word_size', 3)->save();
for ($i = 1; $i <= 7; ++$i) { for ($i = 1; $i <= 7; ++$i) {
search_index($i, SEARCH_TYPE, $this->getText($i)); search_index($i, SEARCH_TYPE, $this->getText($i));

View File

@ -29,7 +29,7 @@ class SearchPageOverrideTest extends SearchTestBase {
$this->drupalLogin($this->search_user); $this->drupalLogin($this->search_user);
// Enable the extra type module for searching. // Enable the extra type module for searching.
variable_set('search_active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type')); config('search.settings')->set('active_modules', array('node' => 'node', 'user' => 'user', 'search_extra_type' => 'search_extra_type'))->save();
menu_router_rebuild(); menu_router_rebuild();
} }

View File

@ -60,7 +60,7 @@ class SearchPageTextTest extends SearchTestBase {
// Test a search input exceeding the limit of AND/OR combinations to test // Test a search input exceeding the limit of AND/OR combinations to test
// the Denial-of-Service protection. // the Denial-of-Service protection.
$limit = variable_get('search_and_or_limit', 7); $limit = config('search.settings')->get('and_or_limit');
$keys = array(); $keys = array();
for ($i = 0; $i < $limit + 1; $i++) { for ($i = 0; $i < $limit + 1; $i++) {
$keys[] = $this->randomName(3); $keys[] = $this->randomName(3);

View File

@ -30,8 +30,10 @@ class SearchTokenizerTest extends SearchTestBase {
function testTokenizer() { function testTokenizer() {
// Set the minimum word size to 1 (to split all CJK characters) and make // Set the minimum word size to 1 (to split all CJK characters) and make
// sure CJK tokenizing is turned on. // sure CJK tokenizing is turned on.
variable_set('minimum_word_size', 1); config('search.settings')
variable_set('overlap_cjk', TRUE); ->set('index.minimum_word_size', 1)
->set('index.overlap_cjk', TRUE)
->save();
$this->refreshVariables(); $this->refreshVariables();
// Create a string of CJK characters from various character ranges in // Create a string of CJK characters from various character ranges in
@ -116,8 +118,10 @@ class SearchTokenizerTest extends SearchTestBase {
function testNoTokenizer() { function testNoTokenizer() {
// Set the minimum word size to 1 (to split all CJK characters) and make // Set the minimum word size to 1 (to split all CJK characters) and make
// sure CJK tokenizing is turned on. // sure CJK tokenizing is turned on.
variable_set('minimum_word_size', 1); config('search.settings')
variable_set('overlap_cjk', TRUE); ->set('minimum_word_size', 1)
->set('overlap_cjk', TRUE)
->save();
$this->refreshVariables(); $this->refreshVariables();
$letters = 'abcdefghijklmnopqrstuvwxyz'; $letters = 'abcdefghijklmnopqrstuvwxyz';

View File

@ -49,11 +49,13 @@ function _search_get_module_names() {
* @see search_admin_settings_submit() * @see search_admin_settings_submit()
* @see search_admin_reindex_submit() * @see search_admin_reindex_submit()
*/ */
function search_admin_settings($form) { function search_admin_settings($form, &$form_state) {
$config = config('search.settings');
// Collect some stats // Collect some stats
$remaining = 0; $remaining = 0;
$total = 0; $total = 0;
foreach (variable_get('search_active_modules', array('node', 'user')) as $module) { foreach ($config->get('active_modules') as $module) {
if ($status = module_invoke($module, 'search_status')) { if ($status = module_invoke($module, 'search_status')) {
$remaining += $status['remaining']; $remaining += $status['remaining'];
$total += $status['total']; $total += $status['total'];
@ -74,10 +76,10 @@ function search_admin_settings($form) {
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('Indexing throttle') '#title' => t('Indexing throttle')
); );
$form['indexing_throttle']['search_cron_limit'] = array( $form['indexing_throttle']['cron_limit'] = array(
'#type' => 'select', '#type' => 'select',
'#title' => t('Number of items to index per cron run'), '#title' => t('Number of items to index per cron run'),
'#default_value' => variable_get('search_cron_limit', 100), '#default_value' => $config->get('index.cron_limit'),
'#options' => $items, '#options' => $items,
'#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status'))) '#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status')))
); );
@ -92,7 +94,7 @@ function search_admin_settings($form) {
$form['indexing_settings']['minimum_word_size'] = array( $form['indexing_settings']['minimum_word_size'] = array(
'#type' => 'number', '#type' => 'number',
'#title' => t('Minimum word length to index'), '#title' => t('Minimum word length to index'),
'#default_value' => variable_get('minimum_word_size', 3), '#default_value' => $config->get('index.minimum_word_size'),
'#min' => 1, '#min' => 1,
'#max' => 1000, '#max' => 1000,
'#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).') '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).')
@ -100,7 +102,7 @@ function search_admin_settings($form) {
$form['indexing_settings']['overlap_cjk'] = array( $form['indexing_settings']['overlap_cjk'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Simple CJK handling'), '#title' => t('Simple CJK handling'),
'#default_value' => variable_get('overlap_cjk', TRUE), '#default_value' => $config->get('index.overlap_cjk'),
'#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.') '#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.')
); );
@ -109,18 +111,18 @@ function search_admin_settings($form) {
'#title' => t('Active search modules') '#title' => t('Active search modules')
); );
$module_options = _search_get_module_names(); $module_options = _search_get_module_names();
$form['active']['search_active_modules'] = array( $form['active']['active_modules'] = array(
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#title' => t('Active modules'), '#title' => t('Active modules'),
'#title_display' => 'invisible', '#title_display' => 'invisible',
'#default_value' => variable_get('search_active_modules', array('node', 'user')), '#default_value' => $config->get('active_modules'),
'#options' => $module_options, '#options' => $module_options,
'#description' => t('Choose which search modules are active from the available modules.') '#description' => t('Choose which search modules are active from the available modules.')
); );
$form['active']['search_default_module'] = array( $form['active']['default_module'] = array(
'#title' => t('Default search module'), '#title' => t('Default search module'),
'#type' => 'radios', '#type' => 'radios',
'#default_value' => variable_get('search_default_module', 'node'), '#default_value' => $config->get('default_module'),
'#options' => $module_options, '#options' => $module_options,
'#description' => t('Choose which search module is the default.') '#description' => t('Choose which search module is the default.')
); );
@ -128,14 +130,14 @@ function search_admin_settings($form) {
$form['#submit'][] = 'search_admin_settings_submit'; $form['#submit'][] = 'search_admin_settings_submit';
// Per module settings // Per module settings
foreach (variable_get('search_active_modules', array('node', 'user')) as $module) { foreach ($config->get('active_modules') as $module) {
$added_form = module_invoke($module, 'search_admin'); $added_form = module_invoke($module, 'search_admin');
if (is_array($added_form)) { if (is_array($added_form)) {
$form = array_merge($form, $added_form); $form = array_merge($form, $added_form);
} }
} }
return system_settings_form($form); return system_config_form($form, $form_state);
} }
/** /**
@ -144,10 +146,10 @@ function search_admin_settings($form) {
function search_admin_settings_validate($form, &$form_state) { function search_admin_settings_validate($form, &$form_state) {
// Check whether we selected a valid default. // Check whether we selected a valid default.
if ($form_state['triggering_element']['#value'] != t('Reset to defaults')) { if ($form_state['triggering_element']['#value'] != t('Reset to defaults')) {
$new_modules = array_filter($form_state['values']['search_active_modules']); $new_modules = array_filter($form_state['values']['active_modules']);
$default = $form_state['values']['search_default_module']; $default = $form_state['values']['default_module'];
if (!in_array($default, $new_modules, TRUE)) { if (!in_array($default, $new_modules, TRUE)) {
form_set_error('search_default_module', t('Your default search module is not selected as an active module.')); form_set_error('default_module', t('Your default search module is not selected as an active module.'));
} }
} }
} }
@ -156,24 +158,30 @@ function search_admin_settings_validate($form, &$form_state) {
* Form submission handler for search_admin_settings(). * Form submission handler for search_admin_settings().
*/ */
function search_admin_settings_submit($form, &$form_state) { function search_admin_settings_submit($form, &$form_state) {
$config = config('search.settings');
// If these settings change, the index needs to be rebuilt. // If these settings change, the index needs to be rebuilt.
if ((variable_get('minimum_word_size', 3) != $form_state['values']['minimum_word_size']) || if (($config->get('index.minimum_word_size') != $form_state['values']['minimum_word_size']) || ($config->get('index.overlap_cjk') != $form_state['values']['overlap_cjk'])) {
(variable_get('overlap_cjk', TRUE) != $form_state['values']['overlap_cjk'])) { $config->set('index.minimum_word_size', $form_state['values']['minimum_word_size']);
$config->set('index.overlap_cjk', $form_state['values']['overlap_cjk']);
drupal_set_message(t('The index will be rebuilt.')); drupal_set_message(t('The index will be rebuilt.'));
search_reindex(); search_reindex();
} }
$current_modules = variable_get('search_active_modules', array('node', 'user')); $config->set('index.cron_limit', $form_state['values']['cron_limit']);
$config->set('default_module', $form_state['values']['default_module']);
// Check whether we are resetting the values. // Check whether we are resetting the values.
if ($form_state['triggering_element']['#value'] == t('Reset to defaults')) { if ($form_state['triggering_element']['#value'] == t('Reset to defaults')) {
$new_modules = array('node', 'user'); $new_modules = array('node', 'user');
} }
else { else {
$new_modules = array_filter($form_state['values']['search_active_modules']); $new_modules = array_filter($form_state['values']['active_modules']);
} }
if (array_diff($current_modules, $new_modules)) { if ($config->get('active_modules') != $new_modules) {
$config->set('active_modules', $new_modules);
drupal_set_message(t('The active search modules have been changed.')); drupal_set_message(t('The active search modules have been changed.'));
variable_set('menu_rebuild_needed', TRUE); variable_set('menu_rebuild_needed', TRUE);
} }
$config->save();
} }
/** /**

View File

@ -69,7 +69,7 @@ function sample_search_conditions_callback($keys) {
if (!empty($_REQUEST['sample_search_keys'])) { if (!empty($_REQUEST['sample_search_keys'])) {
$conditions['sample_search_keys'] = $_REQUEST['sample_search_keys']; $conditions['sample_search_keys'] = $_REQUEST['sample_search_keys'];
} }
if ($force_keys = variable_get('sample_search_force_keywords', '')) { if ($force_keys = config('sample_search.settings')->get('force_keywords')) {
$conditions['sample_search_force_keywords'] = $force_keys; $conditions['sample_search_force_keywords'] = $force_keys;
} }
return $conditions; return $conditions;
@ -328,15 +328,16 @@ function hook_search_preprocess($text) {
* When implementing this hook, your module should index content items that * When implementing this hook, your module should index content items that
* were modified or added since the last run. PHP has a time limit * were modified or added since the last run. PHP has a time limit
* for cron, though, so it is advisable to limit how many items you index * for cron, though, so it is advisable to limit how many items you index
* per run using variable_get('search_cron_limit') (see example below). Also, * per run using config('search.settings')->get('index.cron_limit') (see
* since the cron run could time out and abort in the middle of your run, you * example below). Also, since the cron run could time out and abort in the
* should update your module's internal bookkeeping on when items have last * middle of your run, you should update your module's internal bookkeeping on
* been indexed as you go rather than waiting to the end of indexing. * when items have last been indexed as you go rather than waiting to the end
* of indexing.
* *
* @ingroup search * @ingroup search
*/ */
function hook_update_index() { function hook_update_index() {
$limit = (int)variable_get('search_cron_limit', 100); $limit = (int) config('search.settings')->get('index.cron_limit');
$result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit); $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit);

View File

@ -5,15 +5,6 @@
* Install, update and uninstall functions for the search module. * Install, update and uninstall functions for the search module.
*/ */
/**
* Implements hook_uninstall().
*/
function search_uninstall() {
variable_del('minimum_word_size');
variable_del('overlap_cjk');
variable_del('search_cron_limit');
}
/** /**
* Implements hook_schema(). * Implements hook_schema().
*/ */
@ -153,3 +144,20 @@ function search_schema() {
return $schema; return $schema;
} }
/**
* Update search module to use the configuration system.
*
* @ingroup config_upgrade
*/
function search_update_8000() {
update_variables_to_config('search.settings', array(
'minimum_word_size' => 'index.minimum_word_size',
'overlap_cjk' => 'index.overlap_cjk',
'search_cron_limit' => 'index.cron_limit',
'search_tag_weights' => 'index.tag_weights',
'search_active_modules' => 'active_modules',
'search_and_or_limit' => 'and_or_limit',
'search_default_module' => 'default_module',
));
}

View File

@ -277,8 +277,8 @@ function search_get_info($all = FALSE) {
return $search_hooks; return $search_hooks;
} }
$active = variable_get('search_active_modules', array('node', 'user')); // Return only modules that are set to active in search settings.
return array_intersect_key($search_hooks, array_flip($active)); return array_intersect_key($search_hooks, array_flip(config('search.settings')->get('active_modules')));
} }
/** /**
@ -289,7 +289,7 @@ function search_get_info($all = FALSE) {
*/ */
function search_get_default_module_info() { function search_get_default_module_info() {
$info = search_get_info(); $info = search_get_info();
$default = variable_get('search_default_module', 'node'); $default = config('search.settings')->get('default_module');
if (isset($info[$default])) { if (isset($info[$default])) {
return $info[$default]; return $info[$default];
} }
@ -367,7 +367,7 @@ function search_cron() {
// to date. // to date.
drupal_register_shutdown_function('search_update_totals'); drupal_register_shutdown_function('search_update_totals');
foreach (variable_get('search_active_modules', array('node', 'user')) as $module) { foreach (config('search.settings')->get('active_modules') as $module) {
// Update word index // Update word index
module_invoke($module, 'update_index'); module_invoke($module, 'update_index');
} }
@ -428,7 +428,7 @@ function search_simplify($text) {
search_invoke_preprocess($text); search_invoke_preprocess($text);
// Simple CJK handling // Simple CJK handling
if (variable_get('overlap_cjk', TRUE)) { if (config('search.settings')->get('index.overlap_cjk')) {
$text = preg_replace_callback('/[' . PREG_CLASS_CJK . ']+/u', 'search_expand_cjk', $text); $text = preg_replace_callback('/[' . PREG_CLASS_CJK . ']+/u', 'search_expand_cjk', $text);
} }
@ -482,7 +482,7 @@ function search_simplify($text) {
* Tokenized text, starting and ending with a space character. * Tokenized text, starting and ending with a space character.
*/ */
function search_expand_cjk($matches) { function search_expand_cjk($matches) {
$min = variable_get('minimum_word_size', 3); $min = config('search.settings')->get('index.minimum_word_size');
$str = $matches[0]; $str = $matches[0];
$length = drupal_strlen($str); $length = drupal_strlen($str);
// If the text is shorter than the minimum word size, don't tokenize it. // If the text is shorter than the minimum word size, don't tokenize it.
@ -561,7 +561,7 @@ function search_invoke_preprocess(&$text) {
* @ingroup search * @ingroup search
*/ */
function search_index($sid, $module, $text) { function search_index($sid, $module, $text) {
$minimum_word_size = variable_get('minimum_word_size', 3); $minimum_word_size = config('search.settings')->get('index.minimum_word_size');
// Link matching // Link matching
global $base_url; global $base_url;
@ -570,19 +570,7 @@ function search_index($sid, $module, $text) {
// Multipliers for scores of words inside certain HTML tags. The weights are stored // Multipliers for scores of words inside certain HTML tags. The weights are stored
// in a variable so that modules can overwrite the default weights. // in a variable so that modules can overwrite the default weights.
// Note: 'a' must be included for link ranking to work. // Note: 'a' must be included for link ranking to work.
$tags = variable_get('search_tag_weights', array( $tags = config('search.settings')->get('index.tag_weights');
'h1' => 25,
'h2' => 18,
'h3' => 15,
'h4' => 12,
'h5' => 9,
'h6' => 6,
'u' => 3,
'b' => 3,
'i' => 3,
'strong' => 3,
'em' => 3,
'a' => 10));
// Strip off all ignored tags to speed up processing, but insert space before/after // Strip off all ignored tags to speed up processing, but insert space before/after
// them to keep word boundaries. // them to keep word boundaries.

View File

@ -30,7 +30,7 @@ function search_embedded_form_menu() {
* @see search_embedded_form_form_submit(). * @see search_embedded_form_form_submit().
*/ */
function search_embedded_form_form($form, &$form_state) { function search_embedded_form_form($form, &$form_state) {
$count = variable_get('search_embedded_form_submitted', 0); $count = config('search_embedded_form.settings')->get('submitted');
$form['name'] = array( $form['name'] = array(
'#type' => 'textfield', '#type' => 'textfield',
@ -56,8 +56,9 @@ function search_embedded_form_form($form, &$form_state) {
* Submit handler for search_embedded_form_form(). * Submit handler for search_embedded_form_form().
*/ */
function search_embedded_form_form_submit($form, &$form_state) { function search_embedded_form_form_submit($form, &$form_state) {
$count = variable_get('search_embedded_form_submitted', 0) + 1; $config = config('search_embedded_form.settings');
variable_set('search_embedded_form_submitted', $count); $submit_count = (int) $config->get('submitted');
$config->set('submitted', $submit_count + 1)->save();
drupal_set_message(t('Test form was submitted')); drupal_set_message(t('Test form was submitted'));
} }