From a9654f00c8fbc9934289d761843ddd071025013f Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 28 Aug 2026 17:20:28 +0000
Subject: [PATCH] =PHPStorm Code Inspection: fixed class reference errors (from getting rid of JVB() and replacing with direct class::getInstance; as well as general code sniffing, etc
---
inc/managers/queue/executors/ContentExecutor.php | 54 ++++++++++++++++++++++++------------------------------
1 files changed, 24 insertions(+), 30 deletions(-)
diff --git a/inc/managers/queue/executors/ContentExecutor.php b/inc/managers/queue/executors/ContentExecutor.php
index 3d5ef56..7dff909 100644
--- a/inc/managers/queue/executors/ContentExecutor.php
+++ b/inc/managers/queue/executors/ContentExecutor.php
@@ -1,10 +1,14 @@
<?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\managers\Errors;
+use JVBase\managers\Roles;
use JVBase\meta\Meta;
use JVBase\registrar\Registrar;
use Exception;
+use WP_Post;
if (!defined('ABSPATH')) {
exit;
@@ -22,8 +26,6 @@
];
private int $userId;
- private string $postType;
- private array $fields = [];
public function execute(Operation $operation, Progress $progress): Result
{
@@ -43,7 +45,7 @@
};
} catch (Exception $e) {
- JVB()->error()->log(
+ Errors::getInstance()->log(
'[ContentExecutor]:execute',
$e->getMessage(),
[
@@ -67,7 +69,7 @@
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: 'success',
@@ -125,7 +127,7 @@
// Send notification
// if (jvbSiteHasNotifications()) {
-// JVB()->notification()->addNotification(
+// NotificationManager::getInstance()->addNotification(
// $this->userId,
// 'content_update_complete',
// null,
@@ -134,8 +136,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(
@@ -249,12 +251,7 @@
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 [];
@@ -348,6 +345,10 @@
}
}
}
+ $isUpdate = $meta->get('is_update');
+ if (!(bool) $isUpdate) {
+ $meta->set('number', $index);
+ }
if ($lastKey === $index) {
$latestTimestamp = strtotime($post->post_date);
@@ -361,7 +362,7 @@
}
}
- private function calculateTimeline(\WP_POST $previous, \WP_POST $current): ?string
+ private function calculateTimeline(WP_POST $previous, WP_POST $current): ?string
{
$previousDate = strtotime($previous->post_date);
$currentDate = strtotime($current->post_date);
@@ -379,8 +380,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 +393,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 +417,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) {
@@ -461,11 +462,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;
@@ -484,11 +481,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') {
@@ -604,7 +598,7 @@
{
error_log('Handling term '.$ID.' with data: '.print_r($data, true));
//Existing term update
- if ($registrar->hasFeature('is_ownable') && (!JVB()->roles()->isOwner($this->userId, $ID) && !JVB()->roles()->isManager($this->userId, $ID))) {
+ if ($registrar->hasFeature('is_ownable') && (!Roles::getInstance()()->isOwner($this->userId, $ID) && !Roles::getInstance()()->isManager($this->userId, $ID))) {
error_log('Term is ownable. User does not own this term.');
$progress->failItem($ID, 'No permission to modify this term');
$results['errors'][$ID] = 'No permission';
--
Gitblit v1.10.0