Skip to content

Commit

Permalink
Fixed deprecations in search extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
parpalak committed Jan 14, 2022
1 parent 302af46 commit 24e6cab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
_vendor/*
config.php
favicon.ico
robots.txt
24 changes: 10 additions & 14 deletions _extensions/s2_search/finder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,24 @@ protected function find_fulltext ($words)

$curr_positions = array();

foreach ($words_for_search as $search_word)
{
if (!isset($this->fulltext_index[$search_word]))
continue;
foreach ($this->fulltext_index[$search_word] as $id => $entries)
{
foreach ($words_for_search as $search_word) {
foreach ($this->fulltext_index[$search_word] ?? [] as $id => $entries) {
$chapter = $this->chapters[$id];

// Remember chapters and positions
if (is_int($entries))
if (is_int($entries)) {
$curr_positions[$chapter][] = $entries;
else
{
$entry_count = 1;
}
else {
$entries = explode('|', $entries);
foreach ($entries as $position)
$entry_count = count($entries);
foreach ($entries as $position) {
$curr_positions[$chapter][] = base_convert($position, 36, 10);
}
}

if (!isset ($this->keys[$chapter][$word]))
$this->keys[$chapter][$word] = count($entries) * $word_weight;
else
$this->keys[$chapter][$word] += count($entries) * $word_weight;
$this->keys[$chapter][$word] = ($this->keys[$chapter][$word] ?? 0) + $entry_count * $word_weight;
}
}

Expand Down

0 comments on commit 24e6cab

Please sign in to comment.