From a6413da67a4579866f0fd0323ddb23a7b6b9654a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 18 Sep 2026 17:00:53 +0000
Subject: [PATCH] =Cleaning up the Integrations setup a bit, started the Helcim integration work too

---
 inc/managers/queue/executors/ContentExecutor.php |   40 +++++++++++++++++++++-------------------
 1 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/inc/managers/queue/executors/ContentExecutor.php b/inc/managers/queue/executors/ContentExecutor.php
index bc6ee4b..5d07be0 100644
--- a/inc/managers/queue/executors/ContentExecutor.php
+++ b/inc/managers/queue/executors/ContentExecutor.php
@@ -1,11 +1,15 @@
 <?php
 namespace JVBase\managers\queue\executors;
 
-use JVBase\managers\queue\{Executor, Operation, Progress, Result, Storage};
+use DateTime;
+use JVBase\managers\queue\{Executor, Operation, Progress, Result};
+use JVBase\inc\managers\ErrorHelper;
 use JVBase\managers\Errors;
+use JVBase\managers\Roles;
 use JVBase\meta\Meta;
 use JVBase\registrar\Registrar;
 use Exception;
+use WP_Post;
 
 if (!defined('ABSPATH')) {
 	exit;
@@ -17,14 +21,13 @@
  */
 final class ContentExecutor implements Executor
 {
+	use ErrorHelper;
 	private const HANDLED_TYPES = [
 		'content_update',
 //		'batch_creation',
 	];
 
 	private int $userId;
-	private string $postType;
-	private array $fields = [];
 
 	public function execute(Operation $operation, Progress $progress): Result
 	{
@@ -44,15 +47,11 @@
 			};
 
 		} catch (Exception $e) {
-			Errors::getInstance()->log(
-				'[ContentExecutor]:execute',
-				$e->getMessage(),
-				[
-					'operation_id'   => $operation->id,
-					'operation_type' => $operation->type,
-					'user_id'        => $operation->userId,
-				]
-			);
+			$this->logError($e->getMessage(), 'execute', [
+				'operation_id'   => $operation->id,
+				'operation_type' => $operation->type,
+				'user_id'        => $operation->userId,
+			]);
 
 			return new Result(
 				outcome: 'failed',
@@ -135,8 +134,8 @@
 //		}
 
 		$outcome = 'success';
-		if (!empty($errors)) {
-			$outcome = count($errors) === count($posts) ? 'failed' : 'partial';
+		if (!empty($results['errors'])) {
+			$outcome = count($results['success']) === count($posts) ? 'failed' : 'partial';
 		}
 
 		return new Result(
@@ -361,7 +360,10 @@
 		}
 	}
 
-	private function calculateTimeline(\WP_POST $previous, \WP_POST $current): ?string
+	/**
+	 * @throws \DateMalformedStringException
+	 */
+	private function calculateTimeline(WP_POST $previous, WP_POST $current): ?string
 	{
 		$previousDate = strtotime($previous->post_date);
 		$currentDate = strtotime($current->post_date);
@@ -379,8 +381,8 @@
 			return $weeks === 1 ? '1 Week' : $weeks . ' Weeks';
 		}
 
-		$previousDateTime = new \DateTime($previous->post_date);
-		$currentDateTime = new \DateTime($current->post_date);
+		$previousDateTime = new DateTime($previous->post_date);
+		$currentDateTime = new DateTime($current->post_date);
 
 		$interval = $previousDateTime->diff($currentDateTime);
 		$months = ($interval->y * 12) + $interval->m;
@@ -392,7 +394,7 @@
 		return ($months === 1) ? '1 Month' : $months . ' Months';
 	}
 
-	private function swapTimelineParent(\WP_Post $oldParent, \WP_Post $newParent, array $allPosts): void
+	private function swapTimelineParent(WP_Post $oldParent, WP_Post $newParent, array $allPosts): void
 	{
 		// Swap titles and content
 		$originalTitle = $oldParent->post_title;
@@ -416,7 +418,7 @@
 		]);
 
 		// Clear timeline taxonomy from new parent
-		wp_set_object_terms($newParent->ID, [], BASE . 'timeline', false);
+		wp_set_object_terms($newParent->ID, [], BASE . 'timeline');
 
 		// Update all other posts to new parent
 		foreach ($allPosts as $index => $post) {

--
Gitblit v1.10.0