From 750edc9dc168f12278eb9da4782463d872ec980a Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 10 Sep 2020 13:23:24 +0200 Subject: search : if there is no metadata, do not generate an error log : "Invalid argument supplied for foreach() at /var/www/html/nextcloud/apps/carnet/lib/Misc/Search.php#135", --- lib/Misc/Search.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/Misc/Search.php b/lib/Misc/Search.php index 74de4e3..cdcf303 100644 --- a/lib/Misc/Search.php +++ b/lib/Misc/Search.php @@ -132,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){ -- cgit v1.2.3