[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] File Galleries: Ensure correct destination for AJAX file uploads

"luci \(@luciash\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68946b6e1ae14_2cb8649c4144a@gitlab-sidekiq-low-urgency-cpu-bound-v2-fcfcfbbb-pkljm.mail>

luci pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
b28347d1 by MAGENE Sem Joel at 2025-08-07T08:53:34+00:00
[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

- - - - -


1 changed file:

- lib/core/Services/File/Controller.php


Changes:

=====================================
lib/core/Services/File/Controller.php
=====================================
@@ -936,11 +936,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/b28347d122647c6c6fc599d4f1b06db6a4637261

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/b28347d122647c6c6fc599d4f1b06db6a4637261
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.