From fd3d3f0bc4679a3d82db100cb230c8e0a484c24c Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 11 Feb 2026 15:30:17 +0000
Subject: [PATCH] =AuthManager.js and Referral.js minor fixes - registration form was broken
---
inc/managers/queue/executors/UploadExecutor.php | 51 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 41 insertions(+), 10 deletions(-)
diff --git a/inc/managers/queue/executors/UploadExecutor.php b/inc/managers/queue/executors/UploadExecutor.php
index 3cc90a7..1d42036 100644
--- a/inc/managers/queue/executors/UploadExecutor.php
+++ b/inc/managers/queue/executors/UploadExecutor.php
@@ -151,27 +151,43 @@
throw new Exception('No upload operation ID provided');
}
- // Get results from the dependency
$uploadOp = JVB()->queue()->get($uploadOpId);
- if (!$uploadOp || $uploadOp->outcome !== 'success') {
+ if (!$uploadOp || !in_array($uploadOp->outcome, ['success', 'partial'])) {
throw new Exception("Upload operation {$uploadOpId} not completed successfully");
}
- $uploadResults = $uploadOp->result ?? [];
+ $uploadResults = $uploadOp->result['uploads'] ?? [];
if (empty($uploadResults)) {
throw new Exception('No upload results found');
}
- // Attach to content via field
+ // Resolve post_id from content_update dependency for new posts
+ if (empty($data['post_id']) || str_starts_with((string)($data['item_id'] ?? ''), 'new')) {
+ foreach ($operation->dependencies as $depId) {
+ $dep = JVB()->queue()->get($depId);
+ if ($dep && $dep->type === 'content_update' && !empty($dep->result['new_posts'])) {
+ $itemId = $data['item_id'] ?? null;
+ if ($itemId && isset($dep->result['new_posts'][$itemId])) {
+ $data['post_id'] = $dep->result['new_posts'][$itemId];
+ break;
+ }
+ }
+ }
+
+ if (empty($data['post_id'])) {
+ throw new Exception('Could not resolve post_id from dependencies');
+ }
+ }
+
if (!empty($data['field_name'])) {
- $this->updateFieldValue($data, $uploadResults);
+ $this->saveToMeta($data, $uploadResults);
}
$progress->advance(1);
return new Result(
outcome: 'success',
- result: ['attached' => count($uploadResults)]
+ result: ['attached' => count($uploadResults), 'post_id' => $data['post_id']]
);
}
@@ -442,8 +458,11 @@
if (!$found) {
error_log('Could not find a gallery upload field for post '.$ID);
}
+
+ $meta->save();
}
+
return [
'ID' => $ID,
'usedUploads' => $uploadIds
@@ -636,11 +655,20 @@
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));
+ }
+
+ $meta->save();
}
private function updateFieldValue(array $data, array $results): void
@@ -660,6 +688,7 @@
$allIds = array_unique(array_merge($existingIds, $attachmentIds));
$meta->set($data['field_name'], implode(',', $allIds));
+ $meta->save();
}
private function getMetaManager(array $data): ?Meta
@@ -722,12 +751,14 @@
} elseif (str_starts_with($mimeType, 'video/')) {
$meta = Meta::forPost($postId);
$meta->set('video', $attachmentId);
+ $meta->save();
} else {
$meta = Meta::forPost($postId);
$existing = $meta->get('documents');
$existingIds = !empty($existing) ? explode(',', $existing) : [];
$existingIds[] = $attachmentId;
$meta->set('documents', implode(',', $existingIds));
+ $meta->save();
}
}
--
Gitblit v1.10.0