[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] File Gallery: apply categories selected when uploading a single or several files
"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a919c62887a0_383f931499180@gitlab-sidekiq-low-urgency-cpu-bound-v2-7bbd4dd4cd-ch947.mail> |
Victor Emanouilov pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
4e9f9af5 by Bernard Sfez at 2026-08-28T14:25:32+00:00
[FIX] File Gallery: apply categories selected when uploading a single or several files
---
* [FIX] replace ||= with an explicit check to pass ESLint
* [FIX] File Gallery: apply categories selected when uploading a single or several files
See merge request tikiwiki/tiki!11049
- - - - -
2 changed files:
- lib/core/Services/File/Controller.php
- src/js/vue-widgets/element-plus-ui/src/helpers/fileGalUploader/getUploadData.js
Changes:
=====================================
lib/core/Services/File/Controller.php
=====================================
@@ -216,11 +216,22 @@ class Services_File_Controller
$cat_name = $name;
$cat_href = "tiki-download_file.php?fileId=$fileId";
- if ($categories) {
+ // Categories are either posted by the form or, on a replace, already on the file.
+ $postedCategories = [];
+ if (isset($_REQUEST['cat_categorize']) && $_REQUEST['cat_categorize'] === 'on' && ! empty($_REQUEST['cat_categories'])) {
+ $postedCategories = array_filter(array_map('intval', (array) $_REQUEST['cat_categories']));
+ }
+
+ if ($postedCategories) {
+ $_REQUEST['cat_categories'] = $postedCategories;
+ include('categorize.php');
+ } elseif ($categories) {
+ // Replacing a file with nothing posted: keep what it already had.
$_REQUEST['cat_categories'] = $categories;
- $_REQUEST["cat_categorize"] = 'on';
+ $_REQUEST['cat_categorize'] = 'on';
+ include('categorize.php');
}
- include('categorize.php');
+ // Otherwise skip: categorize.php has no no-op path and would clear the file's categories.
$filegallib = TikiLib::lib('filegal');
$info = $filegallib->get_file_info($fileId);
=====================================
src/js/vue-widgets/element-plus-ui/src/helpers/fileGalUploader/getUploadData.js
=====================================
@@ -21,10 +21,20 @@ export default async function (file, maxWidth, maxHeight) {
ElMessage.error("Failed to get file data");
}
- const form = $("form#file_0").serializeArray();
- form.forEach((item) => {
- result[item.name] = item.value;
- });
+ // serializeArray() repeats multi-value fields (cat_categories[], cat_managed[]);
+ // a flat assign keeps only the last and silently drops the selection.
+ $("form#file_0")
+ .serializeArray()
+ .forEach((item) => {
+ if (item.name.endsWith("[]")) {
+ if (!Array.isArray(result[item.name])) {
+ result[item.name] = [];
+ }
+ result[item.name].push(item.value);
+ } else {
+ result[item.name] = item.value;
+ }
+ });
return result;
}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/4e9f9af57d7cc1926a251335defefd56e75ef7aa
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/4e9f9af57d7cc1926a251335defefd56e75ef7aa
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs