From 3b3bd067d0ff2671fca2890c14428c97e1011a2b Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 11 Feb 2026 03:20:21 +0000
Subject: [PATCH] =Hey guess what? Meta->set() and Meta->setAll() doesn't actually save the meta to the database. Went through the files and added a ->save() call after every set
---
inc/managers/queue/executors/UploadExecutor.php | 36 ++++++++++++++++++++++++++++++------
1 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/inc/managers/queue/executors/UploadExecutor.php b/inc/managers/queue/executors/UploadExecutor.php
index 0c693d6..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
@@ -648,6 +667,8 @@
$allIds = array_unique(array_merge($existingIds, $attachmentIds));
$meta->set($data['field_name'], implode(',', $allIds));
}
+
+ $meta->save();
}
private function updateFieldValue(array $data, array $results): void
@@ -667,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
@@ -729,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