Skip to content
Snippets Groups Projects
Commit d35f1517 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #313156 by Crell: convert bootstrap.inc to DBTNG and resurrected a kitten.

parent 87567f89
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
...@@ -445,7 +445,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { ...@@ -445,7 +445,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
// the database. This is required because this function is called both // the database. This is required because this function is called both
// before we have a database connection (i.e. during installation) and // before we have a database connection (i.e. during installation) and
// when a database connection fails. // when a database connection fails.
elseif (db_is_active() && (($file = db_result(db_query("SELECT filename FROM {system} WHERE name = '%s' AND type = '%s'", $name, $type))) && file_exists($file))) { elseif (db_is_active() && (($file = db_query("SELECT filename FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField()) && file_exists($file))) {
$files[$type][$name] = $file; $files[$type][$name] = $file;
} }
else { else {
...@@ -481,10 +481,7 @@ function variable_init($conf = array()) { ...@@ -481,10 +481,7 @@ function variable_init($conf = array()) {
$variables = $cached->data; $variables = $cached->data;
} }
else { else {
$result = db_query('SELECT * FROM {variable}'); $variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed());
while ($variable = db_fetch_object($result)) {
$variables[$variable->name] = unserialize($variable->value);
}
cache_set('variables', $variables); cache_set('variables', $variables);
} }
...@@ -539,7 +536,9 @@ function variable_set($name, $value) { ...@@ -539,7 +536,9 @@ function variable_set($name, $value) {
function variable_del($name) { function variable_del($name) {
global $conf; global $conf;
db_query("DELETE FROM {variable} WHERE name = '%s'", $name); db_delete('variable')
->condition('name', $name)
->execute();
cache_clear_all('variables', 'cache'); cache_clear_all('variables', 'cache');
unset($conf[$name]); unset($conf[$name]);
...@@ -924,8 +923,7 @@ function drupal_is_denied($ip) { ...@@ -924,8 +923,7 @@ function drupal_is_denied($ip) {
return in_array($ip, $blocked_ips); return in_array($ip, $blocked_ips);
} }
else { else {
$sql = "SELECT 1 FROM {blocked_ips} WHERE ip = '%s'"; return (bool)db_query("SELECT 1 FROM {blocked_ips} WHERE ip = :ip", array(':ip' => $ip))->fetchField();
return (bool) db_result(db_query($sql, $ip));
} }
} }
...@@ -1142,10 +1140,7 @@ function language_list($field = 'language', $reset = FALSE) { ...@@ -1142,10 +1140,7 @@ function language_list($field = 'language', $reset = FALSE) {
// Init language list // Init language list
if (!isset($languages)) { if (!isset($languages)) {
if (variable_get('language_count', 1) > 1 || module_exists('locale')) { if (variable_get('language_count', 1) > 1 || module_exists('locale')) {
$result = db_query('SELECT * FROM {languages} ORDER BY weight ASC, name ASC'); $languages['language'] = db_query('SELECT * FROM {languages} ORDER BY weight ASC, name ASC')->fetchAllAssoc('language');
while ($row = db_fetch_object($result)) {
$languages['language'][$row->language] = $row;
}
} }
else { else {
// No locale module, so use the default language only. // No locale module, so use the default language only.
...@@ -1340,7 +1335,11 @@ function drupal_function_exists($function) { ...@@ -1340,7 +1335,11 @@ function drupal_function_exists($function) {
return TRUE; return TRUE;
} }
$file = db_result(db_query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(':name' => $function, ':type' => 'function'))); $file = db_query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(
':name' => $function,
':type' => 'function',
))
->fetchField();
if ($file) { if ($file) {
require_once DRUPAL_ROOT . '/' . $file; require_once DRUPAL_ROOT . '/' . $file;
$checked[$function] = function_exists($function); $checked[$function] = function_exists($function);
...@@ -1388,7 +1387,11 @@ function drupal_autoload_class($class) { ...@@ -1388,7 +1387,11 @@ function drupal_autoload_class($class) {
* Helper for registry_check_{interface, class}. * Helper for registry_check_{interface, class}.
*/ */
function _registry_check_code($type, $name) { function _registry_check_code($type, $name) {
$file = db_result(db_query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))); $file = db_query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(
':name' => $name,
':type' => $type,
))
->fetchField();
if ($file) { if ($file) {
require_once DRUPAL_ROOT . '/' . $file; require_once DRUPAL_ROOT . '/' . $file;
registry_mark_code($type, $name); registry_mark_code($type, $name);
...@@ -1467,15 +1470,21 @@ function registry_cache_path_files() { ...@@ -1467,15 +1470,21 @@ function registry_cache_path_files() {
$files = array(); $files = array();
$type_sql = array(); $type_sql = array();
$params = array(); $params = array();
$select = db_select('registry')->distinct();
$select->addField('registry', 'filename');
// This creates a series of 2-clause AND conditions that are then ORed together.
$ors = db_or();
foreach ($used_code as $type => $names) { foreach ($used_code as $type => $names) {
$type_sql[] = "(name IN (" . db_placeholders($names, 'varchar') . ") AND type = '%s')"; $and = db_and()
$params = array_merge($params, $names); ->condition('name', $names, 'IN')
$params[] = $type; ->condition('type', $type);
} $ors->condition($and);
$res = db_query("SELECT DISTINCT filename FROM {registry} WHERE " . implode(' OR ', $type_sql), $params);
while ($row = db_fetch_object($res)) {
$files[] = $row->filename;
} }
$select->condition($ors);
$files = $select->execute()->fetchCol();
if ($files) { if ($files) {
sort($files); sort($files);
// Only write this to cache if the file list we are going to cache // Only write this to cache if the file list we are going to cache
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment