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:
@@ -1031,6 +1031,12 @@ class database {
|
|||||||
* @depends connect()
|
* @depends connect()
|
||||||
*/
|
*/
|
||||||
public function table_exists(string $table_name) {
|
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) {
|
if (self::sanitize($table_name) != $table_name) {
|
||||||
trigger_error('Table Name must be sanitized', E_USER_WARNING);
|
trigger_error('Table Name must be sanitized', E_USER_WARNING);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user