Skip to content
Snippets Groups Projects
Commit ca9293b3 authored by Steven Wittens's avatar Steven Wittens
Browse files

#54981: calls to db_lock_table in bootstrap.inc do not use db_prefix

parent b1762700
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -315,6 +315,15 @@ function db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid', $
return $query;
}
/**
* Restrict a dynamic tablename to safe characters.
*
* Only keeps alphanumeric and underscores.
*/
function db_escape_table($string) {
return preg_replace('/[^A-Za-z0-9_]+/', '', $string);
}
/**
* @} End of "defgroup database".
*/
......
......@@ -353,7 +353,7 @@ function db_escape_string($text) {
* Lock a table.
*/
function db_lock_table($table) {
db_query('LOCK TABLES {%s} WRITE', $table);
db_query('LOCK TABLES {'. db_escape_table($table) .'} WRITE');
}
/**
......
......@@ -355,7 +355,7 @@ function db_escape_string($text) {
* Lock a table.
*/
function db_lock_table($table) {
db_query('LOCK TABLES {%s} WRITE', $table);
db_query('LOCK TABLES {'. db_escape_table($table) .'} WRITE');
}
/**
......
......@@ -331,7 +331,7 @@ function db_escape_string($text) {
* This function automatically starts a transaction.
*/
function db_lock_table($table) {
db_query('BEGIN; LOCK TABLE {%s} IN EXCLUSIVE MODE', $table);
db_query('BEGIN; LOCK TABLE {'. db_escape_table($table) .'} IN EXCLUSIVE MODE');
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment