Jake Vanderwerf
2026-09-14 7935d26cd16a4f8f69a59a44e27a7263b60e54bf
inc/managers/TaxonomyRelationships.php
@@ -2,6 +2,8 @@
namespace JVBase\managers;
use Exception;
use JVBase\Instance;
use JVBase\managers\queue\Queue;
use WP_Error;
use WP_Post;
use WP_Query;
@@ -12,15 +14,15 @@
class TaxonomyRelationships
{
   use Instance;
    protected Cache $cache;
   protected CustomTable $relationships;
    public function __construct()
    private function __construct()
    {
      $this->defineTables();
        $this->cache = Cache::for('term_relationship', WEEK_IN_SECONDS);
      $this->cache->connect('terms');
        $this->cache = Cache::for('term_relationship', 'term', WEEK_IN_SECONDS);
        // Ensure the table exists
//        $this->create_table_if_not_exists();
@@ -78,14 +80,12 @@
        add_filter(BASE.'handle_bulk_operation', [$this, 'processOperation'], 10, 3);
    }
    // Update relationships for a post
    /**
     * @param int $post_id
     *
     * @return void
     */
   /**
    * Update relationships for a post
    * @param int $post_id
    * @param WP_Post $post
    * @return void
    */
    public function updatePostRelationships(int $post_id, WP_Post $post):void
    {
      // Skip autosaves and revisions
@@ -196,7 +196,7 @@
    {
        $term_posts = $this->cache->remember(
         $this->cache->generateKey(['term' => $term_id, 'taxonomy' => $taxonomy]),
         ['id' => $term_id, 'taxonomy' => $taxonomy],
         function () use ($term_id, $taxonomy) {
            global $wpdb;
            return $wpdb->get_col($wpdb->prepare(
@@ -211,7 +211,7 @@
        $related_term_posts = $this->cache->remember(
         $this->cache->generateKey(['term' => $related_term_id, 'taxonomy' => $related_taxonomy]),
         ['id' => $related_term_id, 'taxonomy' => $related_taxonomy],
         function () use($related_term_id, $related_taxonomy) {
            global $wpdb;
            return $wpdb->get_col($wpdb->prepare(
@@ -292,7 +292,7 @@
        // Queue the operation
        $queue = JVB()->queue();
        $queue = Queue::getInstance();
        $queue->queueOperation(
            'taxonomy_relationships',