Issue #2715113 by anshuljain2k8, SwapS, dagmar, Fabianx, ndobromirov: Watchdog logging of all searches is performance hit; need ability to turn it off (7.x)
parent
7a94baeb94
commit
dc0064dd91
|
@ -125,6 +125,16 @@ function search_admin_settings($form) {
|
||||||
'#options' => $module_options,
|
'#options' => $module_options,
|
||||||
'#description' => t('Choose which search module is the default.')
|
'#description' => t('Choose which search module is the default.')
|
||||||
);
|
);
|
||||||
|
$form['logging'] = array(
|
||||||
|
'#type' => 'fieldset',
|
||||||
|
'#title' => t('Logging')
|
||||||
|
);
|
||||||
|
$form['logging']['search_logging'] = array(
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#title' => t('Log searches'),
|
||||||
|
'#default_value' => variable_get('search_logging', 1),
|
||||||
|
'#description' => t('If checked, all searches will be logged. Uncheck to skip logging. Logging may affect performance.'),
|
||||||
|
);
|
||||||
$form['#validate'][] = 'search_admin_settings_validate';
|
$form['#validate'][] = 'search_admin_settings_validate';
|
||||||
$form['#submit'][] = 'search_admin_settings_submit';
|
$form['#submit'][] = 'search_admin_settings_submit';
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ function search_uninstall() {
|
||||||
variable_del('minimum_word_size');
|
variable_del('minimum_word_size');
|
||||||
variable_del('overlap_cjk');
|
variable_del('overlap_cjk');
|
||||||
variable_del('search_cron_limit');
|
variable_del('search_cron_limit');
|
||||||
|
variable_del('search_logging');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,9 +57,10 @@ function search_view($module = NULL, $keys = '') {
|
||||||
}
|
}
|
||||||
// Only search if there are keywords or non-empty conditions.
|
// Only search if there are keywords or non-empty conditions.
|
||||||
if ($keys || !empty($conditions)) {
|
if ($keys || !empty($conditions)) {
|
||||||
// Log the search keys.
|
if (variable_get('search_logging', TRUE)) {
|
||||||
watchdog('search', 'Searched %type for %keys.', array('%keys' => $keys, '%type' => $info['title']), WATCHDOG_NOTICE, l(t('results'), 'search/' . $info['path'] . '/' . $keys));
|
// Log the search keys.
|
||||||
|
watchdog('search', 'Searched %type for %keys.', array('%keys' => $keys, '%type' => $info['title']), WATCHDOG_NOTICE, l(t('results'), 'search/' . $info['path'] . '/' . $keys));
|
||||||
|
}
|
||||||
// Collect the search results.
|
// Collect the search results.
|
||||||
$results = search_data($keys, $info['module'], $conditions);
|
$results = search_data($keys, $info['module'], $conditions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1453,7 +1453,7 @@ class SearchConfigSettingsForm extends DrupalWebTestCase {
|
||||||
parent::setUp('search', 'search_extra_type');
|
parent::setUp('search', 'search_extra_type');
|
||||||
|
|
||||||
// Login as a user that can create and search content.
|
// Login as a user that can create and search content.
|
||||||
$this->search_user = $this->drupalCreateUser(array('search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks'));
|
$this->search_user = $this->drupalCreateUser(array('search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks', 'access site reports'));
|
||||||
$this->drupalLogin($this->search_user);
|
$this->drupalLogin($this->search_user);
|
||||||
|
|
||||||
// Add a single piece of content and index it.
|
// Add a single piece of content and index it.
|
||||||
|
@ -1502,6 +1502,19 @@ class SearchConfigSettingsForm extends DrupalWebTestCase {
|
||||||
);
|
);
|
||||||
$this->drupalPost('admin/config/search/settings', $edit, t('Save configuration'));
|
$this->drupalPost('admin/config/search/settings', $edit, t('Save configuration'));
|
||||||
$this->assertNoText(t('The configuration options have been saved.'), 'Form does not save with an invalid word length.');
|
$this->assertNoText(t('The configuration options have been saved.'), 'Form does not save with an invalid word length.');
|
||||||
|
|
||||||
|
// Test logging setting. It should be on by default.
|
||||||
|
$text = $this->randomName(5);
|
||||||
|
$this->drupalPost('search/node', array('keys' => $text), t('Search'));
|
||||||
|
$this->drupalGet('admin/reports/dblog');
|
||||||
|
$this->assertLink('Searched Content for ' . $text . '.', 0, 'Search was logged');
|
||||||
|
|
||||||
|
// Turn off logging.
|
||||||
|
variable_set('search_logging', FALSE);
|
||||||
|
$text = $this->randomName(5);
|
||||||
|
$this->drupalPost('search/node', array('keys' => $text), t('Search'));
|
||||||
|
$this->drupalGet('admin/reports/dblog');
|
||||||
|
$this->assertNoLink('Searched Content for ' . $text . '.', 'Search was not logged');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue