[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [BP][FIX] File Galleries: Ensure correct destination for AJAX file uploads
"Baraka Kinywa \(@bkinywa24\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6894882f58bdb_2cb4c9f4395c0@gitlab-sidekiq-low-urgency-cpu-bound-v2-fcfcfbbb-68tqs.mail> |
Baraka Kinywa pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki
Commits:
99d84907 by MAGENE Sem Joel at 2025-08-07T13:56:17+03:00
[BP][FIX] File Galleries: Ensure correct destination for AJAX file uploads
---
* [FIX] File Galleries: Ensure correct destination for AJAX file uploads
---
* [FIX] Fgal : Ensure correct destination for AJAX file uploads
See merge request tikiwiki/tiki!8211
See merge request tikiwiki/tiki!8218
- - - - -
1 changed file:
- lib/core/Services/File/Controller.php
Changes:
=====================================
lib/core/Services/File/Controller.php
=====================================
@@ -930,11 +930,22 @@ class Services_File_Controller
private function checkTargetGallery($input)
{
- if ($input->fileId->int()) {
+ // The file uploader sends galleryId as an array, while elFinder and older methods send it as an integer. This logic handles all cases.
+
+ // First, check for the array format used by the file uploader.
+ $galleryIdFromInput = $input->galleryId->asArray();
+ if (! empty($galleryIdFromInput) && is_array($galleryIdFromInput) && isset($galleryIdFromInput[0])) {
+ $galleryId = (int) $galleryIdFromInput[0];
+ } elseif ($input->galleryId->int()) {
+ // Second, check for an integer format, used by elFinder and other parts of Tiki.
+ $galleryId = $input->galleryId->int();
+ } elseif ($input->fileId->int()) {
+ // Third, fall back to the context of an existing file (for editing).
$fileInfo = TikiLib::lib('filegal')->get_file_info($input->fileId->int());
$galleryId = $fileInfo ? $fileInfo['galleryId'] : $this->defaultGalleryId;
} else {
- $galleryId = $input->galleryId->int() ?: $this->defaultGalleryId;
+ // Finally, if no gallery is specified in any of the above contexts, use the system default.
+ $galleryId = $this->defaultGalleryId;
}
// Patch for uninitialized utilities.
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/99d849071be4ebfc92b97a93a78744990aa6a157
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/99d849071be4ebfc92b97a93a78744990aa6a157
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