From a9b3b28d001941921aa70d37fdc87c758a163a44 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 05 Jun 2026 16:47:03 +0000
Subject: [PATCH] =Some hefty changes to FeedBlock. Transitioning to loading first page in php to save on extra requests. Got a bit to do yet, but I have to work on Northeh for a bit here.
---
inc/managers/queue/executors/ContentExecutor.php | 74 ++++++++++++++++++++++++++-----------
1 files changed, 52 insertions(+), 22 deletions(-)
diff --git a/inc/managers/queue/executors/ContentExecutor.php b/inc/managers/queue/executors/ContentExecutor.php
index 4fbdba2..6b6aa1a 100644
--- a/inc/managers/queue/executors/ContentExecutor.php
+++ b/inc/managers/queue/executors/ContentExecutor.php
@@ -67,10 +67,10 @@
private function processContentUpdate(Operation $operation, array $data, Progress $progress): Result
{
$posts = $data['posts'] ?? [];
-
+ error_log('Processing Content Update: '.print_r($posts, true));
if (empty($posts)) {
return new Result(
- outcome: 'failed',
+ outcome: 'success',
result: ['message' => 'No posts to update']
);
}
@@ -242,23 +242,17 @@
}
}
}
- protected function maybeReorderTimeline(int $parentID):void
+ protected function getTimelinePosts(int $parentID):array
{
-// clean_post_cache($parentID);
$parent = get_post($parentID);
if (!$parent) {
- return;
+ return [];
}
- $children = get_children([
- 'post_parent' => $parentID,
- 'posts_per_page' => -1,
- 'post_status' => ['publish', 'draft'],
- ]);
-
+ $children = jvbTimelinePoints($parentID, $parent->post_type, ['publish', 'draft']);
if (count($children) === 0) {
- return;
+ return [];
}
$allPosts = array_merge([$parent], $children);
@@ -268,6 +262,22 @@
return strtotime($a->post_date) <=> strtotime($b->post_date);
});
+ return $allPosts;
+ }
+ protected function maybeReorderTimeline(int $parentID):void
+ {
+// clean_post_cache($parentID);
+ $parent = get_post($parentID);
+ if (!$parent) {
+ return;
+ }
+
+ $allPosts = $this->getTimelinePosts($parentID);
+ if (empty($allPosts)) {
+ return;
+ }
+
+
// Check if order changed
$needsReorder = false;
@@ -333,6 +343,10 @@
}
}
}
+ $isUpdate = $meta->get('is_update');
+ if (!(bool) $isUpdate) {
+ $meta->set('number', $index);
+ }
if ($lastKey === $index) {
$latestTimestamp = strtotime($post->post_date);
@@ -446,11 +460,7 @@
$meta = Meta::forPost($parentID);
$values = $meta->getAll($shared);
- $children = get_children([
- 'post_parent' => $parentID,
- 'posts_per_page' => -1,
- 'fields' => 'ids',
- ]);
+ $children = jvbTimelinePoints($parentID, get_post_type($parentID), ['any']);
if (empty($children)) {
continue;
@@ -469,11 +479,8 @@
});
foreach ($updates as $parentID => $status) {
- $children = get_children([
- 'post_parent' => $parentID,
- 'posts_per_page' => -1,
- 'fields' => 'ids'
- ]);
+ $children = jvbTimelinePoints($parentID, get_post_type($parentID), ['any']);
+
if (!empty($children)) {
foreach($children as $child) {
if ($status === 'trash') {
@@ -503,6 +510,7 @@
'post_title' => $data['post_title'] ?? apply_filters('jvbDefaultTitle', '', $registrar->getSlug()),
'post_status' => $data['status'] ?? 'draft',
]);
+ error_log('Created new post: '.print_r($newId, true));
if (!$newId || is_wp_error($newId)) {
$results['errors'][$ID] = 'Could not create post';
@@ -540,6 +548,28 @@
return !array_key_exists('for_all', $field) || !$field['for_all'];
}));
+
+ if (array_key_exists('timeline_gallery', $data)) {
+ //This should only happen if we delete an image from the gallery
+ $changes = explode(',', $data['timeline_gallery']);
+ $timelinePosts = $this->getTimelinePosts($parentId);
+ if (!empty($timelinePosts)) {
+ $posts = array_map(function($item) { return $item->ID; }, $timelinePosts);
+ $changed = false;
+ foreach ($posts as $tID) {
+ if (!in_array($tID, $changes)) {
+ $changed = true;
+ wp_delete_post($tID, true);
+ }
+ }
+ if ($changed) {
+ $results['timelineParents'][] = $parentId;
+ }
+ }
+
+ }
+
+
if (array_key_exists('post_date', $data) && !in_array($parentId, $results['timelineParents'])) {
$results['timelineParents'][] = $parentId;
}
--
Gitblit v1.10.0