From 172a8b4404ea4ef10801d4662a68c7503aef23e1 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 10 Feb 2026 23:47:05 +0000
Subject: [PATCH] =Minor changes to upload system for when a field's value is deleted, and replaced with a new item
---
inc/managers/queue/executors/UploadExecutor.php | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/inc/managers/queue/executors/UploadExecutor.php b/inc/managers/queue/executors/UploadExecutor.php
index 3cc90a7..0c693d6 100644
--- a/inc/managers/queue/executors/UploadExecutor.php
+++ b/inc/managers/queue/executors/UploadExecutor.php
@@ -636,11 +636,18 @@
return;
}
- $existing = $meta->get($data['field_name']);
- $existingIds = !empty($existing) ? explode(',', $existing) : [];
- $allIds = array_unique(array_merge($existingIds, $attachmentIds));
+ $fieldType = $data['field_type'] ?? 'single';
- $meta->set($data['field_name'], implode(',', $allIds));
+ if ($fieldType === 'single') {
+ // Single field: replace with latest upload
+ $meta->set($data['field_name'], end($attachmentIds));
+ } else {
+ // Multi field: merge with existing
+ $existing = $meta->get($data['field_name']);
+ $existingIds = !empty($existing) ? explode(',', $existing) : [];
+ $allIds = array_unique(array_merge($existingIds, $attachmentIds));
+ $meta->set($data['field_name'], implode(',', $allIds));
+ }
}
private function updateFieldValue(array $data, array $results): void
--
Gitblit v1.10.0