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.
This commit is contained in:
frytimo
2026-05-22 22:43:54 +00:00
committed by GitHub
parent 20f415fc4a
commit 4597798904
+6
View File
@@ -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;