Skip to content

Commit aa4d901

Browse files
refactor: Fix error of expected type string
1 parent 0267010 commit aa4d901

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

code/web/sys/SearchObject/SummonSearcher.php

+14-10
Original file line numberDiff line numberDiff line change
@@ -861,18 +861,22 @@ public function getDefaultIndex() {
861861
}
862862

863863
public function setSearchTerm() {
864-
if (strpos($this->searchTerms, ':') !== false) {
865-
[
866-
$searchIndex,
867-
$term,
868-
] = explode(':', $this->searchTerms, 2);
869-
$this->setSearchTerms([
870-
'lookfor' => $term,
871-
'index' => $searchIndex,
872-
]);
864+
if (is_array($this->searchTerms) && count($this->searchTerms) > 0) {
865+
if (strpos($this->searchTerms[0], ':') !== false) {
866+
[$searchIndex, $term] = explode(':', $this->searchTerms[0], 2);
867+
$this->setSearchTerms([
868+
'lookfor' => $term,
869+
'index' => $searchIndex,
870+
]);
871+
} else {
872+
$this->setSearchTerms([
873+
'lookfor' => $this->searchTerms[0],
874+
'index' => $this->getDefaultIndex(),
875+
]);
876+
}
873877
} else {
874878
$this->setSearchTerms([
875-
'lookfor' => $this->searchTerms,
879+
'lookfor' => '',
876880
'index' => $this->getDefaultIndex(),
877881
]);
878882
}

0 commit comments

Comments
 (0)