Remove the hyphen as a legal search character for MySQL
Bug: T221560 Change-Id: Ib38ab6334983eecea0981540d102ecde7fc94d42 (cherry picked from commit 693155fe2c653fbae781578fcb39d9888df5b2a3)
This commit is contained in:
parent
8e14ff1bc0
commit
3ac4f81c18
1 changed files with 11 additions and 0 deletions
|
|
@ -162,6 +162,17 @@ class SearchMySQL extends SearchDatabase {
|
|||
|
||||
public function legalSearchChars( $type = self::CHARS_ALL ) {
|
||||
$searchChars = parent::legalSearchChars( $type );
|
||||
|
||||
// In the MediaWiki UI, search strings containing (just) a hyphen are translated into
|
||||
// MATCH(si_title) AGAINST('+- ' IN BOOLEAN MODE)
|
||||
// which is not valid.
|
||||
|
||||
// From <https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html>:
|
||||
// "InnoDB full-text search does not support... a plus and minus sign combination ('+-')"
|
||||
|
||||
// See also https://phabricator.wikimedia.org/T221560
|
||||
$searchChars = preg_replace( '/\\\\-/', '', $searchChars );
|
||||
|
||||
if ( $type === self::CHARS_ALL ) {
|
||||
// " for phrase, * for wildcard
|
||||
$searchChars = "\"*" . $searchChars;
|
||||
|
|
|
|||
Loading…
Reference in a new issue