From 7d79ea71ccce512dc4300daee57bd8e9d24f881a Mon Sep 17 00:00:00 2001 From: Ghislain Loas <ghislo@sandbox.pergame.net> Date: Wed, 2 Nov 2016 16:01:29 +0100 Subject: [PATCH] hotline #49355 : modify autocomplete sort to take in account numbers --- VERSIONS_HOTLINE/49355 | 1 + library/Class/Autocomplete/IndexSearcher.php | 2 +- .../modules/opac/controllers/RechercheControllerTest.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 VERSIONS_HOTLINE/49355 diff --git a/VERSIONS_HOTLINE/49355 b/VERSIONS_HOTLINE/49355 new file mode 100644 index 00000000000..44210abe5eb --- /dev/null +++ b/VERSIONS_HOTLINE/49355 @@ -0,0 +1 @@ + - ticket #49355 : question sur les propositions de titre via l'autocompletion \ No newline at end of file diff --git a/library/Class/Autocomplete/IndexSearcher.php b/library/Class/Autocomplete/IndexSearcher.php index 7975f7b34cf..0ebc8e2b59b 100644 --- a/library/Class/Autocomplete/IndexSearcher.php +++ b/library/Class/Autocomplete/IndexSearcher.php @@ -62,7 +62,7 @@ class Class_Autocomplete_IndexSearcher { public function buildGrepCommand($search_expression) { $terms = str_replace("'", "'\''", static::extractTerms($search_expression)); - $grep_args= ["-ri -E --no-filename '(\b|'\'')" . $terms[0] . "' " . $this->base_path . "| sort --unique"]; + $grep_args= ["-ri -E --no-filename '(\b|'\'')" . $terms[0] . "' " . $this->base_path . "| sort -Vuf"]; foreach(array_slice($terms, 1) as $term) $grep_args []= "-i -E '(\b|'\'')" . $term . "'"; diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index 638873159ff..e816dded951 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -2858,7 +2858,7 @@ class RechercheController_IndexSearcherTest extends RechercheControllerNoticeTes /** @test */ public function grepCommandForIleMaiteShouldRestrictLastResultToTen() { $this->assertEquals( - "grep -ri -E --no-filename '(\b|'\'')M[aà áâãäå][iìÃîï]t[eèéêë][eèéêë]' | sort --unique | grep -i -E '(\b|'\'')l'\''[iìÃîï]l[eèéêë]' | grep -i -E '(\b|'\'')[iìÃîï]l[eèéêë]' | grep -m 10 -i -E '(\b|'\'')d[eèéêë]'", + "grep -ri -E --no-filename '(\b|'\'')M[aà áâãäå][iìÃîï]t[eèéêë][eèéêë]' | sort -Vuf | grep -i -E '(\b|'\'')l'\''[iìÃîï]l[eèéêë]' | grep -i -E '(\b|'\'')[iìÃîï]l[eèéêë]' | grep -m 10 -i -E '(\b|'\'')d[eèéêë]'", (new Class_Autocomplete_IndexSearcher)->buildGrepCommand("l'ile dE Maitee")); } -- GitLab