diff options
author | PhieF <phie@phie.ovh> | 2020-09-11 15:51:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-11 15:51:29 +0300 |
commit | 906121bbe6585533f7059c63565820d530bbefd5 (patch) | |
tree | 4b4266c3b2f64b60610d130f4f22c74fdfab8b3d | |
parent | 9804d6fde7527ad44b486c8e050607025d2f4072 (diff) | |
parent | 01c6e632c27d39858d5efc9b3eaf63e3b7f3b60a (diff) |
Merge pull request #122 from dominiquefournier/log-empty-search
search : do not generate PHP logs in standard usage
-rw-r--r-- | lib/Misc/Search.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/Misc/Search.php b/lib/Misc/Search.php index 018f112..3ee11a0 100644 --- a/lib/Misc/Search.php +++ b/lib/Misc/Search.php @@ -17,6 +17,7 @@ class Search { private $searchCache; private $current=0; private $from; + private $pathArray = array (); /** * @param string $appName @@ -131,11 +132,14 @@ private function search($relativePath, $folder, $query, $curDepth){ try { $metadata = json_decode($zipFile->getEntryContents("metadata.json")); $hasFound = false; - foreach($metadata->keywords as $keyword){ - if(strstr($this->removeAccents(strtolower($keyword)), $query)){ - $this->writeFound($relativePath,$in); - $hasFound = true; - break; + if (is_object ($metadata)) + { + foreach($metadata->keywords as $keyword){ + if(strstr($this->removeAccents(strtolower($keyword)), $query)){ + $this->writeFound($relativePath,$in); + $hasFound = true; + break; + } } } if($hasFound){ @@ -145,7 +149,7 @@ private function search($relativePath, $folder, $query, $curDepth){ } catch(Exception $e){ } $index = $zipFile->getEntryContents("index.html"); - if(strstr(strtolower($this->removeAccents($index)), $query)){ + if(trim ($query) !== "" && strstr(strtolower($this->removeAccents($index)), $query)){ $this->writeFound($relativePath,$in); } } catch(\OCP\Files\NotFoundException $e) { @@ -188,4 +192,4 @@ $this->setName('carnet:search') } -?>
\ No newline at end of file +?> |