- Patch #124980 by jhodgdon: Indexer is removing ... and -- instead of replacing with a space.
parent
19c7193c4c
commit
d79dff03ac
|
@ -372,10 +372,13 @@ function search_simplify($text) {
|
|||
// Readable regexp: ([number]+)[punctuation]+(?=[number])
|
||||
$text = preg_replace('/([' . PREG_CLASS_NUMBERS . ']+)[' . PREG_CLASS_PUNCTUATION . ']+(?=[' . PREG_CLASS_NUMBERS . '])/u', '\1', $text);
|
||||
|
||||
// Multiple dot and dash groups are word boundaries and replaced with space.
|
||||
// No need to use the unicode modifer here because 0-127 ASCII characters
|
||||
// can't match higher UTF-8 characters as the leftmost bit of those are 1.
|
||||
$text = preg_replace('/[.-]{2,}/', ' ', $text);
|
||||
|
||||
// The dot, underscore and dash are simply removed. This allows meaningful
|
||||
// search behavior with acronyms and URLs. No need to use the unicode modifer
|
||||
// here because 0-127 ASCII characters can't match higher UTF-8 characters as
|
||||
// the leftmost bit of those are 1.
|
||||
// search behavior with acronyms and URLs. See unicode note directly above.
|
||||
$text = preg_replace('/[._-]+/', '', $text);
|
||||
|
||||
// With the exception of the rules above, we consider all punctuation,
|
||||
|
|
|
@ -935,22 +935,22 @@ class SearchCommentCountToggleTestCase extends DrupalWebTestCase {
|
|||
$this->drupalPost('', $edit, t('Search'));
|
||||
$this->assertNoText(t('0 comments'), t('Empty comment count does not display for nodes with comment status set to Hidden'));
|
||||
$this->assertNoText(t('1 comment'), t('Non-empty comment count does not display for nodes with comment status set to Hidden'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test search_simplify() on every Unicode character.
|
||||
* Test search_simplify() on every Unicode character, and some other cases.
|
||||
*/
|
||||
class SearchSimplifyTestCase extends DrupalWebTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Search simplify',
|
||||
'description' => 'Check that simplification works as intended.',
|
||||
'description' => 'Check that the search_simply() function works as intended.',
|
||||
'group' => 'Search',
|
||||
);
|
||||
}
|
||||
|
||||
function testSearchSimplify() {
|
||||
function testSearchSimplifyUnicode() {
|
||||
$input = file_get_contents(DRUPAL_ROOT . '/modules/search/tests/UnicodeTest.txt');
|
||||
$strings = explode(chr(10), $input);
|
||||
foreach ($strings as $key => $string) {
|
||||
|
@ -969,6 +969,23 @@ class SearchSimplifyTestCase extends DrupalWebTestCase {
|
|||
// Diff really does not like files starting with \0 so test it separately.
|
||||
$this->assertIdentical(' ', search_simplify($string), t('Search simplify works for ASCII control characters.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that search_simplify() does the right thing with punctuation.
|
||||
*/
|
||||
function testSearchSimplifyPunctuation() {
|
||||
$cases = array(
|
||||
array('20.03/94-28,876', '20039428876', 'Punctuation removed from numbers'),
|
||||
array('great...drupal--module', 'great drupal module', 'Multiple dot and dashes are word boundaries'),
|
||||
array('very_great-drupal.module', 'verygreatdrupalmodule', 'Single dot, dash, underscore are removed'),
|
||||
array('regular,punctuation;word', 'regular punctuation word', 'Punctuation is a word boundary'),
|
||||
);
|
||||
|
||||
foreach ($cases as $case) {
|
||||
$out = trim(search_simplify($case[0]));
|
||||
$this->assertEqual($out, $case[1], $case[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
// $Id$
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*
|
||||
* Allows the profile to alter the site configuration form.
|
||||
*/
|
||||
function minimal_form_install_configure_form_alter(&$form, $form_state) {
|
||||
// Pre-populate the site name with the server name.
|
||||
$form['site_information']['site_name']['#default_value'] = $_SERVER['SERVER_NAME'];
|
||||
}
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
// $Id$
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*
|
||||
* Allows the profile to alter the site configuration form.
|
||||
*/
|
||||
function standard_form_alter(&$form, $form_state, $form_id) {
|
||||
if ($form_id == 'install_configure_form') {
|
||||
// Set default for site name field.
|
||||
$form['site_information']['site_name']['#default_value'] = $_SERVER['SERVER_NAME'];
|
||||
}
|
||||
function standard_form_install_configure_form_alter(&$form, $form_state) {
|
||||
// Pre-populate the site name with the server name.
|
||||
$form['site_information']['site_name']['#default_value'] = $_SERVER['SERVER_NAME'];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue