From e9967fa22781d922ba4eb8fb44fe72d200ac4b14 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 10 Nov 2025 21:04:10 +0000
Subject: [PATCH] =IconsManager.php update

---
 inc/managers/UserTermsManager.php |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/inc/managers/UserTermsManager.php b/inc/managers/UserTermsManager.php
index 5eb29f2..b900dff 100644
--- a/inc/managers/UserTermsManager.php
+++ b/inc/managers/UserTermsManager.php
@@ -64,6 +64,10 @@
         if (wp_is_post_autosave($post_id) || wp_is_post_revision($post_id)) {
             return;
         }
+		// SAFETY: Skip attachments and other non-content post types
+		if (in_array($post->post_type, jvbIgnoredPostTypes())) {
+			return;
+		}
 
         // Skip non-custom post types
         $post_type = get_post_type($post);
@@ -409,12 +413,13 @@
         $this->wpdb->query("TRUNCATE TABLE {$this->table_name}");
 
         // Get all users with posts
-        $users = $this->wpdb->get_col("
-            SELECT DISTINCT post_author
-            FROM {$this->wpdb->posts}
-            WHERE post_status = 'publish'
-            AND post_type LIKE '" . BASE . "%'
-        ");
+		$users = $this->wpdb->get_col($this->wpdb->prepare(
+			"SELECT DISTINCT post_author
+			FROM {$this->wpdb->posts}
+			WHERE post_status = 'publish'
+			AND post_type LIKE %s",
+			$this->wpdb->esc_like(BASE) . '%'
+		));
 
         JVB()->queue()->queueOperation(
             'rebuild_user_term_index',
@@ -490,14 +495,14 @@
                 $this->clearUserCache($user_id);
 
                 // Get all the user's published posts
-                $posts = $this->wpdb->get_col($this->wpdb->prepare(
-                    "SELECT ID FROM {$this->wpdb->posts}
-            WHERE post_author = %d
-            AND post_status = 'publish'
-            AND post_type LIKE '%s'",
-                    $user_id,
-					BASE
-                ));
+				$posts = $this->wpdb->get_col($this->wpdb->prepare(
+					"SELECT ID FROM {$this->wpdb->posts}
+					WHERE post_author = %d
+					AND post_status = 'publish'
+					AND post_type LIKE %s",
+					$user_id,
+					$this->wpdb->esc_like(BASE) . '%'
+				));
 
                 $processed_terms = 0;
 

--
Gitblit v1.10.0