From 45977989040ed8dc43f340a085675199add3a9b0 Mon Sep 17 00:00:00 2001 From: frytimo Date: Fri, 22 May 2026 22:43:54 +0000 Subject: [PATCH] Check table prefix on table_exists (#7974) * Check table prefix on table_exists * Enhance table_exists method prefix handling Updated table_exists method to check if TABLE_PREFIX is not empty before adding it. --- resources/classes/database.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/classes/database.php b/resources/classes/database.php index 2dfe9f471..cf185fd8b 100644 --- a/resources/classes/database.php +++ b/resources/classes/database.php @@ -1031,6 +1031,12 @@ class database { * @depends connect() */ public function table_exists(string $table_name) { + // Only add prefix if it's not already prefixed AND prefix is not empty + if (!empty(self::TABLE_PREFIX) && !str_starts_with($table_name, self::TABLE_PREFIX)) { + $table_name = self::TABLE_PREFIX . $table_name; + } + + // Check to see if the table was sanitized if (self::sanitize($table_name) != $table_name) { trigger_error('Table Name must be sanitized', E_USER_WARNING); return false;