mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
NOBUG: Normalise generated param names so we can safely use sql_xxx() helper functions everywhere.
This commit is contained in:
parent
cea304d432
commit
cd6d352396
1 changed files with 4 additions and 3 deletions
|
@ -485,9 +485,10 @@ abstract class moodle_database {
|
||||||
$where[] = "$key IS NULL";
|
$where[] = "$key IS NULL";
|
||||||
} else {
|
} else {
|
||||||
if ($allowed_types & SQL_PARAMS_NAMED) {
|
if ($allowed_types & SQL_PARAMS_NAMED) {
|
||||||
$where[] = "$key = :$key";
|
$normkey = trim(preg_replace('/[^a-zA-Z0-9-_]/', '_', $key), '-_'); // Need to normalize key names
|
||||||
$params[$key] = $value;
|
$where[] = "$key = :$normkey"; // because they can contain, originally,
|
||||||
} else {
|
$params[$normkey] = $value; // spaces and other forbiden chars when
|
||||||
|
} else { // using sql_xxx() functions and friends.
|
||||||
$where[] = "$key = ?";
|
$where[] = "$key = ?";
|
||||||
$params[] = $value;
|
$params[] = $value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue