Skip to content

Commit

Permalink
! fix elkarte#3678 cant use += when array_merge is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Spuds committed Apr 2, 2024
1 parent 9299d04 commit c63d49b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions sources/ElkArte/Search/API/Custom.php
Expand Up @@ -28,10 +28,10 @@
class Custom extends Standard
{
/** @var string This is the last version of ElkArte that this was tested on, to protect against API changes. */
public $version_compatible = 'ElkArte 2.0 dev';
public $version_compatible = 'ElkArte 2.0';

/** @var string This won't work with versions of ElkArte less than this. */
public $min_elk_version = 'ElkArte 1.0 Beta';
public $min_elk_version = 'ElkArte 1.0';

/** @var bool Is it supported? */
public $is_supported = true;
Expand Down Expand Up @@ -63,7 +63,7 @@ public function __construct($config, $searchParams)

$this->indexSettings = Util::unserialize($modSettings['search_custom_index_config']);

$this->bannedWords = empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']);
$this->bannedWords = empty($modSettings['search_stopwords']) ? [] : explode(',', $modSettings['search_stopwords']);
}

/**
Expand Down Expand Up @@ -95,9 +95,11 @@ public function prepareIndexes($word, &$wordsSearch, &$wordsExclude, $isExcluded
{
return;
}

foreach ($subwords as $subword)
{
if (Util::strlen($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords))
if (Util::strlen($subword) >= $this->min_word_length
&& !in_array($subword, $this->bannedWords, true))
{
$wordsSearch['indexed_words'][] = $subword;
if ($isExcluded !== false)
Expand Down Expand Up @@ -135,9 +137,7 @@ public function indexedWordQuery($words, $search_data)
// We can't do anything without this
$db_search = db_search();

$query_select = array(
'id_msg' => 'm.id_msg',
);
$query_select = ['id_msg' => 'm.id_msg',];
$query_inner_join = [];
$query_left_join = [];
$query_where = [];
Expand All @@ -151,15 +151,15 @@ public function indexedWordQuery($words, $search_data)
$count = 0;
foreach ($words['words'] as $regularWord)
{
$query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' {not_' : '{') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? 'ilike} ' : 'rlike} ') . '{string:complex_body_' . $count . '}';
$query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words'], true) ? ' {not_' : '{') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? 'ilike} ' : 'rlike} ') . '{string:complex_body_' . $count . '}';
$query_params['complex_body_' . ($count++)] = $this->prepareWord($regularWord, $search_data['no_regexp']);
}

// Modifiers such as specific user or specific board.
$query_where += $this->queryWhereModifiers($query_params);
$query_where = array_merge($query_where, $this->queryWhereModifiers($query_params));

// Modifiers to exclude words from the subject
$query_where += $this->queryExclusionModifiers($query_params, $search_data);
$query_where = array_merge($query_where, $this->queryExclusionModifiers($query_params, $search_data));

$numTables = 0;
$prev_join = 0;
Expand Down Expand Up @@ -216,7 +216,7 @@ public function postCreated($msgOptions, $topicOptions, $posterOptions)
{
$db->insert('ignore',
'{db_prefix}log_search_words',
array('id_word' => 'int', 'id_msg' => 'int'),
['id_word' => 'int', 'id_msg' => 'int'],
$inserts,
['id_word', 'id_msg']
);
Expand Down

0 comments on commit c63d49b

Please sign in to comment.