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/ContentExecutor.php |   52 ++++++++++++++++++++++------------------------------
 1 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/inc/managers/queue/executors/ContentExecutor.php b/inc/managers/queue/executors/ContentExecutor.php
index 610037f..4bc06de 100644
--- a/inc/managers/queue/executors/ContentExecutor.php
+++ b/inc/managers/queue/executors/ContentExecutor.php
@@ -2,7 +2,7 @@
 namespace JVBase\managers\queue\executors;
 
 use JVBase\managers\queue\{Executor, Operation, Progress, Result, Storage};
-use JVBase\meta\MetaManager;
+use JVBase\meta\Meta;
 use JVBase\utility\Features;
 use Exception;
 
@@ -76,9 +76,11 @@
 
 		$results = [];
 		$errors = [];
+		$success = [];
 		$timelineParents = [];
 		$timelineStatus = [];
 		$timelineSharedFields = [];
+		$newPostsMap = [];
 
 		foreach ($posts as $id => $postData) {
 			try {
@@ -94,16 +96,14 @@
 					]);
 
 					if (!$newId || is_wp_error($newId)) {
+						$errors[$id] = 'Could not create post';
 						$progress->failItem($id, 'Could not create post');
 						continue;
 					}
 
+					$newPostsMap[$id] = $newId;
 					$this->savePostFields($newId, $postData);
-					$results[$id] = [
-						'success' => true,
-						'new_id' => $newId,
-						'processed_fields' => array_keys($postData)
-					];
+					$success[$newId] = array_keys($postData);
 					$progress->advance();
 					continue;
 				}
@@ -117,7 +117,6 @@
 
 				$this->savePostFields((int)$id, $postData);
 
-
 				if (Features::forContent($content)->has('is_timeline')) {
 					$post = get_post((int)$id);
 					$parentId = $post->post_parent > 0 ? $post->post_parent : $post->ID;
@@ -142,19 +141,12 @@
 						}
 					}
 				}
-				$results[$id] = [
-					'success' => true,
-					'processed_fields' => array_keys($postData)
-				];
-				$progress->advance();
 
+				$success[$id] = array_keys($postData);
+				$progress->advance();
 			} catch (Exception $e) {
 				$progress->failItem($id, $e->getMessage());
 				$errors[$id] = $e->getMessage();
-				$results[$id] = [
-					'success' => false,
-					'error' => $e->getMessage()
-				];
 			}
 		}
 
@@ -188,15 +180,13 @@
 			$outcome = count($errors) === count($posts) ? 'failed' : 'partial';
 		}
 
-
-
-
 		return new Result(
 			outcome: $outcome,
 			result: [
-				'posts' => $results,
+				'posts'	=> $success,
 				'errors' => $errors,
-				'updated_count' => count(array_filter($results, fn($r) => $r['success'] ?? false)),
+				'new_posts' => $newPostsMap,
+				'updated_count' => count($success),
 				'failed_count' => count($errors)
 			]
 		);
@@ -215,8 +205,9 @@
 			return true;
 		}
 
-		$meta = new MetaManager($postId, 'post');
-		return $meta->setAll($allowedFields);
+		return Meta::forPost($postId)
+			->setAll($allowedFields)
+			->save();
 	}
 
 	// ─────────────────────────────────────────────────────────────
@@ -315,9 +306,9 @@
 
 		$lastKey = array_key_last($posts);
 		foreach ($posts as $index => $post) {
-			$meta = new MetaManager($post->ID, 'post');
+			$meta = Meta::forPost($post->ID);
 			if ($index === 0) {
-				$meta->updateValue('timeline', '', false);
+				$meta->set('timeline', '');
 				$previousPost = $post;
 				continue; // Parent has no timeline
 			}
@@ -328,7 +319,7 @@
 				if ($timeline) {
 					$termId = $this->getOrCreateTerm($timeline, 'timeline');
 					if ($termId) {
-						$success = $meta->updateValue('timeline', $termId, false);
+						$success = $meta->set('timeline', $termId);
 					}
 				}
 			}
@@ -336,7 +327,7 @@
 			if ($lastKey === $index) {
 				$latestTimestamp = strtotime($post->post_date);
 			}
-
+			$meta->save();
 			$previousPost = $post;
 		}
 
@@ -443,7 +434,7 @@
 	protected function checkSharedFields(array $fields): void
 	{
 		foreach ($fields as $parentID => $shared) {
-			$meta = new MetaManager($parentID, 'post');
+			$meta = Meta::forPost($parentID);
 			$values = $meta->getAll($shared);
 
 			$children = get_children([
@@ -457,8 +448,9 @@
 			}
 
 			foreach ($children as $child) {
-				$childMeta = new MetaManager($child, 'post');
-				$result = $childMeta->setAll($values, false);
+				$childMeta = Meta::forPost($child);
+				$childMeta->setAll($values, false);
+				$result = $childMeta->save();
 			}
 		}
 	}

--
Gitblit v1.10.0