[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] FinderController.php: prevent foreach() on non-array value
Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <692f6c6baec0f_2a17c1f44222d@gitlab-sidekiq-low-urgency-cpu-bound-v2-5dbbd45dbb-fmsxj.mail> |
Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
0dde8046 by David Maene at 2025-12-02T22:39:14+00:00
[FIX] FinderController.php: prevent foreach() on non-array value
---
* [FIX] FinderController.php: prevent foreach() on non-array value
See merge request tikiwiki/tiki!9076
- - - - -
1 changed file:
- lib/core/Services/File/FinderController.php
Changes:
=====================================
lib/core/Services/File/FinderController.php
=====================================
@@ -236,23 +236,22 @@ class Services_File_FinderController
return [];
}
- private function getHashInfo($elFinder, $hashes, $params)
+ private function getHashInfo($elFinder, string $hash, array $params)
{
$filegallib = TikiLib::lib('filegal');
- $ret = [];
- foreach ($hashes as $hash) {
- $fileId = $elFinder->realpath($hash);
- if (str_contains($fileId, 'f_')) {
- $info = $filegallib->get_file(str_replace('f_', '', $fileId));
- } else {
- $info = $filegallib->get_file_gallery(str_replace('d_', '', $fileId));
- }
- $info['wiki_syntax'] = $filegallib->getWikiSyntax($info['galleryId'], empty($info['fileId']) ? [] : $info, $params);
- $info['data'] = ''; // binary data makes JSON fall over
- $ret[] = $info;
+
+ $fileId = $elFinder->realpath($hash);
+
+ if (str_contains($fileId, 'f_')) {
+ $info = $filegallib->get_file(str_replace('f_', '', $fileId));
+ } else {
+ $info = $filegallib->get_file_gallery(str_replace('d_', '', $fileId));
}
- return $ret;
+ $info['wiki_syntax'] = $filegallib->getWikiSyntax($info['galleryId'], empty($info['fileId']) ? [] : $info, $params);
+ $info['data'] = '';
+
+ return $info;
}
/**
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/0dde80462589e3e226eaf3a256996a9ff01a7a15
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/0dde80462589e3e226eaf3a256996a9ff01a7a15
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs