Fix phrase search
authorDavid Causse <dcausse@wikimedia.org>
Thu, 29 Jun 2017 08:29:13 +0000 (10:29 +0200)
committerDavid Causse <dcausse@wikimedia.org>
Mon, 3 Jul 2017 09:44:48 +0000 (11:44 +0200)
commit187ada1cf404f5943f8962c6241aa53eb3fa139c
treecaa18bbc047420d495690af1337367d5cbe1db1f
parentb3f0a59256a821e9f446d2201b401a77ffb93331
Fix phrase search

Partially revert I61dc536 that broke phrase search support.

Fix phrase search by making explicit that there are two
kind of legalSearchChars() usecases :

- the chars allowed to be part of the search query (including special
  syntax chars such as " and *). Used by SearchDatabase::filter() to
  cleanup the whole query string (the default).

- the chars allowed to be part of a search term (excluding special
  syntax chars) Used by search engine implementaions when parsing with
  a regex.

For future reference:
Originally this distinction was made "explicit" by calling directly
SearchEngine::legalSearchChars() during the parsing stage. This was
broken by Iaabc10c by enabling inheritance.
This patch adds a new optional param to legalSearchChars to make this
more explicit.

Also remove the function I introduced in I61dc536 (I wrongly assumed
that the disctinction made between legalSearchChars usecases was due
to a difference in behavior between indexing and searching).

Added more tests to prevent this from happening in the future.

Bug: T167798
Change-Id: Ibdc796bb2881a2ed8194099d8c9f491980010f0f
includes/deferred/SearchUpdate.php
includes/search/SearchDatabase.php
includes/search/SearchEngine.php
includes/search/SearchMssql.php
includes/search/SearchMySQL.php
includes/search/SearchOracle.php
includes/search/SearchSqlite.php
tests/phpunit/includes/search/SearchEngineTest.php