? sites/default/files ? sites/default/modules ? sites/default/settings.php Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.133 diff -u -p -r1.133 install.php --- install.php 20 Sep 2008 20:22:23 -0000 1.133 +++ install.php 28 Sep 2008 16:44:05 -0000 @@ -160,7 +160,7 @@ function install_main() { function install_verify_drupal() { // Read the variable manually using the @ so we don't trigger an error if it fails. try { - if ($result = db_query("SELECT value FROM {variable} WHERE name = '%s'", 'install_task')) { + if ($result = db_query("SELECT [value] FROM [{variable}] WHERE [name] = %s", 'install_task')) { return unserialize(db_result($result)); } } Index: update.php =================================================================== RCS file: /cvs/drupal/drupal/update.php,v retrieving revision 1.260 diff -u -p -r1.260 update.php --- update.php 20 Sep 2008 20:22:23 -0000 1.260 +++ update.php 28 Sep 2008 16:44:05 -0000 @@ -60,26 +60,26 @@ function db_add_column(&$ret, $table, $c if (array_key_exists('default', $attributes)) { if (is_null($attributes['default'])) { $default_val = 'NULL'; - $default = 'default NULL'; + $default = 'DEFAULT NULL'; } elseif ($attributes['default'] === FALSE) { $default = ''; } else { $default_val = "$attributes[default]"; - $default = "default $attributes[default]"; + $default = "DEFAULT $attributes[default]"; } } - $ret[] = update_sql("ALTER TABLE {" . $table . "} ADD $column $type"); + $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ADD [$column] $type"); if (!empty($default)) { - $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column SET $default"); + $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ALTER [$column] SET $default"); } if (!empty($not_null)) { if (!empty($default)) { - $ret[] = update_sql("UPDATE {" . $table . "} SET $column = $default_val"); + $ret[] = update_sql("UPDATE [{" . $table . "}] SET [$column] = $default_val"); } - $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column SET NOT NULL"); + $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ALTER [$column] SET NOT NULL"); } } @@ -116,27 +116,27 @@ function db_change_column(&$ret, $table, if (array_key_exists('default', $attributes)) { if (is_null($attributes['default'])) { $default_val = 'NULL'; - $default = 'default NULL'; + $default = 'DEFAULT NULL'; } elseif ($attributes['default'] === FALSE) { $default = ''; } else { $default_val = "$attributes[default]"; - $default = "default $attributes[default]"; + $default = "DEFAULT $attributes[default]"; } } - $ret[] = update_sql("ALTER TABLE {" . $table . "} RENAME $column TO " . $column . "_old"); - $ret[] = update_sql("ALTER TABLE {" . $table . "} ADD $column_new $type"); - $ret[] = update_sql("UPDATE {" . $table . "} SET $column_new = " . $column . "_old"); + $ret[] = update_sql("ALTER TABLE [{" . $table . "}] RENAME [$column] TO [" . $column . "_old]"); + $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ADD [$column_new] $type"); + $ret[] = update_sql("UPDATE [{" . $table . "}] SET [$column_new] = [" . $column . "_old]"); if ($default) { - $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column_new SET $default"); + $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ALTER [$column_new] SET $default"); } if ($not_null) { - $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column_new SET NOT NULL"); + $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ALTER [$column_new] SET NOT NULL"); } - $ret[] = update_sql("ALTER TABLE {" . $table . "} DROP " . $column . "_old"); + $ret[] = update_sql("ALTER TABLE [{" . $table . "}] DROP [" . $column . "_old]"); } /** @@ -477,14 +477,14 @@ function update_create_batch_table() { function update_fix_compatibility() { $ret = array(); $incompatible = array(); - $query = db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')"); + $query = db_query("SELECT [name], [type], [status] FROM [{system}] WHERE [status] = 1 AND [type] IN ('module', 'theme')"); while ($result = db_fetch_object($query)) { if (update_check_incompatibility($result->name, $result->type)) { $incompatible[] = $result->name; } } if (!empty($incompatible)) { - $ret[] = update_sql("UPDATE {system} SET status = 0 WHERE name IN ('" . implode("','", $incompatible) . "')"); + $ret[] = update_sql("UPDATE [{system}] SET [status] = 0 WHERE [name] IN ('" . implode("', '", $incompatible) . "')"); } return $ret; } Index: includes/actions.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/actions.inc,v retrieving revision 1.18 diff -u -p -r1.18 actions.inc --- includes/actions.inc 26 Sep 2008 16:13:37 -0000 1.18 +++ includes/actions.inc 28 Sep 2008 16:44:05 -0000 @@ -66,7 +66,7 @@ function actions_do($action_ids, $object $where_clause = implode(' ', $where); // Strip off leading 'OR '. $where_clause = '(' . strstr($where_clause, " ") . ')'; - $result_db = db_query('SELECT * FROM {actions} WHERE ' . $where_clause, $where_values); + $result_db = db_query('SELECT * FROM [{actions}] WHERE ' . $where_clause, $where_values); while ($action = db_fetch_object($result_db)) { $actions[$action->aid] = $action->parameters ? unserialize($action->parameters) : array(); $actions[$action->aid]['callback'] = $action->callback; @@ -91,7 +91,7 @@ function actions_do($action_ids, $object else { // If it's a configurable action, retrieve stored parameters. if (is_numeric($action_ids)) { - $action = db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = '%s'", $action_ids)); + $action = db_fetch_object(db_query("SELECT * FROM [{actions}] WHERE [aid] = %s", $action_ids)); $function = $action->callback; $context = array_merge($context, unserialize($action->parameters)); $result[$action_ids] = $function($object, $context, $a1, $a2); @@ -175,7 +175,7 @@ function actions_list($reset = FALSE) { */ function actions_get_all_actions() { $actions = array(); - $result = db_query("SELECT * FROM {actions}"); + $result = db_query("SELECT * FROM [{actions}]"); while ($action = db_fetch_object($result)) { $actions[$action->aid] = array( 'callback' => $action->callback, @@ -236,7 +236,7 @@ function actions_function_lookup($hash) } // Must be an instance; must check database. - $aid = db_result(db_query("SELECT aid FROM {actions} WHERE MD5(aid) = '%s' AND parameters <> ''", $hash)); + $aid = db_result(db_query("SELECT [aid] FROM [{actions}] WHERE MD5([aid]) = %s AND [parameters] <> %s", $hash, '')); return $aid; } @@ -253,7 +253,7 @@ function actions_synchronize($actions_in $actions_in_code = actions_list(TRUE); } $actions_in_db = array(); - $result = db_query("SELECT * FROM {actions} WHERE parameters = ''"); + $result = db_query("SELECT * FROM [{actions}] WHERE [parameters] = %s", ''); while ($action = db_fetch_object($result)) { $actions_in_db[$action->callback] = array('aid' => $action->aid, 'description' => $action->description); } @@ -269,7 +269,7 @@ function actions_synchronize($actions_in } else { // This is a new singleton that we don't have an aid for; assign one. - db_query("INSERT INTO {actions} (aid, type, callback, parameters, description) VALUES ('%s', '%s', '%s', '%s', '%s')", $callback, $array['type'], $callback, '', $array['description']); + db_query("INSERT INTO [{actions}] ([aid], [type], [callback], [parameters], [description]) VALUES (%s, %s, %s, %s, %s)", $callback, $array['type'], $callback, '', $array['description']); watchdog('actions', "Action '%action' added.", array('%action' => filter_xss_admin($array['description']))); } } @@ -280,7 +280,7 @@ function actions_synchronize($actions_in $orphaned = array_keys($actions_in_db); if ($delete_orphans) { - $results = db_query("SELECT a.aid, a.description FROM {actions} a WHERE callback IN (" . db_placeholders($orphaned, 'varchar') . ")", $orphaned); + $results = db_query("SELECT a.[aid], a.[description] FROM [{actions}] a WHERE [callback] IN (" . db_placeholders($orphaned, 'varchar') . ")", $orphaned); while ($action = db_fetch_object($results)) { actions_delete($action->aid); watchdog('actions', "Removed orphaned action '%action' from database.", array('%action' => filter_xss_admin($action->description))); @@ -315,15 +315,15 @@ function actions_synchronize($actions_in function actions_save($function, $type, $params, $desc, $aid = NULL) { $serialized = serialize($params); if ($aid) { - db_query("UPDATE {actions} SET callback = '%s', type = '%s', parameters = '%s', description = '%s' WHERE aid = '%s'", $function, $type, $serialized, $desc, $aid); + db_query("UPDATE [{actions}] SET [callback] = %s, [type] = %s, [parameters] = %s, [description] = %s WHERE [aid] = %s", $function, $type, $serialized, $desc, $aid); watchdog('actions', 'Action %action saved.', array('%action' => $desc)); } else { // aid is the callback for singleton actions so we need to keep a // separate table for numeric aids. - db_query('INSERT INTO {actions_aid} VALUES (default)'); + db_query('INSERT INTO [{actions_aid}] VALUES (DEFAULT)'); $aid = db_last_insert_id('actions_aid', 'aid'); - db_query("INSERT INTO {actions} (aid, callback, type, parameters, description) VALUES ('%s', '%s', '%s', '%s', '%s')", $aid, $function, $type, $serialized, $desc); + db_query("INSERT INTO [{actions}] ([aid], [callback], [type], [parameters], [description]) VALUES (%s, %s, %s, %s, %s)", $aid, $function, $type, $serialized, $desc); watchdog('actions', 'Action %action created.', array('%action' => $desc)); } @@ -340,7 +340,7 @@ function actions_save($function, $type, * The appropriate action row from the database as an object. */ function actions_load($aid) { - return db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = '%s'", $aid)); + return db_fetch_object(db_query("SELECT * FROM [{actions}] WHERE [aid] = %s", $aid)); } /** @@ -350,6 +350,6 @@ function actions_load($aid) { * integer The ID of the action to delete. */ function actions_delete($aid) { - db_query("DELETE FROM {actions} WHERE aid = '%s'", $aid); + db_query("DELETE FROM [{actions}] WHERE [aid] = %s", $aid); module_invoke_all('actions_delete', $aid); } Index: includes/batch.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/batch.inc,v retrieving revision 1.22 diff -u -p -r1.22 batch.inc --- includes/batch.inc 26 Sep 2008 23:30:20 -0000 1.22 +++ includes/batch.inc 28 Sep 2008 16:44:05 -0000 @@ -16,7 +16,7 @@ function _batch_page() { } // Retrieve the current state of batch from db. - $batch = db_query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", array( + $batch = db_query("SELECT [batch] FROM [{batch}] WHERE [bid] = :bid AND [token] = :token", array( ':bid' => $_REQUEST['id'], ':token' => drupal_get_token($_REQUEST['id'])) )->fetchField(); Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.228 diff -u -p -r1.228 bootstrap.inc --- includes/bootstrap.inc 20 Sep 2008 20:22:23 -0000 1.228 +++ includes/bootstrap.inc 28 Sep 2008 16:44:05 -0000 @@ -445,7 +445,7 @@ function drupal_get_filename($type, $nam // the database. This is required because this function is called both // before we have a database connection (i.e. during installation) and // 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_result(db_query("SELECT [filename] FROM [{system}] WHERE [name] = %s AND [type] = %s", $name, $type))) && file_exists($file))) { $files[$type][$name] = $file; } else { @@ -481,7 +481,7 @@ function variable_init($conf = array()) $variables = $cached->data; } else { - $result = db_query('SELECT * FROM {variable}'); + $result = db_query('SELECT * FROM [{variable}]'); while ($variable = db_fetch_object($result)) { $variables[$variable->name] = unserialize($variable->value); } @@ -539,7 +539,7 @@ function variable_set($name, $value) { function variable_del($name) { global $conf; - db_query("DELETE FROM {variable} WHERE name = '%s'", $name); + db_query("DELETE FROM [{variable}] WHERE [name] = %s", $name); cache_clear_all('variables', 'cache'); unset($conf[$name]); @@ -924,7 +924,7 @@ function drupal_is_denied($ip) { return in_array($ip, $blocked_ips); } else { - $sql = "SELECT 1 FROM {blocked_ips} WHERE ip = '%s'"; + $sql = "SELECT 1 FROM [{blocked_ips}] WHERE [ip] = %s"; return (bool) db_result(db_query($sql, $ip)); } } @@ -1142,7 +1142,7 @@ function language_list($field = 'languag // Init language list if (!isset($languages)) { if (variable_get('language_count', 1) > 1 || module_exists('locale')) { - $result = db_query('SELECT * FROM {languages} ORDER BY weight ASC, name ASC'); + $result = db_query('SELECT * FROM [{languages}] ORDER BY [weight] ASC, [name] ASC'); while ($row = db_fetch_object($result)) { $languages['language'][$row->language] = $row; } @@ -1340,7 +1340,7 @@ function drupal_function_exists($functio return TRUE; } - $file = db_result(db_query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(':name' => $function, ':type' => 'function'))); + $file = db_result(db_query("SELECT [filename] FROM [{registry}] WHERE [name] = :name AND [type] = :type", array(':name' => $function, ':type' => 'function'))); if ($file) { require_once DRUPAL_ROOT . '/' . $file; $checked[$function] = function_exists($function); @@ -1388,7 +1388,7 @@ function drupal_autoload_class($class) { * Helper for registry_check_{interface, class}. */ 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_result(db_query("SELECT [filename] FROM [{registry}] WHERE [name] = :name AND [type] = :type", array(':name' => $name, ':type' => $type))); if ($file) { require_once DRUPAL_ROOT . '/' . $file; registry_mark_code($type, $name); @@ -1468,11 +1468,11 @@ function registry_cache_path_files() { $type_sql = array(); $params = array(); foreach ($used_code as $type => $names) { - $type_sql[] = "(name IN (" . db_placeholders($names, 'varchar') . ") AND type = '%s')"; + $type_sql[] = "([name] IN (" . db_placeholders($names, 'varchar') . ") AND [type] = %s)"; $params = array_merge($params, $names); $params[] = $type; } - $res = db_query("SELECT DISTINCT filename FROM {registry} WHERE " . implode(' OR ', $type_sql), $params); + $res = db_query("SELECT DISTINCT [filename] FROM [{registry}] WHERE " . implode(' OR ', $type_sql), $params); while ($row = db_fetch_object($res)) { $files[] = $row->filename; } Index: includes/cache.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/cache.inc,v retrieving revision 1.24 diff -u -p -r1.24 cache.inc --- includes/cache.inc 17 Sep 2008 07:11:55 -0000 1.24 +++ includes/cache.inc 28 Sep 2008 16:44:05 -0000 @@ -2,15 +2,15 @@ // $Id: cache.inc,v 1.24 2008/09/17 07:11:55 dries Exp $ /** - * Return data from the persistent cache. Data may be stored as either plain - * text or as serialized data. cache_get will automatically return + * Return data from the persistent cache. Data may be stored as either plain + * text or as serialized data. cache_get will automatically return * unserialized objects and arrays. * * @param $cid * The cache ID of the data to retrieve. * @param $table - * The table $table to store the data in. Valid core values are - * 'cache_filter', 'cache_menu', 'cache_page', or 'cache' for + * The table $table to store the data in. Valid core values are + * 'cache_filter', 'cache_menu', 'cache_page', or 'cache' for * the default cache. * @return The cache or FALSE on failure. */ @@ -23,10 +23,10 @@ function cache_get($cid, $table = 'cache // Reset the variable immediately to prevent a meltdown in heavy load situations. variable_set('cache_flush', 0); // Time to flush old cache data - db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire <= %d", CACHE_PERMANENT, $cache_flush); + db_query("DELETE FROM [{" . $table . "}] WHERE [expire] <> %d AND [expire] <= %d", CACHE_PERMANENT, $cache_flush); } - $cache = db_fetch_object(db_query("SELECT data, created, headers, expire, serialized FROM {" . $table . "} WHERE cid = '%s'", $cid)); + $cache = db_fetch_object(db_query("SELECT [data], [created], [headers], [expire], [serialized] FROM [{" . $table . "}] WHERE [cid] = %s", $cid)); if (isset($cache->data)) { // If the data is permanent or we're not enforcing a minimum cache lifetime // always return the cached data. @@ -84,11 +84,11 @@ function cache_get($cid, $table = 'cache * @param $cid * The cache ID of the data to store. * @param $data - * The data to store in the cache. Complex data types will be automatically + * The data to store in the cache. Complex data types will be automatically * serialized before insertion. * Strings will be stored as plain text and not serialized. * @param $table - * The table $table to store the data in. Valid core values are + * The table $table to store the data in. Valid core values are * 'cache_filter', 'cache_menu', 'cache_page', or 'cache'. * @param $expire * One of the following values: @@ -165,13 +165,13 @@ function cache_clear_all($cid = NULL, $t else if (REQUEST_TIME > ($cache_flush + variable_get('cache_lifetime', 0))) { // Clear the cache for everyone, cache_flush_delay seconds have // passed since the first request to clear the cache. - db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, REQUEST_TIME); + db_query("DELETE FROM [{" . $table . "}] WHERE [expire] <> %d AND [expire] < %d", CACHE_PERMANENT, REQUEST_TIME); variable_set('cache_flush', 0); } } else { // No minimum cache lifetime, flush all temporary cache entries now. - db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, REQUEST_TIME); + db_query("DELETE FROM [{" . $table . "}] WHERE [expire] <> %d AND [expire] < %d", CACHE_PERMANENT, REQUEST_TIME); } } else { @@ -180,7 +180,7 @@ function cache_clear_all($cid = NULL, $t db_delete($table)->execute(); } else { - db_delete($table)->condition('cid', $cid .'%', 'LIKE')->execute(); + db_delete($table)->condition('cid', $cid . '%', 'LIKE')->execute(); } } else { Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.799 diff -u -p -r1.799 common.inc --- includes/common.inc 20 Sep 2008 20:22:23 -0000 1.799 +++ includes/common.inc 28 Sep 2008 16:44:06 -0000 @@ -648,7 +648,7 @@ function _drupal_get_last_caller($backtr // The first trace is the call itself. // It gives us the line and the file of the last call. $call = $backtrace[0]; - + // The second call give us the function where the call originated. if (isset($backtrace[1])) { if (isset($backtrace[1]['class'])) { @@ -907,7 +907,7 @@ function valid_url($url, $absolute = FAL * The name of an event. */ function flood_register_event($name) { - db_query("INSERT INTO {flood} (event, hostname, timestamp) VALUES ('%s', '%s', %d)", $name, ip_address(), REQUEST_TIME); + db_query("INSERT INTO [{flood}] ([event], [hostname], [timestamp]) VALUES (%s, %s, %d)", $name, ip_address(), REQUEST_TIME); } /** @@ -924,7 +924,7 @@ function flood_register_event($name) { * True if the user did not exceed the hourly threshold. False otherwise. */ function flood_is_allowed($name, $threshold) { - $number = db_result(db_query("SELECT COUNT(*) FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, ip_address(), REQUEST_TIME - 3600)); + $number = db_result(db_query("SELECT COUNT(*) FROM [{flood}] WHERE [event] = %s AND [hostname] = %s AND [timestamp] > %d", $name, ip_address(), REQUEST_TIME - 3600)); return ($number < $threshold ? TRUE : FALSE); } @@ -3223,12 +3223,12 @@ function drupal_schema_fields_sql($table if ($prefix) { $columns = array(); foreach ($fields as $field) { - $columns[] = "$prefix.$field"; + $columns[] = "$prefix.[$field]"; } return $columns; } else { - return $fields; + return '[' . $fields . ']'; } } @@ -3326,7 +3326,7 @@ function drupal_write_record($table, &$o // Build the SQL. $query = ''; if (!count($update)) { - $query = "INSERT INTO {" . $table . "} (" . implode(', ', $fields) . ') VALUES (' . implode(', ', $placeholders) . ')'; + $query = "INSERT INTO [{" . $table . "}] ([" . implode('], [', $fields) . ']) VALUES (' . implode(', ', $placeholders) . ')'; $return = SAVED_NEW; } else { @@ -3335,15 +3335,15 @@ function drupal_write_record($table, &$o if ($query) { $query .= ', '; } - $query .= $field . ' = ' . $placeholders[$id]; + $query .= '[' . $field . '] = ' . $placeholders[$id]; } foreach ($update as $key){ - $conditions[] = "$key = " . db_type_placeholder($schema['fields'][$key]['type']); + $conditions[] = "[$key] = " . db_type_placeholder($schema['fields'][$key]['type']); $values[] = $object->$key; } - $query = "UPDATE {" . $table . "} SET $query WHERE " . implode(' AND ', $conditions); + $query = "UPDATE [{" . $table . "}] SET $query WHERE " . implode(' AND ', $conditions); $return = SAVED_UPDATED; } Index: includes/file.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/file.inc,v retrieving revision 1.135 diff -u -p -r1.135 file.inc --- includes/file.inc 20 Sep 2008 03:49:23 -0000 1.135 +++ includes/file.inc 28 Sep 2008 16:44:06 -0000 @@ -510,9 +510,9 @@ function file_delete($path) { */ function file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT) { if (!is_null($uid)) { - return (int)db_result(db_query('SELECT SUM(filesize) FROM {files} WHERE uid = %d AND status & %d', array($uid, $status))); + return (int)db_result(db_query('SELECT SUM([filesize]) FROM [{files}] WHERE [uid] = %d AND [status] & %d', array($uid, $status))); } - return (int)db_result(db_query('SELECT SUM(filesize) FROM {files} WHERE status & %d', array($status))); + return (int)db_result(db_query('SELECT SUM([filesize]) FROM [{files}] WHERE [status] & %d', array($status))); } /** @@ -878,7 +878,7 @@ function file_save_data($data, $destinat * error. */ function file_set_status($file, $status = FILE_STATUS_PERMANENT) { - if (db_query('UPDATE {files} SET status = %d WHERE fid = %d', array($status, $file->fid))) { + if (db_query('UPDATE [{files}] SET [status] = %d WHERE [fid] = %d', array($status, $file->fid))) { $file->status = $status; return TRUE; } Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.289 diff -u -p -r1.289 form.inc --- includes/form.inc 27 Sep 2008 19:47:42 -0000 1.289 +++ includes/form.inc 28 Sep 2008 16:44:06 -0000 @@ -2568,7 +2568,7 @@ function batch_process($redirect = NULL, // Initiate db storage in order to get a batch id. We have to provide // at least an empty string for the (not null) 'token' column. - db_query("INSERT INTO {batch} (token, timestamp) VALUES ('', %d)", REQUEST_TIME); + db_query("INSERT INTO [{batch}] ([token], [timestamp]) VALUES (%s, %d)", '', REQUEST_TIME); $batch['id'] = db_last_insert_id('batch', 'bid'); // Now that we have a batch id, we can generate the redirection link in @@ -2577,7 +2577,7 @@ function batch_process($redirect = NULL, $batch['error_message'] = $t('Please continue to the error page', array('@error_url' => url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished'))))); // Actually store the batch data and the token generated form the batch id. - db_query("UPDATE {batch} SET token = '%s', batch = '%s' WHERE bid = %d", drupal_get_token($batch['id']), serialize($batch), $batch['id']); + db_query("UPDATE [{batch}] SET [token] = %s, [batch] = %s WHERE [bid] = %d", drupal_get_token($batch['id']), serialize($batch), $batch['id']); drupal_goto($batch['url'], 'op=start&id=' . $batch['id']); } Index: includes/install.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/install.inc,v retrieving revision 1.71 diff -u -p -r1.71 install.inc --- includes/install.inc 27 Sep 2008 20:03:35 -0000 1.71 +++ includes/install.inc 28 Sep 2008 16:44:06 -0000 @@ -88,7 +88,7 @@ function drupal_load_updates() { * @param $module * A module name. * @return - * If the module has updates, an array of available updates sorted by version. + * If the module has updates, an array of available updates sorted by version. * Otherwise, FALSE. */ function drupal_get_schema_versions($module) { @@ -105,10 +105,10 @@ function drupal_get_schema_versions($mod if (count($updates) == 0) { return FALSE; } - + // Make sure updates are run in numeric order, not in definition order. sort($updates, SORT_NUMERIC); - + return $updates; } @@ -134,7 +134,7 @@ function drupal_get_installed_schema_ver if (!$versions) { $versions = array(); - $result = db_query("SELECT name, schema_version FROM {system} WHERE type = '%s'", 'module'); + $result = db_query("SELECT [name], [schema_version] FROM [{system}] WHERE [type] = %s", 'module'); while ($row = db_fetch_object($result)) { $versions[$row->name] = $row->schema_version; } @@ -152,7 +152,7 @@ function drupal_get_installed_schema_ver * The new schema version. */ function drupal_set_installed_schema_version($module, $version) { - db_query("UPDATE {system} SET schema_version = %d WHERE name = '%s'", $version, $module); + db_query("UPDATE [{system}] SET [schema_version] = %d WHERE [name] = %s", $version, $module); } /** @@ -231,7 +231,7 @@ function drupal_detect_database_types() unset($databases['mysql']); $databases = array('mysql' => $mysql_database) + $databases; } - + return $databases; } @@ -239,28 +239,28 @@ abstract class DatabaseInstaller { protected $success = array(); protected $tests = array( 'testCreate' => array( - 'query' => 'CREATE TABLE drupal_install_test (id int NULL)', + 'query' => 'CREATE TABLE [drupal_install_test] ([id] INT NULL)', 'success' => 'CREATE', 'message' => 'Failed to create a test table on your %name database server with the command %query. %name reports the following message: %error.For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.', 'fatal' => TRUE, ), 'testInsert' => array( - 'query' => 'INSERT INTO drupal_install_test (id) VALUES (1)', + 'query' => 'INSERT INTO [drupal_install_test] ([id]) VALUES (1)', 'success' => 'INSERT', 'message' => 'Failed to insert a value into a test table on your %name database server. We tried inserting a value with the command %query and %name reported the following error: %error.', ), 'testUpdate' => array( - 'query' => 'UPDATE drupal_install_test SET id = 2', + 'query' => 'UPDATE [drupal_install_test] SET [id] = 2', 'success' => 'UPDATE', 'message' => 'Failed to update a value in a test table on your %name database server. We tried updating a value with the command %query and %name reported the following error: %error.', ), 'testDelete' => array( - 'query' => 'DELETE FROM drupal_install_test', + 'query' => 'DELETE FROM [drupal_install_test]', 'success' => 'DELETE', 'message' => 'Failed to delete a value from a test table on your %name database server. We tried deleting a value with the command %query and %name reported the following error: %error.', ), 'testDrop' => array( - 'query' => 'DROP TABLE drupal_install_test', + 'query' => 'DROP TABLE [drupal_install_test]', 'success' => 'DELETE', 'message' => 'Failed to drop a test table from your %name database server. We tried dropping a table with the command %query and %name reported the following error %error.', ), @@ -517,7 +517,7 @@ function _drupal_install_module($module) */ function drupal_install_init_database() { static $included = FALSE; - + if (!$included) { $connection_info = Database::getConnectionInfo(); $driver = $connection_info['default']['driver']; @@ -541,10 +541,10 @@ function drupal_install_system() { require_once DRUPAL_ROOT . '/' . $system_path . '/system.install'; drupal_install_init_database(); module_invoke('system', 'install'); - + $system_versions = drupal_get_schema_versions('system'); $system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED; - db_query("INSERT INTO {system} (filename, name, type, owner, status, bootstrap, schema_version) VALUES('%s', '%s', '%s', '%s', %d, %d, %d)", $system_path . '/system.module', 'system', 'module', '', 1, 0, $system_version); + db_query("INSERT INTO [{system}] ([filename], [name], [type], [owner], [status], [bootstrap], [schema_version]) VALUES(%s, %s, %s, %s, %d, %d, %d)", $system_path . '/system.module', 'system', 'module', '', 1, 0, $system_version); // Now that we've installed things properly, bootstrap the full Drupal environment drupal_install_init_database(); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); @@ -580,9 +580,9 @@ function drupal_uninstall_module($module } $paths[$index] = implode('/', $parts); } - $placeholders = implode(', ', array_fill(0, count($paths), "'%s'")); + $placeholders = implode(', ', array_fill(0, count($paths), "%s")); - $result = db_query('SELECT * FROM {menu_links} WHERE router_path IN (' . $placeholders . ') AND external = 0 ORDER BY depth DESC', $paths); + $result = db_query('SELECT * FROM [{menu_links}] WHERE [router_path] IN (' . $placeholders . ') AND [external] = 0 ORDER BY [depth] DESC', $paths); // Remove all such items. Starting from those with the greatest depth will // minimize the amount of re-parenting done by menu_link_delete(). while ($item = db_fetch_array($result)) { @@ -795,7 +795,7 @@ function drupal_install_fix_file($file, /** - * Send the user to a different installer page. + * Send the user to a different installer page. * * This issues an on-site HTTP redirect. Messages (and errors) are erased. * @@ -894,7 +894,7 @@ function drupal_check_profile($profile) * Extract highest severity from requirements array. * * @param $requirements - * An array of requirements, in the same format as is returned by + * An array of requirements, in the same format as is returned by * hook_requirements(). * @return * The highest severity in the array. Index: includes/locale.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/locale.inc,v retrieving revision 1.187 diff -u -p -r1.187 locale.inc --- includes/locale.inc 27 Sep 2008 20:23:30 -0000 1.187 +++ includes/locale.inc 28 Sep 2008 16:44:06 -0000 @@ -125,7 +125,7 @@ function locale_languages_overview_form_ $language->enabled = 0; } $language->weight = $form_state['values']['weight'][$langcode]; - db_query("UPDATE {languages} SET enabled = %d, weight = %d WHERE language = '%s'", $language->enabled, $language->weight, $langcode); + db_query("UPDATE [{languages}] SET [enabled] = %d, [weight] = %d WHERE [language] = %s", $language->enabled, $language->weight, $langcode); $languages[$langcode] = $language; } drupal_set_message(t('Configuration saved.')); @@ -204,7 +204,7 @@ function locale_languages_custom_form() * Language code of the language to edit. */ function locale_languages_edit_form(&$form_state, $langcode) { - if ($language = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $langcode))) { + if ($language = db_fetch_object(db_query("SELECT * FROM [{languages}] WHERE [language] = %s", $langcode))) { $form = array(); _locale_languages_common_controls($form, $language); $form['submit'] = array( @@ -296,7 +296,7 @@ function _locale_languages_common_contro function locale_languages_predefined_form_validate($form, &$form_state) { $langcode = $form_state['values']['langcode']; - if ($duplicate = db_result(db_query("SELECT COUNT(*) FROM {languages} WHERE language = '%s'", $langcode)) != 0) { + if ($duplicate = db_result(db_query("SELECT COUNT(*) FROM [{languages}] WHERE [language] = %s", $langcode)) != 0) { form_set_error('langcode', t('The language %language (%code) already exists.', array('%language' => $form_state['values']['name'], '%code' => $langcode))); } @@ -347,13 +347,13 @@ function locale_languages_edit_form_vali if (!empty($form_state['values']['domain']) && !empty($form_state['values']['prefix'])) { form_set_error('prefix', t('Domain and path prefix values should not be set at the same time.')); } - if (!empty($form_state['values']['domain']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE domain = '%s' AND language <> '%s'", $form_state['values']['domain'], $form_state['values']['langcode']))) { + if (!empty($form_state['values']['domain']) && $duplicate = db_fetch_object(db_query("SELECT [language] FROM [{languages}] WHERE [domain] = %s AND [language] <> %s", $form_state['values']['domain'], $form_state['values']['langcode']))) { form_set_error('domain', t('The domain (%domain) is already tied to a language (%language).', array('%domain' => $form_state['values']['domain'], '%language' => $duplicate->language))); } if (empty($form_state['values']['prefix']) && language_default('language') != $form_state['values']['langcode'] && empty($form_state['values']['domain'])) { form_set_error('prefix', t('Only the default language can have both the domain and prefix empty.')); } - if (!empty($form_state['values']['prefix']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE prefix = '%s' AND language <> '%s'", $form_state['values']['prefix'], $form_state['values']['langcode']))) { + if (!empty($form_state['values']['prefix']) && $duplicate = db_fetch_object(db_query("SELECT [language] FROM [{languages}] WHERE [prefix] = %s AND [language] <> %s", $form_state['values']['prefix'], $form_state['values']['langcode']))) { form_set_error('prefix', t('The prefix (%prefix) is already tied to a language (%language).', array('%prefix' => $form_state['values']['prefix'], '%language' => $duplicate->language))); } } @@ -362,7 +362,7 @@ function locale_languages_edit_form_vali * Process the language editing form submission. */ function locale_languages_edit_form_submit($form, &$form_state) { - db_query("UPDATE {languages} SET name = '%s', native = '%s', domain = '%s', prefix = '%s', direction = %d WHERE language = '%s'", $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['domain'], $form_state['values']['prefix'], $form_state['values']['direction'], $form_state['values']['langcode']); + db_query("UPDATE [{languages}] SET [name] = %s, [native] = %s, [domain] = %s, [prefix] = %s, [direction] = %d WHERE [language] = %s", $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['domain'], $form_state['values']['prefix'], $form_state['values']['direction'], $form_state['values']['langcode']); $default = language_default(); if ($default->language == $form_state['values']['langcode']) { $properties = array('name', 'native', 'direction', 'enabled', 'plurals', 'formula', 'domain', 'prefix', 'weight'); @@ -420,13 +420,13 @@ function locale_languages_delete_form_su $languages = language_list(); if (isset($languages[$form_state['values']['langcode']])) { // Remove translations first. - db_query("DELETE FROM {locales_target} WHERE language = '%s'", $form_state['values']['langcode']); + db_query("DELETE FROM [{locales_target}] WHERE [language] = %s", $form_state['values']['langcode']); cache_clear_all('locale:' . $form_state['values']['langcode'], 'cache'); // With no translations, this removes existing JavaScript translations file. _locale_rebuild_js($form_state['values']['langcode']); // Remove the language. - db_query("DELETE FROM {languages} WHERE language = '%s'", $form_state['values']['langcode']); - db_query("UPDATE {node} SET language = '' WHERE language = '%s'", $form_state['values']['langcode']); + db_query("DELETE FROM [{languages}] WHERE [language] = %s", $form_state['values']['langcode']); + db_query("UPDATE [{node}] SET [language] = %s WHERE [language] = %s", '', $form_state['values']['langcode']); $variables = array('%locale' => $languages[$form_state['values']['langcode']]->name); drupal_set_message(t('The language %locale has been removed.', $variables)); watchdog('locale', 'The language %locale has been removed.', $variables); @@ -498,7 +498,7 @@ function locale_translate_overview_scree $headers = array_merge(array(t('Language')), array_values($groups)); // Collect summaries of all source strings in all groups. - $sums = db_query("SELECT COUNT(*) AS strings, textgroup FROM {locales_source} GROUP BY textgroup"); + $sums = db_query("SELECT COUNT(*) AS [strings], [textgroup] FROM [{locales_source}] GROUP BY [textgroup]"); $groupsums = array(); while ($group = db_fetch_object($sums)) { $groupsums[$group->textgroup] = $group->strings; @@ -514,7 +514,7 @@ function locale_translate_overview_scree } // Languages with at least one record in the locale table. - $translations = db_query("SELECT COUNT(*) AS translation, t.language, s.textgroup FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid GROUP BY textgroup, language"); + $translations = db_query("SELECT COUNT(*) AS [translation], t.[language], s.[textgroup] FROM [{locales_source}] s INNER JOIN [{locales_target}] t ON s.[lid] = t.[lid] GROUP BY [textgroup], [language]"); while ($data = db_fetch_object($translations)) { $ratio = (!empty($groupsums[$data->textgroup]) && $data->translation > 0) ? round(($data->translation/$groupsums[$data->textgroup])*100., 2) : 0; $rows[$data->language][$data->textgroup] = $data->translation . '/' . $groupsums[$data->textgroup] . " ($ratio%)"; @@ -777,7 +777,7 @@ function locale_translate_export_po_form */ function locale_translate_edit_form(&$form_state, $lid) { // Fetch source string, if possible. - $source = db_fetch_object(db_query('SELECT source, textgroup, location FROM {locales_source} WHERE lid = %d', $lid)); + $source = db_fetch_object(db_query('SELECT [source], [textgroup], [location] FROM [{locales_source}] WHERE [lid] = %d', $lid)); if (!$source) { drupal_set_message(t('String not found.'), 'error'); drupal_goto('admin/build/translate/search'); @@ -824,7 +824,7 @@ function locale_translate_edit_form(&$fo } // Fetch translations and fill in default values in the form. - $result = db_query("SELECT DISTINCT translation, language FROM {locales_target} WHERE lid = %d AND language <> '%s'", $lid, $omit); + $result = db_query("SELECT DISTINCT [translation], [language] FROM [{locales_target}] WHERE [lid] = %d AND [language] <> %s", $lid, $omit); while ($translation = db_fetch_object($result)) { $form['translations'][$translation->language]['#default_value'] = $translation->translation; } @@ -840,19 +840,19 @@ function locale_translate_edit_form(&$fo function locale_translate_edit_form_submit($form, &$form_state) { $lid = $form_state['values']['lid']; foreach ($form_state['values']['translations'] as $key => $value) { - $translation = db_result(db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $key)); + $translation = db_result(db_query("SELECT [translation] FROM [{locales_target}] WHERE [lid] = %d AND [language] = %s", $lid, $key)); if (!empty($value)) { // Only update or insert if we have a value to use. if (!empty($translation)) { - db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND language = '%s'", $value, $lid, $key); + db_query("UPDATE [{locales_target}] SET [translation] = %s WHERE [lid] = %d AND [language] = %s", $value, $lid, $key); } else { - db_query("INSERT INTO {locales_target} (lid, translation, language) VALUES (%d, '%s', '%s')", $lid, $value, $key); + db_query("INSERT INTO [{locales_target}] ([lid], [translation], [language]) VALUES (%d, %s, %s)", $lid, $value, $key); } } elseif (!empty($translation)) { // Empty translation entered: remove existing entry from database. - db_query("DELETE FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $key); + db_query("DELETE FROM [{locales_target}] WHERE [lid] = %d AND [language] = %s", $lid, $key); } // Force JavaScript translation file recreation for this language. @@ -881,7 +881,7 @@ function locale_translate_edit_form_subm * String deletion confirmation page. */ function locale_translate_delete_page($lid) { - if ($source = db_fetch_object(db_query('SELECT * FROM {locales_source} WHERE lid = %d', $lid))) { + if ($source = db_fetch_object(db_query('SELECT * FROM [{locales_source}] WHERE [lid] = %d', $lid))) { return drupal_get_form('locale_translate_delete_form', $source); } else { @@ -901,8 +901,8 @@ function locale_translate_delete_form(&$ * Process string deletion submissions. */ function locale_translate_delete_form_submit($form, &$form_state) { - db_query('DELETE FROM {locales_source} WHERE lid = %d', $form_state['values']['lid']); - db_query('DELETE FROM {locales_target} WHERE lid = %d', $form_state['values']['lid']); + db_query('DELETE FROM [{locales_source}] WHERE [lid] = %d', $form_state['values']['lid']); + db_query('DELETE FROM [{locales_target}] WHERE [lid] = %d', $form_state['values']['lid']); // Force JavaScript translation file recreation for all languages. _locale_invalidate_js(); cache_clear_all('locale:', 'cache', TRUE); @@ -954,7 +954,7 @@ function locale_add_language($langcode, $direction = isset($predefined[$langcode][2]) ? $predefined[$langcode][2] : LANGUAGE_LTR; } - db_query("INSERT INTO {languages} (language, name, native, direction, domain, prefix, enabled) VALUES ('%s', '%s', '%s', %d, '%s', '%s', %d)", $langcode, $name, $native, $direction, $domain, $prefix, $enabled); + db_query("INSERT INTO [{languages}] ([language], [name], [native], [direction], [domain], [prefix], [enabled]) VALUES (%s, %s, %s, %d, %s, %s, %d)", $langcode, $name, $native, $direction, $domain, $prefix, $enabled); // Only set it as default if enabled. if ($enabled && $default) { @@ -999,7 +999,7 @@ function _locale_import_po($file, $langc } // Check if we have the language already in the database. - if (!db_fetch_object(db_query("SELECT language FROM {languages} WHERE language = '%s'", $langcode))) { + if (!db_fetch_object(db_query("SELECT [language] FROM [{languages}] WHERE [language] = %s", $langcode))) { drupal_set_message(t('The language selected for import is not supported.'), 'error'); return FALSE; } @@ -1243,10 +1243,10 @@ function _locale_import_one_string($op, // Get the plural formula and update in database. if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->filename)) { list($nplurals, $plural) = $p; - db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", $nplurals, $plural, $lang); + db_query("UPDATE [{languages}] SET [plurals] = %d, [formula] = %s WHERE [language] = %s", $nplurals, $plural, $lang); } else { - db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", 0, '', $lang); + db_query("UPDATE [{languages}] SET [plurals] = %d, [formula] = %s WHERE [language] = %s", 0, '', $lang); } $headerdone = TRUE; } @@ -1308,35 +1308,35 @@ function _locale_import_one_string($op, * The string ID of the existing string modified or the new string added. */ function _locale_import_one_string_db(&$report, $langcode, $source, $translation, $textgroup, $location, $mode, $plid = NULL, $plural = NULL) { - $lid = db_result(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND textgroup = '%s'", $source, $textgroup)); + $lid = db_result(db_query("SELECT [lid] FROM [{locales_source}] WHERE [source] = %s AND [textgroup] = %s", $source, $textgroup)); if (!empty($translation)) { if ($lid) { // We have this source string saved already. - db_query("UPDATE {locales_source} SET location = '%s' WHERE lid = %d", $location, $lid); - $exists = (bool) db_result(db_query("SELECT lid FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $langcode)); + db_query("UPDATE [{locales_source}] SET [location] = %s WHERE [lid] = %d", $location, $lid); + $exists = (bool) db_result(db_query("SELECT [lid] FROM [{locales_target}] WHERE [lid] = %d AND [language] = %s", $lid, $langcode)); if (!$exists) { // No translation in this language. - db_query("INSERT INTO {locales_target} (lid, language, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $langcode, $translation, $plid, $plural); + db_query("INSERT INTO [{locales_target}] ([lid], [language], [translation], [plid], [plural]) VALUES (%d, %s, %s, %d, %d)", $lid, $langcode, $translation, $plid, $plural); $report[0]++; } else if ($mode == LOCALE_IMPORT_OVERWRITE) { // Translation exists, only overwrite if instructed. - db_query("UPDATE {locales_target} SET translation = '%s', plid = %d, plural = %d WHERE language = '%s' AND lid = %d", $translation, $plid, $plural, $langcode, $lid); + db_query("UPDATE [{locales_target}] SET [translation] = %s, [plid] = %d, [plural] = %d WHERE [language] = %s AND [lid] = %d", $translation, $plid, $plural, $langcode, $lid); $report[1]++; } } else { // No such source string in the database yet. - db_query("INSERT INTO {locales_source} (location, source, textgroup) VALUES ('%s', '%s', '%s')", $location, $source, $textgroup); - $lid = db_result(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND textgroup = '%s'", $source, $textgroup)); - db_query("INSERT INTO {locales_target} (lid, language, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $langcode, $translation, $plid, $plural); + db_query("INSERT INTO [{locales_source}] ([location], [source], [textgroup]) VALUES (%s, %s, %s)", $location, $source, $textgroup); + $lid = db_result(db_query("SELECT [lid] FROM [{locales_source}] WHERE [source] = %s AND [textgroup] = %s", $source, $textgroup)); + db_query("INSERT INTO [{locales_target}] ([lid], [language], [translation], [plid], [plural]) VALUES (%d, %s, %s, %d, %d)", $lid, $langcode, $translation, $plid, $plural); $report[0]++; } } elseif ($mode == LOCALE_IMPORT_OVERWRITE) { // Empty translation, remove existing if instructed. - db_query("DELETE FROM {locales_target} WHERE language = '%s' AND lid = %d AND plid = %d AND plural = %d", $translation, $langcode, $lid, $plid, $plural); + db_query("DELETE FROM [{locales_target}] WHERE [language] = %s AND [lid] = %d AND [plid] = %d AND [plural] = %d", $translation, $langcode, $lid, $plid, $plural); $report[2]++; } @@ -1672,7 +1672,7 @@ function _locale_parse_js_file($filepath // Remove the quotes and string concatenations from the string. $string = implode('', preg_split('~(?lid); + db_query("UPDATE [{locales_source}] SET [location] = %s WHERE [lid] = %d", $locations, $source->lid); } } else { // We don't have the source string yet, thus we insert it into the database. - db_query("INSERT INTO {locales_source} (location, source, textgroup) VALUES ('%s', '%s', 'default')", $filepath, $string); + db_query("INSERT INTO [{locales_source}] ([location], [source], [textgroup]) VALUES (%s, %s, 'default')", $filepath, $string); } } } @@ -1712,10 +1712,10 @@ function _locale_parse_js_file($filepath */ function _locale_export_get_strings($language = NULL, $group = 'default') { if (isset($language)) { - $result = db_query("SELECT s.lid, s.source, s.location, t.translation, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = '%s' ORDER BY t.plid, t.plural", $language->language, $group); + $result = db_query("SELECT s.[lid], s.[source], s.[location], t.[translation], t.[plid], t.[plural] FROM [{locales_source}] s LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] AND t.[language] = %s WHERE s.[textgroup] = %s ORDER BY t.[plid], t.[plural]", $language->language, $group); } else { - $result = db_query("SELECT s.lid, s.source, s.location, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid WHERE s.textgroup = '%s' ORDER BY t.plid, t.plural", $group); + $result = db_query("SELECT s.[lid], s.[source], s.[location], t.[plid], t.[plural] FROM [{locales_source}] s LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] WHERE s.[textgroup] = %s ORDER BY t.[plid], t.[plural]", $group); } $strings = array(); while ($child = db_fetch_object($result)) { @@ -1943,40 +1943,40 @@ function _locale_translate_seek() { // We have at least one criterion to match if ($query = _locale_translate_seek_query()) { - $join = "SELECT s.source, s.location, s.lid, s.textgroup, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid "; + $join = "SELECT s.[source], s.[location], s.[lid], s.[textgroup], t.[translation], t.[language] FROM [{locales_source}] s LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] "; $arguments = array(); $limit_language = FALSE; // Compute LIKE section switch ($query['translation']) { case 'translated': - $where = "WHERE (t.translation LIKE ?)"; - $orderby = "ORDER BY t.translation"; - $arguments[] = '%'. $query['string'] .'%'; + $where = "WHERE (t.[translation] LIKE ?)"; + $orderby = "ORDER BY t.[translation]"; + $arguments[] = '%' . $query['string'] . '%'; break; case 'untranslated': - $where = "WHERE (s.source LIKE ? AND t.translation IS NULL)"; - $orderby = "ORDER BY s.source"; - $arguments[] = '%'. $query['string'] .'%'; + $where = "WHERE (s.[source] LIKE ? AND t.[translation] IS NULL)"; + $orderby = "ORDER BY s.[source]"; + $arguments[] = '%' . $query['string'] . '%'; break; case 'all' : default: - $where = "WHERE (s.source LIKE ? OR t.translation LIKE ?)"; + $where = "WHERE (s.[source] LIKE ? OR t.[translation] LIKE ?)"; $orderby = ''; - $arguments[] = '%'. $query['string'] .'%'; - $arguments[] = '%'. $query['string'] .'%'; + $arguments[] = '%' . $query['string'] . '%'; + $arguments[] = '%' . $query['string'] . '%'; break; } $grouplimit = ''; if (!empty($query['group']) && $query['group'] != 'all') { - $grouplimit = " AND s.textgroup = ?"; + $grouplimit = " AND s.[textgroup] = ?"; $arguments[] = $query['group']; } switch ($query['language']) { // Force search in source strings case "en": - $sql = $join . " WHERE s.source LIKE ? $grouplimit ORDER BY s.source"; + $sql = $join . " WHERE s.[source] LIKE ? $grouplimit ORDER BY s.[source]"; $arguments = array('%' . $query['string'] . '%'); // $where is not used, discard its arguments if (!empty($grouplimit)) { $arguments[] = $query['group']; @@ -1988,7 +1988,7 @@ function _locale_translate_seek() { break; // Some different language default: - $sql = "$join AND t.language = ? $where $grouplimit $orderby"; + $sql = "$join AND t.[language] = ? $where $grouplimit $orderby"; array_unshift($arguments, $query['language']); // Don't show translation flags for other languages, we can't see them with this search. $limit_language = $query['language']; @@ -2098,12 +2098,12 @@ function _locale_rebuild_js($langcode = // Construct the array for JavaScript translations. // We sort on plural so that we have all plural forms before singular forms. - $result = db_query("SELECT s.lid, s.source, t.plid, t.plural, t.translation - FROM {locales_source} s - LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language - WHERE s.location LIKE '%.js%' - AND s.textgroup = 'default' - ORDER BY t.plural DESC", array(':language' => $language->language)); + $result = db_query("SELECT s.[lid], s.[source], t.[plid], t.[plural], t.[translation] + FROM [{locales_source}] s + LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] AND t.[language] = :language + WHERE s.[location] LIKE '%.js%' + AND s.[textgroup] = 'default' + ORDER BY t.[plural] DESC", array(':language' => $language->language)); $translations = $plurals = array(); while ($data = db_fetch_object($result)) { @@ -2178,14 +2178,14 @@ function _locale_rebuild_js($langcode = // Save the new JavaScript hash (or an empty value if the file // just got deleted). Act only if some operation was executed. if ($status) { - db_query("UPDATE {languages} SET javascript = '%s' WHERE language = '%s'", $language->javascript, $language->language); + db_query("UPDATE [{languages}] SET [javascript] = %s WHERE [language] = %s", $language->javascript, $language->language); // Update the default language variable if the default language has been altered. // This is necessary to keep the variable consistent with the database // version of the language and to prevent checking against an outdated hash. $default_langcode = language_default('language'); if ($default_langcode == $language->language) { - $default = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $default_langcode)); + $default = db_fetch_object(db_query("SELECT * FROM [{languages}] WHERE [language] = %s", $default_langcode)); variable_set('language_default', $default); } } @@ -2475,9 +2475,9 @@ function locale_batch_by_language($langc // Collect all files to import for all enabled modules and themes. $files = array(); $components = array(); - $query = "SELECT name, filename FROM {system} WHERE status = 1"; + $query = "SELECT [name], [filename] FROM [{system}] WHERE [status] = 1"; if (count($skip)) { - $query .= " AND name NOT IN (" . db_placeholders($skip, 'varchar') . ")"; + $query .= " AND [name] NOT IN (" . db_placeholders($skip, 'varchar') . ")"; } $result = db_query($query, $skip); while ($component = db_fetch_object($result)) { @@ -2510,7 +2510,7 @@ function locale_batch_by_component($comp if (count($languages[1])) { $language_list = join('|', array_keys($languages[1])); // Collect all files to import for all $components. - $result = db_query("SELECT name, filename FROM {system} WHERE status = 1"); + $result = db_query("SELECT [name], [filename] FROM [{system}] WHERE [status] = 1"); while ($component = db_fetch_object($result)) { if (in_array($component->name, $components)) { // Collect all files for this component in all enabled languages, named Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.292 diff -u -p -r1.292 menu.inc --- includes/menu.inc 22 Sep 2008 03:19:43 -0000 1.292 +++ includes/menu.inc 28 Sep 2008 16:44:06 -0000 @@ -279,7 +279,7 @@ function menu_get_ancestors($parts) { $current .= '/'; } } - $placeholders[] = "'%s'"; + $placeholders[] = "%s"; $ancestors[] = $current; } return array($ancestors, $placeholders); @@ -364,7 +364,7 @@ function menu_get_item($path = NULL, $ro $parts = array_slice($original_map, 0, MENU_MAX_PARTS); list($ancestors, $placeholders) = menu_get_ancestors($parts); - if ($router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN (' . implode (',', $placeholders) . ') ORDER BY fit DESC', $ancestors, 0, 1))) { + if ($router_item = db_fetch_array(db_query_range('SELECT * FROM [{menu_router}] WHERE [path] IN (' . implode (', ', $placeholders) . ') ORDER BY [fit] DESC', $ancestors, 0, 1))) { $map = _menu_translate($router_item, $original_map); if ($map === FALSE) { $router_items[$path] = FALSE; @@ -855,7 +855,7 @@ function menu_tree_all_data($menu_name = } $args = array_unique($args); $placeholders = implode(', ', array_fill(0, count($args), '%d')); - $where = ' AND ml.plid IN (' . $placeholders . ')'; + $where = ' AND ml.[plid] IN (' . $placeholders . ')'; $parents = $args; $parents[] = $item['mlid']; } @@ -870,10 +870,10 @@ function menu_tree_all_data($menu_name = // LEFT JOIN since there is no match in {menu_router} for an external // link. $data['tree'] = menu_tree_data(db_query(" - SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.* - FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path - WHERE ml.menu_name = '%s'" . $where . " - ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents); + SELECT m.[load_functions], m.[to_arg_functions], m.[access_callback], m.[access_arguments], m.[page_callback], m.[page_arguments], m.[title], m.[title_callback], m.[title_arguments], m.[type], m.[description], ml.* + FROM [{menu_links}] ml LEFT JOIN [{menu_router}] m ON m.[path] = ml.[router_path] + WHERE ml.[menu_name] = %s" . $where . " + ORDER BY [p1] ASC, [p2] ASC, [p3] ASC, [p4] ASC, [p5] ASC, [p6] ASC, [p7] ASC, [p8] ASC, [p9] ASC", $args), $parents); $data['node_links'] = array(); menu_tree_collect_node_links($data['tree'], $data['node_links']); // Cache the data, if it is not already in the cache. @@ -932,17 +932,17 @@ function menu_tree_page_data($menu_name if ($item['access']) { // Check whether a menu link exists that corresponds to the current path. $args = array($menu_name, $item['href']); - $placeholders = "'%s'"; + $placeholders = "%s"; if (drupal_is_front_page()) { $args[] = ''; - $placeholders .= ", '%s'"; + $placeholders .= ", %s"; } - $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path IN (" . $placeholders . ")", $args)); + $parents = db_fetch_array(db_query("SELECT [p1], [p2], [p3], [p4], [p5], [p6], [p7], [p8] FROM [{menu_links}] WHERE [menu_name] = %s AND [link_path] IN (" . $placeholders . ")", $args)); if (empty($parents)) { // If no link exists, we may be on a local task that's not in the links. // TODO: Handle the case like a local task on a specific node in the menu. - $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $menu_name, $item['tab_root'])); + $parents = db_fetch_array(db_query("SELECT [p1], [p2], [p3], [p4], [p5], [p6], [p7], [p8] FROM [{menu_links}] WHERE [menu_name] = %s AND [link_path] = %s", $menu_name, $item['tab_root'])); } // We always want all the top-level links with plid == 0. $parents[] = '0'; @@ -956,7 +956,7 @@ function menu_tree_page_data($menu_name // Collect all the links set to be expanded, and then add all of // their children to the list as well. do { - $result = db_query("SELECT mlid FROM {menu_links} WHERE menu_name = '%s' AND expanded = 1 AND has_children = 1 AND plid IN (" . $placeholders . ') AND mlid NOT IN (' . $placeholders . ')', array_merge(array($menu_name), $args, $args)); + $result = db_query("SELECT [mlid] FROM [{menu_links}] WHERE [menu_name] = %s AND [expanded] = 1 AND [has_children] = 1 AND [plid] IN (" . $placeholders . ') AND [mlid] NOT IN (' . $placeholders . ')', array_merge(array($menu_name), $args, $args)); $num_rows = FALSE; while ($item = db_fetch_array($result)) { $args[] = $item['mlid']; @@ -977,10 +977,10 @@ function menu_tree_page_data($menu_name // LEFT JOIN since there is no match in {menu_router} for an external // link. $data['tree'] = menu_tree_data(db_query(" - SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.* - FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path - WHERE ml.menu_name = '%s' AND ml.plid IN (" . $placeholders . ") - ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents); + SELECT m.[load_functions], m.[to_arg_functions], m.[access_callback], m.[access_arguments], m.[page_callback], m.[page_arguments], m.[title], m.[title_callback], m.[title_arguments], m.[type], m.[description], ml.* + FROM [{menu_links}] ml LEFT JOIN [{menu_router}] m ON m.[path] = ml.[router_path] + WHERE ml.[menu_name] = %s AND ml.[plid] IN (" . $placeholders . ") + ORDER BY [p1] ASC, [p2] ASC, [p3] ASC, [p4] ASC, [p5] ASC, [p6] ASC, [p7] ASC, [p8] ASC, [p9] ASC", $args), $parents); $data['node_links'] = array(); menu_tree_collect_node_links($data['tree'], $data['node_links']); // Cache the data, if it is not already in the cache. @@ -1035,7 +1035,7 @@ function menu_tree_check_access(&$tree, // Use db_rewrite_sql to evaluate view access without loading each full node. $nids = array_keys($node_links); $placeholders = '%d' . str_repeat(', %d', count($nids) - 1); - $result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.status = 1 AND n.nid IN (" . $placeholders . ")"), $nids); + $result = db_query(db_rewrite_sql("SELECT n.[nid] FROM [{node}] n WHERE n.[status] = 1 AND n.[nid] IN (" . $placeholders . ")"), $nids); while ($node = db_fetch_array($result)) { $nid = $node['nid']; foreach ($node_links[$nid] as $mlid => $link) { @@ -1243,7 +1243,7 @@ function menu_get_names($reset = FALSE) if ($reset || empty($names)) { $names = array(); - $result = db_query("SELECT DISTINCT(menu_name) FROM {menu_links} ORDER BY menu_name"); + $result = db_query("SELECT DISTINCT([menu_name]) FROM [{menu_links}] ORDER BY [menu_name]"); while ($name = db_fetch_array($result)) { $names[] = $name['menu_name']; } @@ -1357,7 +1357,7 @@ function menu_local_tasks($level = 0, $r return ''; } // Get all tabs and the root page. - $result = db_query("SELECT * FROM {menu_router} WHERE tab_root = '%s' ORDER BY weight, title", $router_item['tab_root']); + $result = db_query("SELECT * FROM [{menu_router}] WHERE [tab_root] = %s ORDER BY [weight], [title]", $router_item['tab_root']); $map = arg(); $children = array(); $tasks = array(); @@ -1663,7 +1663,7 @@ function menu_get_active_title() { * rendering. */ function menu_link_load($mlid) { - if (is_numeric($mlid) && $item = db_fetch_array(db_query("SELECT m.*, ml.* FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = %d", $mlid))) { + if (is_numeric($mlid) && $item = db_fetch_array(db_query("SELECT m.*, ml.* FROM [{menu_links}] ml LEFT JOIN [{menu_router}] m ON m.[path] = ml.[router_path] WHERE ml.[mlid] = %d", $mlid))) { _menu_link_translate($item); return $item; } @@ -1788,7 +1788,7 @@ function _menu_navigation_links_rebuild( array_multisort($sort, SORT_NUMERIC, $menu_links); foreach ($menu_links as $item) { - $existing_item = db_fetch_array(db_query("SELECT mlid, menu_name, plid, customized, has_children, updated FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", $item['link_path'], 'system')); + $existing_item = db_fetch_array(db_query("SELECT [mlid], [menu_name], [plid], [customized], [has_children], [updated] FROM [{menu_links}] WHERE [link_path] = %s AND [module] = %s", $item['link_path'], 'system')); if ($existing_item) { $item['mlid'] = $existing_item['mlid']; // A change in hook_menu may move the link to a different menu @@ -1807,18 +1807,18 @@ function _menu_navigation_links_rebuild( $placeholders = db_placeholders($menu, 'varchar'); $paths = array_keys($menu); // Updated and customized items whose router paths are gone need new ones. - $result = db_query("SELECT ml.link_path, ml.mlid, ml.router_path, ml.updated FROM {menu_links} ml WHERE ml.updated = 1 OR (router_path NOT IN ($placeholders) AND external = 0 AND customized = 1)", $paths); + $result = db_query("SELECT ml.[link_path], ml.[mlid], ml.[router_path], ml.[updated] FROM [{menu_links}] ml WHERE ml.[updated] = 1 OR ([router_path] NOT IN ($placeholders) AND [external] = 0 AND [customized] = 1)", $paths); while ($item = db_fetch_array($result)) { $router_path = _menu_find_router_path($menu, $item['link_path']); if (!empty($router_path) && ($router_path != $item['router_path'] || $item['updated'])) { // If the router path and the link path matches, it's surely a working // item, so we clear the updated flag. $updated = $item['updated'] && $router_path != $item['link_path']; - db_query("UPDATE {menu_links} SET router_path = '%s', updated = %d WHERE mlid = %d", $router_path, $updated, $item['mlid']); + db_query("UPDATE [{menu_links}] SET [router_path] = %s, [updated] = %d WHERE [mlid] = %d", $router_path, $updated, $item['mlid']); } } // Find any item whose router path does not exist any more. - $result = db_query("SELECT * FROM {menu_links} WHERE router_path NOT IN ($placeholders) AND external = 0 AND updated = 0 AND customized = 0 ORDER BY depth DESC", $paths); + $result = db_query("SELECT * FROM [{menu_links}] WHERE [router_path] NOT IN ($placeholders) AND [external] = 0 AND [updated] = 0 AND [customized] = 0 ORDER BY [depth] DESC", $paths); // Remove all such items. Starting from those with the greatest depth will // minimize the amount of re-parenting done by menu_link_delete(). while ($item = db_fetch_array($result)) { @@ -1836,10 +1836,10 @@ function _menu_navigation_links_rebuild( */ function menu_link_delete($mlid, $path = NULL) { if (isset($mlid)) { - _menu_delete_item(db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $mlid))); + _menu_delete_item(db_fetch_array(db_query("SELECT * FROM [{menu_links}] WHERE [mlid] = %d", $mlid))); } else { - $result = db_query("SELECT * FROM {menu_links} WHERE link_path = '%s'", $path); + $result = db_query("SELECT * FROM [{menu_links}] WHERE [link_path] = %s", $path); while ($link = db_fetch_array($result)) { _menu_delete_item($link); } @@ -1858,14 +1858,14 @@ function _menu_delete_item($item, $force if ($item && ($item['module'] != 'system' || $item['updated'] || $force)) { // Children get re-attached to the item's parent. if ($item['has_children']) { - $result = db_query("SELECT mlid FROM {menu_links} WHERE plid = %d", $item['mlid']); + $result = db_query("SELECT [mlid] FROM [{menu_links}] WHERE [plid] = %d", $item['mlid']); while ($m = db_fetch_array($result)) { $child = menu_link_load($m['mlid']); $child['plid'] = $item['plid']; menu_link_save($child); } } - db_query('DELETE FROM {menu_links} WHERE mlid = %d', $item['mlid']); + db_query('DELETE FROM [{menu_links}] WHERE [mlid] = %d', $item['mlid']); // Update the has_children status of the parent. _menu_update_parental_status($item); @@ -1888,7 +1888,7 @@ function _menu_delete_item($item, $force * - plid The mlid of the parent. * - router_path The path of the relevant router item. * @return - * The mlid of the saved menu link, or FALSE if the menu link could not be + * The mlid of the saved menu link, or FALSE if the menu link could not be * saved. */ function menu_link_save(&$item) { @@ -1914,34 +1914,34 @@ function menu_link_save(&$item) { ); $existing_item = FALSE; if (isset($item['mlid'])) { - $existing_item = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $item['mlid'])); + $existing_item = db_fetch_array(db_query("SELECT * FROM [{menu_links}] WHERE [mlid] = %d", $item['mlid'])); } if (isset($item['plid'])) { - $parent = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $item['plid'])); + $parent = db_fetch_array(db_query("SELECT * FROM [{menu_links}] WHERE [mlid] = %d", $item['plid'])); } else { // Find the parent - it must be unique. $parent_path = $item['link_path']; - $where = "WHERE link_path = '%s'"; + $where = "WHERE [link_path] = %s"; // Only links derived from router items should have module == 'system', and // we want to find the parent even if it's in a different menu. if ($item['module'] == 'system') { - $where .= " AND module = '%s'"; + $where .= " AND [module] = %s"; $arg2 = 'system'; } else { // If not derived from a router item, we respect the specified menu name. - $where .= " AND menu_name = '%s'"; + $where .= " AND [menu_name] = %s"; $arg2 = $item['menu_name']; } do { $parent = FALSE; $parent_path = substr($parent_path, 0, strrpos($parent_path, '/')); - $result = db_query("SELECT COUNT(*) FROM {menu_links} " . $where, $parent_path, $arg2); + $result = db_query("SELECT COUNT(*) FROM [{menu_links}] " . $where, $parent_path, $arg2); // Only valid if we get a unique result. if (db_result($result) == 1) { - $parent = db_fetch_array(db_query("SELECT * FROM {menu_links} " . $where, $parent_path, $arg2)); + $parent = db_fetch_array(db_query("SELECT * FROM [{menu_links}] " . $where, $parent_path, $arg2)); } } while ($parent === FALSE && $parent_path); } @@ -1959,16 +1959,16 @@ function menu_link_save(&$item) { } if (!$existing_item) { - db_query("INSERT INTO {menu_links} ( - menu_name, plid, link_path, - hidden, external, has_children, - expanded, weight, - module, link_title, options, - customized, updated) VALUES ( - '%s', %d, '%s', + db_query("INSERT INTO [{menu_links}] ( + [menu_name], [plid], [link_path], + [hidden], [external], [has_children], + [expanded], [weight], + [module], [link_title], [options], + [customized], [updated]) VALUES ( + %s, %d, %s, %d, %d, %d, %d, %d, - '%s', '%s', '%s', %d, %d)", + %s, %s, %s, %d, %d)", $item['menu_name'], $item['plid'], $item['link_path'], $item['hidden'], $item['_external'], $item['has_children'], $item['expanded'], $item['weight'], @@ -2014,11 +2014,11 @@ function menu_link_save(&$item) { $item['router_path'] = _menu_find_router_path($menu, $item['link_path']); } } - db_query("UPDATE {menu_links} SET menu_name = '%s', plid = %d, link_path = '%s', - router_path = '%s', hidden = %d, external = %d, has_children = %d, - expanded = %d, weight = %d, depth = %d, - p1 = %d, p2 = %d, p3 = %d, p4 = %d, p5 = %d, p6 = %d, p7 = %d, p8 = %d, p9 = %d, - module = '%s', link_title = '%s', options = '%s', customized = %d WHERE mlid = %d", + db_query("UPDATE [{menu_links}] SET [menu_name] = %s, [plid] = %d, [link_path] = %s, + [router_path] = %s, [hidden] = %d, [external] = %d, [has_children] = %d, + [expanded] = %d, [weight] = %d, [depth] = %d, + [p1] = %d, [p2] = %d, [p3] = %d, [p4] = %d, [p5] = %d, [p6] = %d, [p7] = %d, [p8] = %d, [p9] = %d, + [module] = %s, [link_title] = %s, [options] = %s, [customized] = %d WHERE [mlid] = %d", $item['menu_name'], $item['plid'], $item['link_path'], $item['router_path'], $item['hidden'], $item['_external'], $item['has_children'], $item['expanded'], $item['weight'], $item['depth'], @@ -2062,7 +2062,7 @@ function _menu_clear_page_cache() { */ function _menu_set_expanded_menus() { $names = array(); - $result = db_query("SELECT menu_name FROM {menu_links} WHERE expanded <> 0 GROUP BY menu_name"); + $result = db_query("SELECT [menu_name] FROM [{menu_links}] WHERE [expanded] <> 0 GROUP BY [menu_name]"); while ($n = db_fetch_array($result)) { $names[] = $n['menu_name']; } @@ -2121,8 +2121,8 @@ function menu_link_maintain($module, $op return menu_link_save($menu_link); break; case 'update': - db_query("UPDATE {menu_links} SET link_title = '%s' WHERE link_path = '%s' AND customized = 0 AND module = '%s'", $link_title, $link_path, $module); - $result = db_query("SELECT menu_name FROM {menu_links} WHERE link_path = '%s' AND customized = 0 AND module = '%s'", $link_path, $module); + db_query("UPDATE [{menu_links}] SET [link_title] = %s WHERE [link_path] = %s AND [customized] = 0 AND [module] = %s", $link_title, $link_path, $module); + $result = db_query("SELECT [menu_name] FROM [{menu_links}] WHERE [link_path] = %s AND [customized] = 0 AND [module] = %s", $link_path, $module); while ($item = db_fetch_array($result)) { menu_cache_clear($item['menu_name']); } @@ -2151,12 +2151,12 @@ function menu_link_children_relative_dep $args[] = $item['menu_name']; $p = 'p1'; while ($i <= MENU_MAX_DEPTH && $item[$p]) { - $match .= " AND $p = %d"; + $match .= " AND [$p] = %d"; $args[] = $item[$p]; $p = 'p' . ++$i; } - $max_depth = db_result(db_query_range("SELECT depth FROM {menu_links} WHERE menu_name = '%s'" . $match . " ORDER BY depth DESC", $args, 0, 1)); + $max_depth = db_result(db_query_range("SELECT [depth] FROM [{menu_links}] WHERE [menu_name] = %s" . $match . " ORDER BY [depth] DESC", $args, 0, 1)); return ($max_depth > $item['depth']) ? $max_depth - $item['depth'] : 0; } @@ -2170,26 +2170,26 @@ function menu_link_children_relative_dep function _menu_link_move_children($item, $existing_item) { $args[] = $item['menu_name']; - $set[] = "menu_name = '%s'"; + $set[] = "[menu_name] = %s"; $i = 1; while ($i <= $item['depth']) { $p = 'p' . $i++; - $set[] = "$p = %d"; + $set[] = "[$p] = %d"; $args[] = $item[$p]; } $j = $existing_item['depth'] + 1; while ($i <= MENU_MAX_DEPTH && $j <= MENU_MAX_DEPTH) { - $set[] = 'p' . $i++ . ' = p' . $j++; + $set[] = '[p' . $i++ . '] = [p' . $j++ . ']'; } while ($i <= MENU_MAX_DEPTH) { - $set[] = 'p' . $i++ . ' = 0'; + $set[] = '[p' . $i++ . '] = 0'; } $shift = $item['depth'] - $existing_item['depth']; if ($shift < 0) { $args[] = -$shift; - $set[] = 'depth = depth - %d'; + $set[] = '[depth] = [depth] - %d'; } elseif ($shift > 0) { // The order of $set must be reversed so the new values don't overwrite the @@ -2200,17 +2200,17 @@ function _menu_link_move_children($item, $args = array_reverse($args); $args[] = $shift; - $set[] = 'depth = depth + %d'; + $set[] = '[depth] = [depth] + %d'; } - $where[] = "menu_name = '%s'"; + $where[] = "[menu_name] = %s"; $args[] = $existing_item['menu_name']; $p = 'p1'; for ($i = 1; $i <= MENU_MAX_DEPTH && $existing_item[$p]; $p = 'p' . ++$i) { - $where[] = "$p = %d"; + $where[] = "[$p] = %d"; $args[] = $existing_item[$p]; } - db_query("UPDATE {menu_links} SET " . implode(', ', $set) . " WHERE " . implode(' AND ', $where), $args); + db_query("UPDATE [{menu_links}] SET " . implode(', ', $set) . " WHERE " . implode(' AND ', $where), $args); // Check the has_children status of the parent, while excluding this item. _menu_update_parental_status($existing_item, TRUE); } @@ -2234,7 +2234,7 @@ function _menu_update_parental_status($i } $parent_has_children = ((bool) $query->execute()->fetchField()) ? 1 : 0; - db_query("UPDATE {menu_links} SET has_children = %d WHERE mlid = %d", $parent_has_children, $item['plid']); + db_query("UPDATE [{menu_links}] SET [has_children] = %d WHERE [mlid] = %d", $parent_has_children, $item['plid']); } } @@ -2344,7 +2344,7 @@ function _menu_router_build($callbacks) return array(); } // Delete the existing router since we have some data to replace it. - db_query('DELETE FROM {menu_router}'); + db_query('DELETE FROM [{menu_router}]'); // Apply inheritance rules. foreach ($menu as $path => $v) { $item = &$menu[$path]; @@ -2411,17 +2411,17 @@ function _menu_router_build($callbacks) ); $title_arguments = $item['title arguments'] ? serialize($item['title arguments']) : ''; - db_query("INSERT INTO {menu_router} - (path, load_functions, to_arg_functions, access_callback, - access_arguments, page_callback, page_arguments, fit, - number_parts, tab_parent, tab_root, - title, title_callback, title_arguments, - type, block_callback, description, position, weight) - VALUES ('%s', '%s', '%s', '%s', - '%s', '%s', '%s', %d, - %d, '%s', '%s', - '%s', '%s', '%s', - %d, '%s', '%s', '%s', %d)", + db_query("INSERT INTO [{menu_router}] + ([path], [load_functions], [to_arg_functions], [access_callback], + [access_arguments], [page_callback], [page_arguments], [fit], + [number_parts], [tab_parent], [tab_root], + [title], [title_callback], [title_arguments], + [type], [block_callback], [description], [position], [weight]) + VALUES (%s, %s, %s, %s, + %s, %s, %s, %d, + %d, %s, %s, + %s, %s, %s, + %d, %s, %s, %s, %d)", $path, $item['load_functions'], $item['to_arg_functions'], $item['access callback'], serialize($item['access arguments']), $item['page callback'], serialize($item['page arguments']), $item['_fit'], $item['_number_parts'], $item['tab_parent'], $item['tab_root'], @@ -2498,7 +2498,7 @@ function menu_valid_path($form_item) { } elseif (preg_match('/\/\%/', $path)) { // Path is dynamic (ie 'user/%'), so check directly against menu_router table. - if ($item = db_fetch_array(db_query("SELECT * FROM {menu_router} where path = '%s' ", $path))) { + if ($item = db_fetch_array(db_query("SELECT * FROM [{menu_router}] where [path] = %s ", $path))) { $item['link_path'] = $form_item['link_path']; $item['link_title'] = $form_item['link_title']; $item['external'] = FALSE; Index: includes/module.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/module.inc,v retrieving revision 1.127 diff -u -p -r1.127 module.inc --- includes/module.inc 27 Sep 2008 19:03:30 -0000 1.127 +++ includes/module.inc 28 Sep 2008 16:44:06 -0000 @@ -49,10 +49,10 @@ function module_list($refresh = FALSE, $ } else { if ($bootstrap) { - $result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, filename ASC"); + $result = db_query("SELECT [name], [filename] FROM [{system}] WHERE [type] = 'module' AND [status] = 1 AND [bootstrap] = 1 ORDER BY [weight] ASC, [filename] ASC"); } else { - $result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC"); + $result = db_query("SELECT [name], [filename] FROM [{system}] WHERE [type] = 'module' AND [status] = 1 ORDER BY [weight] ASC, [filename] ASC"); } while ($module = db_fetch_object($result)) { if (file_exists($module->filename)) { @@ -124,12 +124,12 @@ function module_rebuild_cache() { // Update the contents of the system table: if (isset($file->status) || (isset($file->old_filename) && $file->old_filename != $file->filename)) { - db_query("UPDATE {system} SET info = '%s', name = '%s', filename = '%s', bootstrap = %d WHERE filename = '%s'", serialize($files[$filename]->info), $file->name, $file->filename, $bootstrap, $file->old_filename); + db_query("UPDATE [{system}] SET [info] = %s, [name] = %s, [filename] = %s, [bootstrap] = %d WHERE [filename] = %s", serialize($files[$filename]->info), $file->name, $file->filename, $bootstrap, $file->old_filename); } else { // This is a new module. $files[$filename]->status = 0; - db_query("INSERT INTO {system} (name, info, type, filename, status, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d)", $file->name, serialize($files[$filename]->info), 'module', $file->filename, 0, $bootstrap); + db_query("INSERT INTO [{system}] ([name], [info], [type], [filename], [status], [bootstrap]) VALUES (%s, %s, %s, %s, %d, %d)", $file->name, serialize($files[$filename]->info), 'module', $file->filename, 0, $bootstrap); } } $files = _module_build_dependencies($files); @@ -271,10 +271,10 @@ function module_load_all_includes($type, function module_enable($module_list) { $invoke_modules = array(); foreach ($module_list as $module) { - $existing = db_fetch_object(db_query("SELECT status FROM {system} WHERE type = '%s' AND name = '%s'", 'module', $module)); + $existing = db_fetch_object(db_query("SELECT [status] FROM [{system}] WHERE [type] = %s AND [name] = %s", 'module', $module)); if ($existing->status == 0) { module_load_install($module); - db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 1, 'module', $module); + db_query("UPDATE [{system}] SET [status] = %d WHERE [type] = %s AND [name] = %s", 1, 'module', $module); drupal_load('module', $module); $invoke_modules[] = $module; } @@ -316,7 +316,7 @@ function module_disable($module_list) { module_load_install($module); module_invoke($module, 'disable'); - db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 0, 'module', $module); + db_query("UPDATE [{system}] SET [status] = %d WHERE [type] = %s AND [name] = %s", 0, 'module', $module); $invoke_modules[] = $module; } } Index: includes/path.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/path.inc,v retrieving revision 1.24 diff -u -p -r1.24 path.inc --- includes/path.inc 24 Jun 2008 22:12:15 -0000 1.24 +++ includes/path.inc 28 Sep 2008 16:44:06 -0000 @@ -52,7 +52,7 @@ function drupal_lookup_path($action, $pa // Use $count to avoid looking up paths in subsequent calls if there simply are no aliases if (!isset($count)) { - $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}')); + $count = db_result(db_query('SELECT COUNT([pid]) FROM [{url_alias}]')); } if ($action == 'wipe') { @@ -65,7 +65,7 @@ function drupal_lookup_path($action, $pa return $map[$path_language][$path]; } // Get the most fitting result falling back with alias without language - $alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s' AND language IN('%s', '') ORDER BY language DESC", $path, $path_language)); + $alias = db_result(db_query("SELECT [dst] FROM [{url_alias}] WHERE [src] = %s AND [language] IN(%s, %s) ORDER BY [language] DESC", $path, $path_language, '')); $map[$path_language][$path] = $alias; return $alias; } @@ -76,7 +76,7 @@ function drupal_lookup_path($action, $pa $src = ''; if (!isset($map[$path_language]) || !($src = array_search($path, $map[$path_language]))) { // Get the most fitting result falling back with alias without language - if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s' AND language IN('%s', '') ORDER BY language DESC", $path, $path_language))) { + if ($src = db_result(db_query("SELECT [src] FROM [{url_alias}] WHERE [dst] = %s AND [language] IN(%s, %s) ORDER BY [language] DESC", $path, $path_language, ''))) { $map[$path_language][$src] = $path; } else { Index: includes/registry.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/registry.inc,v retrieving revision 1.5 diff -u -p -r1.5 registry.inc --- includes/registry.inc 20 Sep 2008 20:22:23 -0000 1.5 +++ includes/registry.inc 28 Sep 2008 16:44:06 -0000 @@ -76,7 +76,7 @@ function _registry_rebuild() { function registry_get_parsed_files() { $files = array(); // We want the result as a keyed array. - $files = db_query("SELECT * FROM {registry_file}")->fetchAllAssoc('filename', PDO::FETCH_ASSOC); + $files = db_query("SELECT * FROM [{registry_file}]")->fetchAllAssoc('filename', PDO::FETCH_ASSOC); return $files; } Index: includes/session.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/session.inc,v retrieving revision 1.60 diff -u -p -r1.60 session.inc --- includes/session.inc 27 Sep 2008 20:37:00 -0000 1.60 +++ includes/session.inc 28 Sep 2008 16:44:06 -0000 @@ -83,7 +83,7 @@ function _sess_read($key) { // Otherwise, if the session is still active, we have a record of the // client's session in the database. - $user = db_fetch_object(db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = '%s'", $key)); + $user = db_fetch_object(db_query("SELECT u.*, s.* FROM [{users}] u INNER JOIN [{sessions}] s ON u.[uid] = s.[uid] WHERE s.[sid] = %s", $key)); // We found the client's session record and they are an authenticated user. if ($user && $user->uid > 0) { @@ -93,7 +93,7 @@ function _sess_read($key) { // Add roles element to $user. $user->roles = array(); $user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user'; - $result = db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d", $user->uid); + $result = db_query("SELECT r.[rid], r.[name] FROM [{role}] r INNER JOIN [{users_roles}] ur ON ur.[rid] = r.[rid] WHERE ur.[uid] = %d", $user->uid); while ($role = db_fetch_object($result)) { $user->roles[$role->rid] = $role->name; } @@ -136,7 +136,7 @@ function _sess_write($key, $value) { return TRUE; } - $result = db_result(db_query("SELECT COUNT(*) FROM {sessions} WHERE sid = '%s'", $key)); + $result = db_result(db_query("SELECT COUNT(*) FROM [{sessions}] WHERE [sid] = %s", $key)); if (!$result) { // Only save session data when when the browser sends a cookie. This keeps @@ -144,18 +144,18 @@ function _sess_write($key, $value) { // and gives more useful statistics. We can't eliminate anonymous session // table rows without breaking "Who's Online" block. if ($user->uid || $value || count($_COOKIE)) { - db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, REQUEST_TIME); + db_query("INSERT INTO [{sessions}] ([sid], [uid], [cache], [hostname], [session], [timestamp]) VALUES (%s, %d, %d, %s, %s, %d)", $key, $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, REQUEST_TIME); } } else { - db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, REQUEST_TIME, $key); + db_query("UPDATE [{sessions}] SET [uid] = %d, [cache] = %d, [hostname] = %s, [session] = %s, [timestamp] = %d WHERE [sid] = %s", $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, REQUEST_TIME, $key); if (db_affected_rows()) { // Last access time is updated no more frequently // than once every 180 seconds. // This reduces contention in the users table. if ($user->uid && REQUEST_TIME - $user->access > variable_get('session_write_interval', 180)) { - db_query("UPDATE {users} SET access = %d WHERE uid = %d", REQUEST_TIME, $user->uid); + db_query("UPDATE [{users}] SET [access] = %d WHERE [uid] = %d", REQUEST_TIME, $user->uid); } } } @@ -169,7 +169,7 @@ function _sess_write($key, $value) { function drupal_session_regenerate() { $old_session_id = session_id(); session_regenerate_id(); - db_query("UPDATE {sessions} SET sid = '%s' WHERE sid = '%s'", session_id(), $old_session_id); + db_query("UPDATE [{sessions}] SET [sid] = %s WHERE [sid] = %s", session_id(), $old_session_id); } /** @@ -189,8 +189,8 @@ function drupal_session_regenerate() { * The number of users with sessions. */ function drupal_session_count($timestamp = 0, $anonymous = TRUE) { - $query = $anonymous ? ' AND uid = 0' : ' AND uid > 0'; - return db_result(db_query('SELECT COUNT(sid) AS count FROM {sessions} WHERE timestamp >= %d' . $query, $timestamp)); + $query = $anonymous ? ' AND [uid] = 0' : ' AND [uid] > 0'; + return db_result(db_query('SELECT COUNT([sid]) AS [count] FROM [{sessions}] WHERE [timestamp] >= %d' . $query, $timestamp)); } /** @@ -202,7 +202,7 @@ function drupal_session_count($timestamp * Session ID. */ function _sess_destroy_sid($sid) { - db_query("DELETE FROM {sessions} WHERE sid = '%s'", $sid); + db_query("DELETE FROM [{sessions}] WHERE [sid] = %s", $sid); } /** @@ -212,7 +212,7 @@ function _sess_destroy_sid($sid) { * User ID. */ function drupal_session_destroy_uid($uid) { - db_query('DELETE FROM {sessions} WHERE uid = %d', $uid); + db_query('DELETE FROM [{sessions}] WHERE [uid] = %d', $uid); } /** @@ -230,7 +230,7 @@ function _sess_gc($lifetime) { // for three weeks before deleting them, you need to set gc_maxlifetime // to '1814400'. At that value, only after a user doesn't log in after // three weeks (1814400 seconds) will his/her session be removed. - db_query("DELETE FROM {sessions} WHERE timestamp < %d", REQUEST_TIME - $lifetime); + db_query("DELETE FROM [{sessions}] WHERE [timestamp] < %d", REQUEST_TIME - $lifetime); return TRUE; } Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.437 diff -u -p -r1.437 theme.inc --- includes/theme.inc 20 Sep 2008 20:22:23 -0000 1.437 +++ includes/theme.inc 28 Sep 2008 16:44:06 -0000 @@ -436,7 +436,7 @@ function list_themes($refresh = FALSE) { // Extract from the database only when it is available. // Also check that the site is not in the middle of an install or update. if (db_is_active() && !defined('MAINTENANCE_MODE')) { - $result = db_query("SELECT * FROM {system} WHERE type = '%s'", 'theme'); + $result = db_query("SELECT * FROM [{system}] WHERE [type] = %s", 'theme'); while ($theme = db_fetch_object($result)) { if (file_exists($theme->filename)) { $theme->info = unserialize($theme->info); Index: modules/aggregator/aggregator.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.admin.inc,v retrieving revision 1.16 diff -u -p -r1.16 aggregator.admin.inc --- modules/aggregator/aggregator.admin.inc 17 Sep 2008 07:11:56 -0000 1.16 +++ modules/aggregator/aggregator.admin.inc 28 Sep 2008 16:44:06 -0000 @@ -20,7 +20,7 @@ function aggregator_admin_overview() { * The page HTML. */ function aggregator_view() { - $result = db_query('SELECT f.*, COUNT(i.iid) AS items FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.hash, f.etag, f.modified, f.image, f.block ORDER BY f.title'); + $result = db_query('SELECT f.*, COUNT(i.[iid]) AS [items] FROM [{aggregator_feed}] f LEFT JOIN [{aggregator_item}] i ON f.[fid] = i.[fid] GROUP BY f.[fid], f.[title], f.[url], f.[refresh], f.[checked], f.[link], f.[description], f.[hash], f.[etag], f.[modified], f.[image], f.[block] ORDER BY f.[title]'); $output = '

' . t('Feed overview') . '

'; @@ -31,7 +31,7 @@ function aggregator_view() { } $output .= theme('table', $header, $rows); - $result = db_query('SELECT c.cid, c.title, count(ci.iid) as items FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid GROUP BY c.cid, c.title ORDER BY title'); + $result = db_query('SELECT c.[cid], c.[title], COUNT(ci.[iid]) AS [items] FROM [{aggregator_category}] c LEFT JOIN [{aggregator_category_item}] ci ON c.[cid] = ci.[cid] GROUP BY c.[cid], c.[title] ORDER BY [title]'); $output .= '

' . t('Category overview') . '

'; @@ -89,7 +89,7 @@ function aggregator_form_feed(&$form_sta // Handling of categories. $options = array(); $values = array(); - $categories = db_query('SELECT c.cid, c.title, f.fid FROM {aggregator_category} c LEFT JOIN {aggregator_category_feed} f ON c.cid = f.cid AND f.fid = %d ORDER BY title', $edit['fid']); + $categories = db_query('SELECT c.[cid], c.[title], f.[fid] FROM [{aggregator_category}] c LEFT JOIN [{aggregator_category_feed}] f ON c.[cid] = f.[cid] AND f.[fid] = %d ORDER BY [title]', $edit['fid']); while ($category = db_fetch_object($categories)) { $options[$category->cid] = check_plain($category->title); if ($category->fid) $values[] = $category->cid; @@ -133,10 +133,10 @@ function aggregator_form_feed_validate($ } // Check for duplicate titles. if (isset($form_state['values']['fid'])) { - $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE (title = '%s' OR url = '%s') AND fid <> %d", $form_state['values']['title'], $form_state['values']['url'], $form_state['values']['fid']); + $result = db_query("SELECT [title], [url] FROM [{aggregator_feed}] WHERE ([title] = %s OR [url] = %s) AND [fid] <> %d", $form_state['values']['title'], $form_state['values']['url'], $form_state['values']['fid']); } else { - $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = '%s' OR url = '%s'", $form_state['values']['title'], $form_state['values']['url']); + $result = db_query("SELECT [title], [url] FROM [{aggregator_feed}] WHERE [title] = %s OR [url] = %s", $form_state['values']['title'], $form_state['values']['url']); } while ($feed = db_fetch_object($result)) { if (strcasecmp($feed->title, $form_state['values']['title']) == 0) { @@ -257,7 +257,7 @@ function aggregator_form_opml(&$form_sta // Handling of categories. $options = array(); - $categories = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title'); + $categories = db_query('SELECT [cid], [title] FROM [{aggregator_category}] ORDER BY [title]'); while ($category = db_fetch_object($categories)) { $options[$category->cid] = check_plain($category->title); } @@ -323,7 +323,7 @@ function aggregator_form_opml_submit($fo } // Check for duplicate titles or URLs. - $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = '%s' OR url = '%s'", $feed['title'], $feed['url']); + $result = db_query("SELECT [title], [url] FROM [{aggregator_feed}] WHERE [title] = %s OR [url] = %s", $feed['title'], $feed['url']); while ($old = db_fetch_object($result)) { if (strcasecmp($old->title, $feed['title']) == 0) { drupal_set_message(t('A feed named %title already exists.', array('%title' => $old->title)), 'warning'); @@ -458,10 +458,10 @@ function aggregator_form_category_valida if ($form_state['values']['op'] == t('Save')) { // Check for duplicate titles if (isset($form_state['values']['cid'])) { - $category = db_fetch_object(db_query("SELECT cid FROM {aggregator_category} WHERE title = '%s' AND cid <> %d", $form_state['values']['title'], $form_state['values']['cid'])); + $category = db_fetch_object(db_query("SELECT [cid] FROM [{aggregator_category}] WHERE [title] = %s AND [cid] <> %d", $form_state['values']['title'], $form_state['values']['cid'])); } else { - $category = db_fetch_object(db_query("SELECT cid FROM {aggregator_category} WHERE title = '%s'", $form_state['values']['title'])); + $category = db_fetch_object(db_query("SELECT [cid] FROM [{aggregator_category}] WHERE [title] = %s", $form_state['values']['title'])); } if ($category) { form_set_error('title', t('A category named %category already exists. Please enter a unique title.', array('%category' => $form_state['values']['title']))); Index: modules/aggregator/aggregator.module =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v retrieving revision 1.392 diff -u -p -r1.392 aggregator.module --- modules/aggregator/aggregator.module 17 Sep 2008 07:11:56 -0000 1.392 +++ modules/aggregator/aggregator.module 28 Sep 2008 16:44:06 -0000 @@ -262,7 +262,7 @@ function aggregator_init() { * TRUE if there is at least one category and the user has access to them, FALSE otherwise. */ function _aggregator_has_categories() { - return user_access('access news feeds') && db_result(db_query('SELECT COUNT(*) FROM {aggregator_category}')); + return user_access('access news feeds') && db_result(db_query('SELECT COUNT(*) FROM [{aggregator_category}]')); } /** @@ -281,7 +281,7 @@ function aggregator_perm() { * Checks news feeds for updates once their refresh interval has elapsed. */ function aggregator_cron() { - $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < %d', REQUEST_TIME); + $result = db_query('SELECT * FROM [{aggregator_feed}] WHERE [checked] + [refresh] < %d', REQUEST_TIME); while ($feed = db_fetch_array($result)) { aggregator_refresh($feed); } @@ -295,11 +295,11 @@ function aggregator_cron() { function aggregator_block($op = 'list', $delta = '', $edit = array()) { if (user_access('access news feeds')) { if ($op == 'list') { - $result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title'); + $result = db_query('SELECT [cid], [title] FROM [{aggregator_category}] ORDER BY [title]'); while ($category = db_fetch_object($result)) { $block['category-' . $category->cid]['info'] = t('!title category latest items', array('!title' => $category->title)); } - $result = db_query('SELECT fid, title FROM {aggregator_feed} WHERE block <> 0 ORDER BY fid'); + $result = db_query('SELECT [fid], [title] FROM [{aggregator_feed}] WHERE [block] <> 0 ORDER BY [fid]'); while ($feed = db_fetch_object($result)) { $block['feed-' . $feed->fid]['info'] = t('!title feed latest items', array('!title' => $feed->title)); } @@ -307,7 +307,7 @@ function aggregator_block($op = 'list', elseif ($op == 'configure') { list($type, $id) = explode('-', $delta); if ($type == 'category') { - $value = db_result(db_query('SELECT block FROM {aggregator_category} WHERE cid = %d', $id)); + $value = db_result(db_query('SELECT [block] FROM [{aggregator_category}] WHERE [cid] = %d', $id)); $form['block'] = array( '#type' => 'select', '#title' => t('Number of news items in block'), @@ -320,24 +320,24 @@ function aggregator_block($op = 'list', elseif ($op == 'save') { list($type, $id) = explode('-', $delta); if ($type == 'category') { - $value = db_query('UPDATE {aggregator_category} SET block = %d WHERE cid = %d', $edit['block'], $id); + $value = db_query('UPDATE [{aggregator_category}] SET [block] = %d WHERE [cid] = %d', $edit['block'], $id); } } elseif ($op == 'view') { list($type, $id) = explode('-', $delta); switch ($type) { case 'feed': - if ($feed = db_fetch_object(db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = %d', $id))) { + if ($feed = db_fetch_object(db_query('SELECT [fid], [title], [block] FROM [{aggregator_feed}] WHERE [block] <> 0 AND [fid] = %d', $id))) { $block['subject'] = check_plain($feed->title); - $result = db_query_range('SELECT * FROM {aggregator_item} WHERE fid = %d ORDER BY timestamp DESC, iid DESC', $feed->fid, 0, $feed->block); + $result = db_query_range('SELECT * FROM [{aggregator_item}] WHERE [fid] = %d ORDER BY [timestamp] DESC, [iid] DESC', $feed->fid, 0, $feed->block); $read_more = theme('more_link', url('aggregator/sources/' . $feed->fid), t("View this feed's recent news.")); } break; case 'category': - if ($category = db_fetch_object(db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = %d', $id))) { + if ($category = db_fetch_object(db_query('SELECT [cid], [title], [block] FROM [{aggregator_category}] WHERE [cid] = %d', $id))) { $block['subject'] = check_plain($category->title); - $result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = %d ORDER BY i.timestamp DESC, i.iid DESC', $category->cid, 0, $category->block); + $result = db_query_range('SELECT i.* FROM [{aggregator_category_item}] ci LEFT JOIN [{aggregator_item}] i ON ci.[iid] = i.[iid] WHERE ci.[cid] = %d ORDER BY i.[timestamp] DESC, i.[iid] DESC', $category->cid, 0, $category->block); $read_more = theme('more_link', url('aggregator/categories/' . $category->cid), t("View this category's recent news.")); } break; @@ -369,20 +369,20 @@ function aggregator_save_category($edit) if (!empty($edit['cid'])) { $link_path .= $edit['cid']; if (!empty($edit['title'])) { - db_query("UPDATE {aggregator_category} SET title = '%s', description = '%s' WHERE cid = %d", $edit['title'], $edit['description'], $edit['cid']); + db_query("UPDATE [{aggregator_category}] SET [title] = %s, [description] = %s WHERE [cid] = %d", $edit['title'], $edit['description'], $edit['cid']); $op = 'update'; } else { - db_query('DELETE FROM {aggregator_category} WHERE cid = %d', $edit['cid']); + db_query('DELETE FROM [{aggregator_category}] WHERE [cid] = %d', $edit['cid']); // Make sure there is no active block for this category. - db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s'", 'aggregator', 'category-' . $edit['cid']); + db_query("DELETE FROM [{blocks}] WHERE [module] = %s AND [delta] = %s", 'aggregator', 'category-' . $edit['cid']); $edit['title'] = ''; $op = 'delete'; } } elseif (!empty($edit['title'])) { // A single unique id for bundles and feeds, to use in blocks. - db_query("INSERT INTO {aggregator_category} (title, description, block) VALUES ('%s', '%s', 5)", $edit['title'], $edit['description']); + db_query("INSERT INTO [{aggregator_category}] ([title], [description], [block]) VALUES (%s, %s, 5)", $edit['title'], $edit['description']); $link_path .= db_last_insert_id('aggregator_category', 'cid'); $op = 'insert'; } @@ -400,27 +400,27 @@ function aggregator_save_category($edit) function aggregator_save_feed($edit) { if (!empty($edit['fid'])) { // An existing feed is being modified, delete the category listings. - db_query('DELETE FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']); + db_query('DELETE FROM [{aggregator_category_feed}] WHERE [fid] = %d', $edit['fid']); } if (!empty($edit['fid']) && !empty($edit['title'])) { - db_query("UPDATE {aggregator_feed} SET title = '%s', url = '%s', refresh = %d, block = %d WHERE fid = %d", $edit['title'], $edit['url'], $edit['refresh'], $edit['block'], $edit['fid']); + db_query("UPDATE [{aggregator_feed}] SET [title] = %s, [url] = %s, [refresh] = %d, [block] = %d WHERE [fid] = %d", $edit['title'], $edit['url'], $edit['refresh'], $edit['block'], $edit['fid']); } elseif (!empty($edit['fid'])) { $items = array(); - $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $edit['fid']); + $result = db_query('SELECT [iid] FROM [{aggregator_item}] WHERE [fid] = %d', $edit['fid']); while ($item = db_fetch_object($result)) { - $items[] = "iid = $item->iid"; + $items[] = "[iid] = $item->iid"; } if (!empty($items)) { - db_query('DELETE FROM {aggregator_category_item} WHERE ' . implode(' OR ', $items)); + db_query('DELETE FROM [{aggregator_category_item}] WHERE ' . implode(' OR ', $items)); } - db_query('DELETE FROM {aggregator_feed} WHERE fid = %d', $edit['fid']); - db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $edit['fid']); + db_query('DELETE FROM [{aggregator_feed}] WHERE [fid] = %d', $edit['fid']); + db_query('DELETE FROM [{aggregator_item}] WHERE [fid] = %d', $edit['fid']); // Make sure there is no active block for this feed. - db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s'", 'aggregator', 'feed-' . $edit['fid']); + db_query("DELETE FROM [{blocks}] WHERE [module] = %s AND [delta] = %s", 'aggregator', 'feed-' . $edit['fid']); } elseif (!empty($edit['title'])) { - db_query("INSERT INTO {aggregator_feed} (title, url, refresh, block, description, image) VALUES ('%s', '%s', %d, %d, '', '')", $edit['title'], $edit['url'], $edit['refresh'], $edit['block']); + db_query("INSERT INTO [{aggregator_feed}] ([title], [url], [refresh], [block], [description], [image]) VALUES (%s, %s, %d, %d, %s, %s)", $edit['title'], $edit['url'], $edit['refresh'], $edit['block'], '', ''); // A single unique ID for bundles and feeds, to use in blocks. $edit['fid'] = db_last_insert_id('aggregator_feed', 'fid'); } @@ -429,7 +429,7 @@ function aggregator_save_feed($edit) { if (!empty($edit['category'])) { foreach ($edit['category'] as $cid => $value) { if ($value) { - db_query('INSERT INTO {aggregator_category_feed} (fid, cid) VALUES (%d, %d)', $edit['fid'], $cid); + db_query('INSERT INTO [{aggregator_category_feed}] ([fid], [cid]) VALUES (%d, %d)', $edit['fid'], $cid); } } } @@ -443,15 +443,15 @@ function aggregator_save_feed($edit) { * An associative array describing the feed to be cleared. */ function aggregator_remove($feed) { - $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $feed['fid']); + $result = db_query('SELECT [iid] FROM [{aggregator_item}] WHERE [fid] = %d', $feed['fid']); while ($item = db_fetch_object($result)) { - $items[] = "iid = $item->iid"; + $items[] = "[iid] = $item->iid"; } if (!empty($items)) { - db_query('DELETE FROM {aggregator_category_item} WHERE ' . implode(' OR ', $items)); + db_query('DELETE FROM [{aggregator_category_item}] WHERE ' . implode(' OR ', $items)); } - db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $feed['fid']); - db_query("UPDATE {aggregator_feed} SET checked = 0, hash = '', etag = '', modified = 0 WHERE fid = %d", $feed['fid']); + db_query('DELETE FROM [{aggregator_item}] WHERE [fid] = %d', $feed['fid']); + db_query("UPDATE [{aggregator_feed}] SET [checked] = %d, [hash] = %s, [etag] = %s, [modified] = %d WHERE [fid] = %d", 0, '', '', 0, $feed['fid']); drupal_set_message(t('The news items from %site have been removed.', array('%site' => $feed['title']))); } @@ -592,7 +592,7 @@ function aggregator_refresh($feed) { // Process HTTP response code. switch ($result->code) { case 304: - db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', REQUEST_TIME, $feed['fid']); + db_query('UPDATE [{aggregator_feed}] SET [checked] = %d WHERE [fid] = %d', REQUEST_TIME, $feed['fid']); drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed['title']))); break; case 301: @@ -606,7 +606,7 @@ function aggregator_refresh($feed) { // data. If both are equal we say that feed is not updated. $md5 = md5($result->data); if ($feed['hash'] == $md5) { - db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', REQUEST_TIME, $feed['fid']); + db_query('UPDATE [{aggregator_feed}] SET [checked] = %d WHERE [fid] = %d', REQUEST_TIME, $feed['fid']); drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed['title']))); break; } @@ -636,7 +636,7 @@ function aggregator_refresh($feed) { $etag = empty($result->headers['ETag']) ? '' : $result->headers['ETag']; // Update the feed data. - db_query("UPDATE {aggregator_feed} SET url = '%s', checked = %d, link = '%s', description = '%s', image = '%s', hash = '%s', etag = '%s', modified = %d WHERE fid = %d", $feed['url'], REQUEST_TIME, $channel['LINK'], $channel['DESCRIPTION'], $image, $md5, $etag, $modified, $feed['fid']); + db_query("UPDATE [{aggregator_feed}] SET [url] = %s, [checked] = %d, [link] = %s, [description] = %s, [image] = %s, [hash] = %s, [etag] = %s, [modified] = %d WHERE [fid] = %d", $feed['url'], REQUEST_TIME, $channel['LINK'], $channel['DESCRIPTION'], $image, $md5, $etag, $modified, $feed['fid']); // Clear the cache. cache_clear_all(); @@ -793,13 +793,13 @@ function aggregator_parse_feed(&$data, $ // we find a duplicate entry, we resolve it and pass along its ID is such // that we can update it if needed. if (!empty($guid)) { - $entry = db_fetch_object(db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = %d AND guid = '%s'", $feed['fid'], $guid)); + $entry = db_fetch_object(db_query("SELECT [iid], [timestamp] FROM [{aggregator_item}] WHERE [fid] = %d AND [guid] = %s", $feed['fid'], $guid)); } else if ($link && $link != $feed['link'] && $link != $feed['url']) { - $entry = db_fetch_object(db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = %d AND link = '%s'", $feed['fid'], $link)); + $entry = db_fetch_object(db_query("SELECT [iid], [timestamp] FROM [{aggregator_item}] WHERE [fid] = %d AND [link] = %s", $feed['fid'], $link)); } else { - $entry = db_fetch_object(db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = %d AND title = '%s'", $feed['fid'], $title)); + $entry = db_fetch_object(db_query("SELECT [iid], [timestamp] FROM [{aggregator_item}] WHERE [fid] = %d AND [title] = %s", $feed['fid'], $title)); } if (!$timestamp) { @@ -811,7 +811,7 @@ function aggregator_parse_feed(&$data, $ // Remove all items that are older than flush item timer. $age = REQUEST_TIME - variable_get('aggregator_clear', 9676800); - $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age); + $result = db_query('SELECT [iid] FROM [{aggregator_item}] WHERE [fid] = %d AND [timestamp] < %d', $feed['fid'], $age); $items = array(); $num_rows = FALSE; @@ -820,8 +820,8 @@ function aggregator_parse_feed(&$data, $ $num_rows = TRUE; } if ($num_rows) { - db_query('DELETE FROM {aggregator_category_item} WHERE iid IN (' . implode(', ', $items) . ')'); - db_query('DELETE FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age); + db_query('DELETE FROM [{aggregator_category_item}] WHERE [iid] IN (' . implode(', ', $items) . ')'); + db_query('DELETE FROM [{aggregator_item}] WHERE [fid] = %d AND [timestamp] < %d', $feed['fid'], $age); } return TRUE; @@ -835,19 +835,19 @@ function aggregator_parse_feed(&$data, $ */ function aggregator_save_item($edit) { if ($edit['iid'] && $edit['title']) { - db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['guid'], $edit['timestamp'], $edit['iid']); + db_query("UPDATE [{aggregator_item}] SET [title] = %s, [link] = %s, [author] = %s, [description] = %s, [guid] = %s, [timestamp] = %d WHERE [iid] = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['guid'], $edit['timestamp'], $edit['iid']); } elseif ($edit['iid']) { - db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']); - db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $edit['iid']); + db_query('DELETE FROM [{aggregator_item}] WHERE [iid] = %d', $edit['iid']); + db_query('DELETE FROM [{aggregator_category_item}] WHERE [iid] = %d', $edit['iid']); } elseif ($edit['title'] && $edit['link']) { - db_query("INSERT INTO {aggregator_item} (fid, title, link, author, description, timestamp, guid) VALUES (%d, '%s', '%s', '%s', '%s', %d, '%s')", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp'], $edit['guid']); + db_query("INSERT INTO [{aggregator_item}] ([fid], [title], [link], [author], [description], [timestamp], [guid]) VALUES (%d, %s, %s, %s, %s, %d, %s)", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp'], $edit['guid']); $edit['iid'] = db_last_insert_id('aggregator_item', 'iid'); // file the items in the categories indicated by the feed - $categories = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']); + $categories = db_query('SELECT [cid] FROM [{aggregator_category_feed}] WHERE [fid] = %d', $edit['fid']); while ($category = db_fetch_object($categories)) { - db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $category->cid, $edit['iid']); + db_query('INSERT INTO [{aggregator_category_item}] ([cid], [iid]) VALUES (%d, %d)', $category->cid, $edit['iid']); } } } @@ -863,7 +863,7 @@ function aggregator_save_item($edit) { function aggregator_feed_load($fid) { static $feeds; if (!isset($feeds[$fid])) { - $feeds[$fid] = db_fetch_array(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', $fid)); + $feeds[$fid] = db_fetch_array(db_query('SELECT * FROM [{aggregator_feed}] WHERE [fid] = %d', $fid)); } return $feeds[$fid]; @@ -880,7 +880,7 @@ function aggregator_feed_load($fid) { function aggregator_category_load($cid) { static $categories; if (!isset($categories[$cid])) { - $categories[$cid] = db_fetch_array(db_query('SELECT * FROM {aggregator_category} WHERE cid = %d', $cid)); + $categories[$cid] = db_fetch_array(db_query('SELECT * FROM [{aggregator_category}] WHERE [cid] = %d', $cid)); } return $categories[$cid]; Index: modules/aggregator/aggregator.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.pages.inc,v retrieving revision 1.18 diff -u -p -r1.18 aggregator.pages.inc --- modules/aggregator/aggregator.pages.inc 17 Sep 2008 07:11:56 -0000 1.18 +++ modules/aggregator/aggregator.pages.inc 28 Sep 2008 16:44:06 -0000 @@ -15,7 +15,7 @@ function aggregator_page_last() { drupal_add_feed(url('aggregator/rss'), variable_get('site_name', 'Drupal') . ' ' . t('aggregator')); - $items = aggregator_feed_items_load('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC'); + $items = aggregator_feed_items_load('SELECT i.*, f.[title] AS [ftitle], f.[link] AS [flink] FROM [{aggregator_item}] i INNER JOIN [{aggregator_feed}] f ON i.[fid] = f.[fid] ORDER BY i.[timestamp] DESC, i.[iid] DESC'); return _aggregator_page_list($items, arg(1)); } @@ -42,7 +42,7 @@ function aggregator_page_source($arg1, $ // It is safe to include the fid in the query because it's loaded from the // database by aggregator_feed_load. - $items = aggregator_feed_items_load('SELECT * FROM {aggregator_item} WHERE fid = ' . $feed->fid . ' ORDER BY timestamp DESC, iid DESC'); + $items = aggregator_feed_items_load('SELECT * FROM [{aggregator_item}] WHERE [fid] = ' . $feed->fid . ' ORDER BY [timestamp] DESC, [iid] DESC'); return _aggregator_page_list($items, arg(3), $feed_source); } @@ -68,7 +68,7 @@ function aggregator_page_category($arg1, // It is safe to include the cid in the query because it's loaded from the // database by aggregator_category_load. - $items = aggregator_feed_items_load('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = ' . $category['cid'] . ' ORDER BY timestamp DESC, i.iid DESC'); + $items = aggregator_feed_items_load('SELECT i.*, f.[title] AS [ftitle], f.[link] AS [flink] FROM [{aggregator_category_item}] c LEFT JOIN [{aggregator_item}] i ON c.[iid] = i.[iid] LEFT JOIN [{aggregator_feed}] f ON i.[fid] = f.[fid] WHERE [cid] = ' . $category['cid'] . ' ORDER BY [timestamp] DESC, i.[iid] DESC'); return _aggregator_page_list($items, arg(3)); } @@ -86,7 +86,7 @@ function aggregator_feed_items_load($sql if (isset($sql)) { $result = pager_query($sql, 20); while ($item = db_fetch_object($result)) { - $result_category = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = %d ORDER BY c.title', $item->iid); + $result_category = db_query('SELECT c.[title], c.[cid] FROM [{aggregator_category_item}] ci LEFT JOIN [{aggregator_category}] c ON ci.[cid] = c.[cid] WHERE ci.[iid] = %d ORDER BY c.[title]', $item->iid); $item->categories = array(); while ($item_categories = db_fetch_object($result_category)) { $item->categories[] = $item_categories; @@ -158,7 +158,7 @@ function aggregator_categorize_items($it foreach ($items as $item) { $form['items'][$item->iid] = array('#markup' => theme('aggregator_item', $item)); $form['categories'][$item->iid] = array(); - $categories_result = db_query('SELECT c.cid, c.title, ci.iid FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid AND ci.iid = %d', $item->iid); + $categories_result = db_query('SELECT c.[cid], c.[title], ci.[iid] FROM [{aggregator_category}] c LEFT JOIN [{aggregator_category_item}] ci ON c.[cid] = ci.[cid] AND ci.[iid] = %d', $item->iid); $selected = array(); while ($category = db_fetch_object($categories_result)) { if (!$done) { @@ -197,10 +197,10 @@ function aggregator_categorize_items_val function aggregator_categorize_items_submit($form, &$form_state) { if (!empty($form_state['values']['categories'])) { foreach ($form_state['values']['categories'] as $iid => $selection) { - db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $iid); + db_query('DELETE FROM [{aggregator_category_item}] WHERE [iid] = %d', $iid); foreach ($selection as $cid) { if ($cid) { - db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $cid, $iid); + db_query('INSERT INTO [{aggregator_category_item}] ([cid], [iid]) VALUES (%d, %d)', $cid, $iid); } } } @@ -281,14 +281,14 @@ function template_preprocess_aggregator_ * Menu callback; displays all the feeds used by the aggregator. */ function aggregator_page_sources() { - $result = db_query('SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.description, f.image ORDER BY last DESC, f.title'); + $result = db_query('SELECT f.[fid], f.[title], f.[description], f.[image], MAX(i.[timestamp]) AS [last] FROM [{aggregator_feed}] f LEFT JOIN [{aggregator_item}] i ON f.[fid] = i.[fid] GROUP BY f.[fid], f.[title], f.[description], f.[image] ORDER BY [last] DESC, f.[title]'); $output = ''; while ($feed = db_fetch_object($result)) { // Most recent items: $summary_items = array(); if (variable_get('aggregator_summary_items', 3)) { - $items = db_query_range('SELECT i.title, i.timestamp, i.link FROM {aggregator_item} i WHERE i.fid = %d ORDER BY i.timestamp DESC', $feed->fid, 0, variable_get('aggregator_summary_items', 3)); + $items = db_query_range('SELECT i.[title], i.[timestamp], i.[link] FROM [{aggregator_item}] i WHERE i.[fid] = %d ORDER BY i.[timestamp] DESC', $feed->fid, 0, variable_get('aggregator_summary_items', 3)); while ($item = db_fetch_object($items)) { $summary_items[] = theme('aggregator_summary_item', $item); } @@ -305,13 +305,13 @@ function aggregator_page_sources() { * Menu callback; displays all the categories used by the aggregator. */ function aggregator_page_categories() { - $result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY c.cid, c.title, c.description'); + $result = db_query('SELECT c.[cid], c.[title], c.[description] FROM [{aggregator_category}] c LEFT JOIN [{aggregator_category_item}] ci ON c.[cid] = ci.[cid] LEFT JOIN [{aggregator_item}] i ON ci.[iid] = i.[iid] GROUP BY c.[cid], c.[title], c.[description]'); $output = ''; while ($category = db_fetch_object($result)) { if (variable_get('aggregator_summary_items', 3)) { $summary_items = array(); - $items = db_query_range('SELECT i.title, i.timestamp, i.link, f.title as feed_title, f.link as feed_link FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON i.iid = ci.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE ci.cid = %d ORDER BY i.timestamp DESC', $category->cid, 0, variable_get('aggregator_summary_items', 3)); + $items = db_query_range('SELECT i.[title], i.[timestamp], i.[link], f.[title] AS [feed_title], f.[link] AS [feed_link] FROM [{aggregator_category_item}] ci LEFT JOIN [{aggregator_item}] i ON i.[iid] = ci.[iid] LEFT JOIN [{aggregator_feed}] f ON i.[fid] = f.[fid] WHERE ci.[cid] = %d ORDER BY i.[timestamp] DESC', $category->cid, 0, variable_get('aggregator_summary_items', 3)); while ($item = db_fetch_object($items)) { $summary_items[] = theme('aggregator_summary_item', $item); } @@ -330,14 +330,14 @@ function aggregator_page_rss() { $result = NULL; // arg(2) is the passed cid, only select for that category. if (arg(2)) { - $category = db_fetch_object(db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = %d', arg(2))); - $sql = 'SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = %d ORDER BY timestamp DESC, i.iid DESC'; + $category = db_fetch_object(db_query('SELECT [cid], [title] FROM [{aggregator_category}] WHERE [cid] = %d', arg(2))); + $sql = 'SELECT i.*, f.[title] AS [ftitle], f.[link] AS [flink] FROM [{aggregator_category_item}] c LEFT JOIN [{aggregator_item}] i ON c.[iid] = i.[iid] LEFT JOIN [{aggregator_feed}] f ON i.[fid] = f.[fid] WHERE [cid] = %d ORDER BY [timestamp] DESC, i.[iid] DESC'; $result = db_query_range($sql, $category->cid, 0, variable_get('feed_default_items', 10)); } // Or, get the default aggregator items. else { $category = NULL; - $sql = 'SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC'; + $sql = 'SELECT i.*, f.[title] AS [ftitle], f.[link] AS [flink] FROM [{aggregator_item}] i INNER JOIN [{aggregator_feed}] f ON i.[fid] = f.[fid] ORDER BY i.[timestamp] DESC, i.[iid] DESC'; $result = db_query_range($sql, 0, variable_get('feed_default_items', 10)); } @@ -401,10 +401,10 @@ function theme_aggregator_page_rss($feed */ function aggregator_page_opml($cid = NULL) { if ($cid) { - $result = db_query('SELECT f.title, f.url FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} c on f.fid = c.fid WHERE c.cid = %d ORDER BY title', $cid); + $result = db_query('SELECT f.[title], f.[url] FROM [{aggregator_feed}] f LEFT JOIN [{aggregator_category_feed}] c on f.[fid] = c.[fid] WHERE c.[cid] = %d ORDER BY [title]', $cid); } else { - $result = db_query('SELECT * FROM {aggregator_feed} ORDER BY title'); + $result = db_query('SELECT * FROM [{aggregator_feed}] ORDER BY [title]'); } $feeds = array(); Index: modules/aggregator/aggregator.test =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.test,v retrieving revision 1.8 diff -u -p -r1.8 aggregator.test --- modules/aggregator/aggregator.test 15 Sep 2008 21:06:06 -0000 1.8 +++ modules/aggregator/aggregator.test 28 Sep 2008 16:44:06 -0000 @@ -23,7 +23,7 @@ class AggregatorTestCase extends DrupalW $this->drupalPost('admin/content/aggregator/add/feed', $edit, t('Save')); $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title'])), t('The feed !name has been added.', array('!name' => $edit['title']))); - $feed = db_fetch_object(db_query("SELECT * FROM {aggregator_feed} WHERE title = '%s' AND url='%s'", $edit['title'], $edit['url'])); + $feed = db_fetch_object(db_query("SELECT * FROM [{aggregator_feed}] WHERE [title] = %s AND [url] = %s", $edit['title'], $edit['url'])); $this->assertTrue(!empty($feed), t('The feed found in database.')); return $feed; } @@ -65,14 +65,14 @@ class AggregatorTestCase extends DrupalW $this->assertResponse(200, t('rss.xml is reachable.')); // Our tests are based off of rss.xml, so let's find out how many elements should be related. - $feed_count = db_result(db_query_range(db_rewrite_sql('SELECT COUNT(*) FROM {node} n WHERE n.promote = 1 AND n.status = 1'), 0, variable_get('feed_default_items', 10))); + $feed_count = db_result(db_query_range(db_rewrite_sql('SELECT COUNT(*) FROM [{node}] n WHERE n.[promote] = 1 AND n.[status] = 1'), 0, variable_get('feed_default_items', 10))); $feed_count = $feed_count > 10 ? 10 : $feed_count; // Refresh the feed (simulated link click). $this->drupalGet('admin/content/aggregator/update/' . $feed->fid); // Ensure we have the right number of items. - $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $feed->fid); + $result = db_query('SELECT [iid] FROM [{aggregator_item}] WHERE [fid] = %d', $feed->fid); $items = array(); $feed->items = array(); while ($item = db_fetch_object($result)) { @@ -99,7 +99,7 @@ class AggregatorTestCase extends DrupalW */ function getFeedCategories($feed) { // add the categories to the feed so we can use them - $result = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $feed->fid); + $result = db_query('SELECT [cid] FROM [{aggregator_category_feed}] WHERE [fid] = %d', $feed->fid); while ($category = db_fetch_object($result)) { $feed->categories[] = $category->cid; } @@ -113,7 +113,7 @@ class AggregatorTestCase extends DrupalW * @return boolean Feed is unique. */ function uniqueFeed($feed_name, $feed_url) { - $result = db_result(db_query("SELECT count(*) FROM {aggregator_feed} WHERE title = '%s' AND url='%s'", $feed_name, $feed_url)); + $result = db_result(db_query("SELECT COUNT(*) FROM [{aggregator_feed}] WHERE [title] = %s AND [url] = %s", $feed_name, $feed_url)); return (1 == $result); } @@ -324,7 +324,7 @@ class RemoveFeedTestCase extends Aggrega $this->assertResponse(404, t('Deleted feed source does not exists.')); // Check database for feed. - $result = db_result(db_query("SELECT count(*) FROM {aggregator_feed} WHERE title = '%s' AND url='%s'", $feed->title, $feed->url)); + $result = db_result(db_query("SELECT COUNT(*) FROM [{aggregator_feed}] WHERE [title] = %s AND [url] = %s", $feed->title, $feed->url)); $this->assertFalse($result, t('Feed not found in database')); } } @@ -366,17 +366,17 @@ class UpdateFeedItemTestCase extends Agg $this->drupalPost('admin/content/aggregator/add/feed', $edit, t('Save')); $this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title'])), t('The feed !name has been added.', array('!name' => $edit['title']))); - $feed = db_fetch_object(db_query("SELECT * FROM {aggregator_feed} WHERE url = '%s'", $edit['url'])); + $feed = db_fetch_object(db_query("SELECT * FROM [{aggregator_feed}] WHERE [url] = %s", $edit['url'])); $this->drupalGet('admin/content/aggregator/update/' . $feed->fid); - $before = db_result(db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = %d', $feed->fid)); + $before = db_result(db_query('SELECT [timestamp] FROM [{aggregator_item}] WHERE [fid] = %d', $feed->fid)); // Sleep for 3 second. sleep(3); - db_query("UPDATE {aggregator_feed} SET checked = 0, hash = '', etag = '', modified = 0 WHERE fid = %d", $feed->fid); + db_query("UPDATE [{aggregator_feed}] SET [checked] = %d, [hash] = %s, [etag] = %s, [modified] = %d WHERE [fid] = %d", 0, '', '', 0, $feed->fid); $this->drupalGet('admin/content/aggregator/update/' . $feed->fid); - $after = db_result(db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = %d', $feed->fid)); + $after = db_result(db_query('SELECT [timestamp] FROM [{aggregator_item}] WHERE [fid] = %d', $feed->fid)); $this->assertTrue($before === $after, t('Publish timestamp of feed item was not updated (!before === !after)', array('!before' => $before, '!after' => $after))); } @@ -403,7 +403,7 @@ class RemoveFeedItemTestCase extends Agg // Add and remove feed items and ensure that the count is zero. $this->updateFeedItems($feed); $this->removeFeedItems($feed); - $count = db_result(db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = %d', $feed->fid)); + $count = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_item}] WHERE [fid] = %d', $feed->fid)); $this->assertTrue($count == 0); // Delete feed. @@ -434,11 +434,11 @@ class CategorizeFeedItemTestCase extends $this->drupalPost('admin/content/aggregator/add/category', $edit, t('Save')); $this->assertRaw(t('The category %title has been added.', array('%title' => $edit['title'])), t('The category %title has been added.', array('%title' => $edit['title']))); - $category = db_fetch_object(db_query("SELECT * FROM {aggregator_category} WHERE title = '%s'", $edit['title'])); + $category = db_fetch_object(db_query("SELECT * FROM [{aggregator_category}] WHERE [title] = %s", $edit['title'])); $this->assertTrue(!empty($category), t('The category found in database.')); $link_path = 'aggregator/categories/' . $category->cid; - $menu_link = db_fetch_object(db_query("SELECT * FROM {menu_links} WHERE link_path = '%s'", $link_path)); + $menu_link = db_fetch_object(db_query("SELECT * FROM [{menu_links}] WHERE [link_path] = %s", $link_path)); $this->assertTrue(!empty($menu_link), t('The menu link associated with the category found in database.')); // TODO: Need to add categories to the feed on creation. @@ -450,7 +450,7 @@ class CategorizeFeedItemTestCase extends if (!empty($feed->categories) && !empty($feed->items)) { foreach ($feed->categories as $category) { $items_str = implode(', ', $feed->items); - $categorized_count = db_result(db_query('SELECT COUNT(*) FROM {aggregator_category_item} WHERE iid IN (' . $items_str . ')')); + $categorized_count = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_category_item}] WHERE [iid] IN (' . $items_str . ')')); $this->assertEqual($feed->item_count, $categorized_count, t('Total items in feed equal to the total categorized feed items in database')); } } @@ -478,10 +478,10 @@ class ImportOPMLTestCase extends Aggrega * Open OPML import form. */ function openImportForm() { - db_query('DELETE FROM {aggregator_category}'); + db_query('DELETE FROM [{aggregator_category}]'); $category = $this->randomName(10, self::$prefix); - db_query("INSERT INTO {aggregator_category} (cid, title, description) VALUES (%d, '%s', '%s')", 1, $category, ''); + db_query("INSERT INTO [{aggregator_category}] ([cid], [title], [description]) VALUES (%d, %s, %s)", 1, $category, ''); $this->drupalGet('admin/content/aggregator/add/opml'); $this->assertText('A single OPML document may contain a collection of many feeds.', t('Looking for help text.')); @@ -495,7 +495,7 @@ class ImportOPMLTestCase extends Aggrega * Submit form filled with invalid fields. */ function validateImportFormFields() { - $before = db_result(db_query('SELECT COUNT(*) FROM {aggregator_feed}')); + $before = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_feed}]')); $form = array(); $this->drupalPost('admin/content/aggregator/add/opml', $form, t('Import')); @@ -513,7 +513,7 @@ class ImportOPMLTestCase extends Aggrega $this->drupalPost('admin/content/aggregator/add/opml', $form, t('Import')); $this->assertText(t('This URL is not valid.'), t('Error if the URL is invalid.')); - $after = db_result(db_query('SELECT COUNT(*) FROM {aggregator_feed}')); + $after = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_feed}]')); $this->assertEqual($before, $after, t('No feeds were added during the three last form submissions.')); } @@ -521,7 +521,7 @@ class ImportOPMLTestCase extends Aggrega * Submit form with invalid, empty and valid OPML files. */ function submitImportForm() { - $before = db_result(db_query('SELECT COUNT(*) FROM {aggregator_feed}')); + $before = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_feed}]')); $form['files[upload]'] = $this->getInvalidOpml(); $this->drupalPost('admin/content/aggregator/add/opml', $form, t('Import')); @@ -531,15 +531,15 @@ class ImportOPMLTestCase extends Aggrega $this->drupalPost('admin/content/aggregator/add/opml', $form, t('Import')); $this->assertText(t('No new feed has been added.'), t('Attempting to load empty OPML from remote URL.')); - $after = db_result(db_query('SELECT COUNT(*) FROM {aggregator_feed}')); + $after = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_feed}]')); $this->assertEqual($before, $after, t('No feeds were added during the two last form submissions.')); - db_query('DELETE FROM {aggregator_feed}'); - db_query('DELETE FROM {aggregator_category}'); - db_query('DELETE FROM {aggregator_category_feed}'); + db_query('DELETE FROM [{aggregator_feed}]'); + db_query('DELETE FROM [{aggregator_category}]'); + db_query('DELETE FROM [{aggregator_category_feed}]'); $category = $this->randomName(10, self::$prefix); - db_query("INSERT INTO {aggregator_category} (cid, title, description) VALUES (%d, '%s', '%s')", 1, $category, ''); + db_query("INSERT INTO [{aggregator_category}] ([cid], [title], [description]) VALUES (%d, %s, %s)", 1, $category, ''); $feeds[0] = $this->getFeedEditArray(); $feeds[1] = $this->getFeedEditArray(); @@ -553,10 +553,10 @@ class ImportOPMLTestCase extends Aggrega $this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url'])), t('Verifying that a duplicate URL was identified')); $this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title'])), t('Verifying that a duplicate title was identified')); - $after = db_result(db_query('SELECT COUNT(*) FROM {aggregator_feed}')); + $after = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_feed}]')); $this->assertEqual($after, 2, t('Verifying that two distinct feeds were added.')); - $feeds_from_db = db_query("SELECT f.title, f.url, f.refresh, cf.cid FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} cf ON f.fid = cf.fid"); + $feeds_from_db = db_query("SELECT f.[title], f.[url], f.[refresh], cf.[cid] FROM [{aggregator_feed}] f LEFT JOIN [{aggregator_category_feed}] cf ON f.[fid] = cf.[fid]"); $refresh = $category = TRUE; while ($feed = db_fetch_array($feeds_from_db)) { $title[$feed['url']] = $feed['title']; Index: modules/block/block.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v retrieving revision 1.19 diff -u -p -r1.19 block.admin.inc --- modules/block/block.admin.inc 16 Jul 2008 21:59:25 -0000 1.19 +++ modules/block/block.admin.inc 28 Sep 2008 16:44:06 -0000 @@ -95,7 +95,7 @@ function block_admin_display_form_submit foreach ($form_state['values'] as $block) { $block['status'] = $block['region'] != BLOCK_REGION_NONE; $block['region'] = $block['status'] ? $block['region'] : ''; - db_query("UPDATE {blocks} SET status = %d, weight = %d, region = '%s' WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $block['status'], $block['weight'], $block['region'], $block['module'], $block['delta'], $block['theme']); + db_query("UPDATE [{blocks}] SET [status] = %d, [weight] = %d, [region] = %s WHERE [module] = %s AND [delta] = %s AND [theme] = %s", $block['status'], $block['weight'], $block['region'], $block['module'], $block['delta'], $block['theme']); } drupal_set_message(t('The block settings have been updated.')); cache_clear_all(); @@ -148,7 +148,7 @@ function block_admin_configure(&$form_st '#value' => $delta, ); - $edit = db_fetch_array(db_query("SELECT pages, visibility, custom, title FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta)); + $edit = db_fetch_array(db_query("SELECT [pages], [visibility], [custom], [title] FROM [{blocks}] WHERE [module] = %s AND [delta] = %s", $module, $delta)); $form['block_settings'] = array( '#type' => 'fieldset', @@ -197,11 +197,11 @@ function block_admin_configure(&$form_st // Role-based visibility settings. $default_role_options = array(); - $result = db_query("SELECT rid FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $module, $delta); + $result = db_query("SELECT [rid] FROM [{blocks_roles}] WHERE [module] = %s AND [delta] = %s", $module, $delta); while ($role = db_fetch_object($result)) { $default_role_options[] = $role->rid; } - $result = db_query('SELECT rid, name FROM {role} ORDER BY name'); + $result = db_query('SELECT [rid], [name] FROM [{role}] ORDER BY [name]'); $role_options = array(); while ($role = db_fetch_object($result)) { $role_options[$role->rid] = $role->name; @@ -263,7 +263,7 @@ function block_admin_configure(&$form_st function block_admin_configure_validate($form, &$form_state) { if ($form_state['values']['module'] == 'block') { - if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE bid != %d AND info = '%s'", $form_state['values']['delta'], $form_state['values']['info']))) { + if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM [{boxes}] WHERE [bid] <> %d AND [info] = %s", $form_state['values']['delta'], $form_state['values']['info']))) { form_set_error('info', t('Please ensure that each block description is unique.')); } } @@ -271,10 +271,10 @@ function block_admin_configure_validate( function block_admin_configure_submit($form, &$form_state) { if (!form_get_errors()) { - db_query("UPDATE {blocks} SET visibility = %d, pages = '%s', custom = %d, title = '%s' WHERE module = '%s' AND delta = '%s'", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $form_state['values']['delta']); - db_query("DELETE FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $form_state['values']['module'], $form_state['values']['delta']); + db_query("UPDATE [{blocks}] SET [visibility] = %d, [pages] = %s, [custom] = %d, [title] = %s WHERE [module] = %s AND [delta] = %s", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $form_state['values']['delta']); + db_query("DELETE FROM [{blocks_roles}] WHERE [module] = %s AND [delta] = %s", $form_state['values']['module'], $form_state['values']['delta']); foreach (array_filter($form_state['values']['roles']) as $rid) { - db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $form_state['values']['delta']); + db_query("INSERT INTO [{blocks_roles}] ([rid], [module], [delta]) VALUES (%d, %s, %s)", $rid, $form_state['values']['module'], $form_state['values']['delta']); } module_invoke($form_state['values']['module'], 'block', 'save', $form_state['values']['delta'], $form_state['values']); drupal_set_message(t('The block configuration has been saved.')); @@ -292,7 +292,7 @@ function block_add_block_form(&$form_sta } function block_add_block_form_validate($form, &$form_state) { - if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE info = '%s'", $form_state['values']['info']))) { + if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM [{boxes}] WHERE [info] = %s", $form_state['values']['info']))) { form_set_error('info', t('Please ensure that each block description is unique.')); } } @@ -301,17 +301,17 @@ function block_add_block_form_validate($ * Save the new custom block. */ function block_add_block_form_submit($form, &$form_state) { - db_query("INSERT INTO {boxes} (body, info, format) VALUES ('%s', '%s', %d)", $form_state['values']['body'], $form_state['values']['info'], $form_state['values']['format']); + db_query("INSERT INTO [{boxes}] ([body], [info], [format]) VALUES (%s, %s, %d)", $form_state['values']['body'], $form_state['values']['info'], $form_state['values']['format']); $delta = db_last_insert_id('boxes', 'bid'); foreach (list_themes() as $key => $theme) { if ($theme->status) { - db_query("INSERT INTO {blocks} (visibility, pages, custom, title, module, theme, status, weight, delta, cache) VALUES(%d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d)", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $theme->name, 0, 0, $delta, BLOCK_NO_CACHE); + db_query("INSERT INTO [{blocks}] ([visibility], [pages], [custom], [title], [module], [theme], [status], [weight], [delta], [cache]) VALUES(%d, %s, %d, %s, %s, %s, %d, %d, %d, %d)", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $theme->name, 0, 0, $delta, BLOCK_NO_CACHE); } } foreach (array_filter($form_state['values']['roles']) as $rid) { - db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $delta); + db_query("INSERT INTO [{blocks_roles}] ([rid], [module], [delta]) VALUES (%d, %s, %s)", $rid, $form_state['values']['module'], $delta); } drupal_set_message(t('The block has been created.')); @@ -337,8 +337,8 @@ function block_box_delete(&$form_state, * Deletion of custom blocks. */ function block_box_delete_submit($form, &$form_state) { - db_query('DELETE FROM {boxes} WHERE bid = %d', $form_state['values']['bid']); - db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = %d", $form_state['values']['bid']); + db_query('DELETE FROM [{boxes}] WHERE [bid] = %d', $form_state['values']['bid']); + db_query("DELETE FROM [{blocks}] WHERE [module] = 'block' AND [delta] = %d", $form_state['values']['bid']); drupal_set_message(t('The block %name has been removed.', array('%name' => $form_state['values']['info']))); cache_clear_all(); $form_state['redirect'] = 'admin/build/block'; Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.310 diff -u -p -r1.310 block.module --- modules/block/block.module 27 Sep 2008 19:47:42 -0000 1.310 +++ modules/block/block.module 28 Sep 2008 16:44:06 -0000 @@ -183,7 +183,7 @@ function block_block($op = 'list', $delt case 'list': $blocks = array(); - $result = db_query('SELECT bid, info FROM {boxes} ORDER BY info'); + $result = db_query('SELECT [bid], [info] FROM [{boxes}] ORDER BY [info]'); while ($block = db_fetch_object($result)) { $blocks[$block->bid]['info'] = $block->info; // Not worth caching. @@ -206,7 +206,7 @@ function block_block($op = 'list', $delt break; case 'view': - $block = db_fetch_object(db_query('SELECT body, format FROM {boxes} WHERE bid = %d', $delta)); + $block = db_fetch_object(db_query('SELECT [body], [format] FROM [{boxes}] WHERE [bid] = %d', $delta)); $data['content'] = check_markup($block->body, $block->format, FALSE); return $data; } @@ -223,7 +223,7 @@ function _block_rehash() { init_theme(); - $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key); + $result = db_query("SELECT * FROM [{blocks}] WHERE [theme] = %s", $theme_key); $old_blocks = array(); while ($old_block = db_fetch_array($result)) { $old_blocks[$old_block['module']][$old_block['delta']] = $old_block; @@ -283,14 +283,14 @@ function _block_rehash() { // Remove blocks that are no longer defined by the code from the database. foreach ($old_blocks as $module => $old_module_blocks) { foreach ($old_module_blocks as $delta => $block) { - db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $module, $delta, $theme_key); + db_query("DELETE FROM [{blocks}] WHERE [module] = %s AND [delta] = %s AND [theme] = %s", $module, $delta, $theme_key); } } return $blocks; } function block_box_get($bid) { - return db_fetch_array(db_query("SELECT * FROM {boxes} WHERE bid = %d", $bid)); + return db_fetch_array(db_query("SELECT * FROM [{boxes}] WHERE [bid] = %d", $bid)); } /** @@ -329,7 +329,7 @@ function block_box_save($edit, $delta) { $edit['body_format'] = FILTER_FORMAT_DEFAULT; } - db_query("UPDATE {boxes} SET body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['body'], $edit['info'], $edit['body_format'], $delta); + db_query("UPDATE [{boxes}] SET [body] = %s, [info] = %s, [format] = %d WHERE [bid] = %d", $edit['body'], $edit['info'], $edit['body_format'], $delta); return TRUE; } @@ -345,7 +345,7 @@ function block_user($type, $edit, &$acco case 'form': if ($category == 'account') { $rids = array_keys($account->roles); - $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom != 0 AND (r.rid IN (" . db_placeholders($rids) . ") OR r.rid IS NULL) ORDER BY b.weight, b.module", $rids); + $result = db_query("SELECT DISTINCT b.* FROM [{blocks}] b LEFT JOIN [{blocks_roles}] r ON b.[module] = r.[module] AND b.[delta] = r.[delta] WHERE b.[status] = 1 AND b.[custom] <> 0 AND (r.[rid] IN (" . db_placeholders($rids) . ") OR r.[rid] IS NULL) ORDER BY b.[weight], b.[module]", $rids); $form['block'] = array('#type' => 'fieldset', '#title' => t('Block configuration'), '#weight' => 3, '#collapsible' => TRUE, '#tree' => TRUE); while ($block = db_fetch_object($result)) { $data = module_invoke($block->module, 'block', 'list'); @@ -410,7 +410,7 @@ function _block_load_blocks() { $blocks = array(); $rids = array_keys($user->roles); - $result = db_query(db_rewrite_sql("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (" . db_placeholders($rids) . ") OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", 'b', 'bid'), array_merge(array($theme_key), $rids)); + $result = db_query(db_rewrite_sql("SELECT DISTINCT b.* FROM [{blocks}] b LEFT JOIN [{blocks_roles}] r ON b.[module] = r.[module] AND b.[delta] = r.[delta] WHERE b.[theme] = %s AND b.[status] = 1 AND (r.[rid] IN (" . db_placeholders($rids) . ") OR r.[rid] IS NULL) ORDER BY b.[region], b.[weight], b.[module]", 'b', 'bid'), array_merge(array($theme_key), $rids)); while ($block = db_fetch_object($result)) { if (!isset($blocks[$block->region])) { $blocks[$block->region] = array(); Index: modules/block/block.test =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.test,v retrieving revision 1.3 diff -u -p -r1.3 block.test --- modules/block/block.test 14 Sep 2008 20:37:28 -0000 1.3 +++ modules/block/block.test 28 Sep 2008 16:44:06 -0000 @@ -37,7 +37,7 @@ class BlockTestCase extends DrupalWebTes // Confirm that the box has been created, and then query the created bid. $this->assertText(t('The block has been created.'), t('Box successfully created.')); - $bid = db_result(db_query("SELECT bid FROM {boxes} WHERE info = '%s'", array($box['info']))); + $bid = db_result(db_query("SELECT [bid] FROM [{boxes}] WHERE [info] = %s", array($box['info']))); // Check to see if the box was created by checking that it's in the database.. $this->assertNotNull($bid, t('Box found in database')); @@ -73,7 +73,7 @@ class BlockTestCase extends DrupalWebTes // Set block title to confirm that interface works and override any custom titles. $this->drupalPost('admin/build/block/configure/' . $block['module'] . '/' . $block['delta'], array('title' => $block['title']), t('Save block')); $this->assertText(t('The block configuration has been saved.'), t('Block title set.')); - $bid = db_result(db_query("SELECT bid FROM {blocks} WHERE module = '%s' AND delta = %d", array($block['module'], $block['delta']))); + $bid = db_result(db_query("SELECT [bid] FROM [{blocks}] WHERE [module] = %s AND [delta] = %d", array($block['module'], $block['delta']))); // Check to see if the block was created by checking that it's in the database. $this->assertNotNull($bid, t('Block found in database')); Index: modules/blog/blog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v retrieving revision 1.309 diff -u -p -r1.309 blog.module --- modules/blog/blog.module 22 Jul 2008 20:00:55 -0000 1.309 +++ modules/blog/blog.module 28 Sep 2008 16:44:06 -0000 @@ -85,7 +85,7 @@ function blog_form(&$node) { $node->body = '' . $blog->body . ' [' . l($blog->name, "node/$nid") . ']'; } - if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {aggregator_item} i, {aggregator_feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) { + if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.[title] AS [ftitle], f.[link] AS [flink] FROM [{aggregator_item}] i, [{aggregator_feed}] f WHERE i.[iid] = %d AND i.[fid] = f.[fid]', $iid))) { $node->title = $item->title; // Note: $item->description has been validated on aggregation. $node->body = '' . check_plain($item->title) . ' - ' . $item->description . ' [' . check_plain($item->ftitle) . "]\n"; @@ -178,7 +178,7 @@ function blog_page_user_access($account) * Helper function to determine if a user has blog posts already. */ function _blog_post_exists($account) { - return (bool)db_result(db_query_range(db_rewrite_sql("SELECT 1 FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1"), $account->uid, 0, 1)); + return (bool)db_result(db_query_range(db_rewrite_sql("SELECT 1 FROM [{node}] n WHERE n.[type] = 'blog' AND n.[uid] = %d AND n.[status] = 1"), $account->uid, 0, 1)); } /** @@ -194,7 +194,7 @@ function blog_block($op = 'list', $delta } elseif ($op == 'view') { if (user_access('access content')) { - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10); + $result = db_query_range(db_rewrite_sql("SELECT n.[nid], n.[title], n.[created] FROM [{node}] n WHERE n.[type] = 'blog' AND n.[status] = 1 ORDER BY n.[created] DESC"), 0, 10); if ($node_title_list = node_title_list($result)) { $block['content'] = $node_title_list; $block['content'] .= theme('more_link', url('blog'), t('Read the latest blog entries.')); Index: modules/blog/blog.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/blog/blog.pages.inc,v retrieving revision 1.10 diff -u -p -r1.10 blog.pages.inc --- modules/blog/blog.pages.inc 22 May 2008 19:27:13 -0000 1.10 +++ modules/blog/blog.pages.inc 28 Sep 2008 16:44:06 -0000 @@ -25,7 +25,7 @@ function blog_page_user($account) { $output = theme('item_list', $items); - $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid); + $result = pager_query(db_rewrite_sql("SELECT n.[nid], n.[sticky], n.[created] FROM [{node}] n WHERE n.[type] = 'blog' AND n.[uid] = %d AND n.[status] = 1 ORDER BY n.[sticky] DESC, n.[created] DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid); $has_posts = FALSE; while ($node = db_fetch_object($result)) { @@ -64,7 +64,7 @@ function blog_page_last() { $output = theme('item_list', $items); - $result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10)); + $result = pager_query(db_rewrite_sql("SELECT n.[nid], n.[created] FROM [{node}] n WHERE n.[type] = 'blog' AND n.[status] = 1 ORDER BY n.[sticky] DESC, n.[created] DESC"), variable_get('default_nodes_main', 10)); $has_posts = FALSE; while ($node = db_fetch_object($result)) { @@ -87,7 +87,7 @@ function blog_page_last() { * Menu callback; displays an RSS feed containing recent blog entries of a given user. */ function blog_feed_user($account) { - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $account->uid, 0, variable_get('feed_default_items', 10)); + $result = db_query_range(db_rewrite_sql("SELECT n.[nid], n.[created] FROM [{node}] n WHERE n.[type] = 'blog' AND n.[uid] = %d AND n.[status] = 1 ORDER BY n.[created] DESC"), $account->uid, 0, variable_get('feed_default_items', 10)); $channel['title'] = $account->name . "'s blog"; $channel['link'] = url('blog/' . $account->uid, array('absolute' => TRUE)); @@ -102,7 +102,7 @@ function blog_feed_user($account) { * Menu callback; displays an RSS feed containing recent blog entries of all users. */ function blog_feed_last() { - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, variable_get('feed_default_items', 10)); + $result = db_query_range(db_rewrite_sql("SELECT n.[nid], n.[created] FROM [{node}] n WHERE n.[type] = 'blog' AND n.[status] = 1 ORDER BY n.[created] DESC"), 0, variable_get('feed_default_items', 10)); $channel['title'] = variable_get('site_name', 'Drupal') . ' blogs'; $channel['link'] = url('blog', array('absolute' => TRUE)); Index: modules/blogapi/blogapi.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blogapi/blogapi.module,v retrieving revision 1.126 diff -u -p -r1.126 blogapi.module --- modules/blogapi/blogapi.module 17 Sep 2008 21:07:47 -0000 1.126 +++ modules/blogapi/blogapi.module 28 Sep 2008 16:44:07 -0000 @@ -338,13 +338,13 @@ function blogapi_blogger_get_recent_post } if ($bodies) { - $result = db_query_range("SELECT n.nid, n.title, r.body, r.format, n.comment, n.created, u.name FROM {node} n, {node_revisions} r, {users} u WHERE n.uid = u.uid AND n.vid = r.vid AND n.type = :type AND n.uid = :uid ORDER BY n.created DESC", array( + $result = db_query_range("SELECT n.[nid], n.[title], r.[body], r.[format], n.[comment], n.[created], u.[name] FROM [{node}] n, [{node_revisions}] r, [{users}] u WHERE n.[uid] = u.[uid] AND n.[vid] = r.[vid] AND n.[type] = :type AND n.[uid] = :uid ORDER BY n.[created] DESC", array( ':type' => $blogid, ':uid' => $user->uid ), 0, $number_of_posts); } else { - $result = db_query_range("SELECT n.nid, n.title, n.created, u.name FROM {node} n, {users} u WHERE n.uid = u.uid AND n.type = :type AND n.uid = :uid ORDER BY n.created DESC", array( + $result = db_query_range("SELECT n.[nid], n.[title], n.[created], u.[name] FROM [{node}] n, [{users}] u WHERE n.[uid] = u.[uid] AND n.[type] = :type AND n.[uid] = :uid ORDER BY n.[created] DESC", array( ':type' => $blogid, ':uid' => $user->uid ), 0, $number_of_posts); Index: modules/book/book.install =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.install,v retrieving revision 1.22 diff -u -p -r1.22 book.install --- modules/book/book.install 15 May 2008 21:19:24 -0000 1.22 +++ modules/book/book.install 28 Sep 2008 16:44:07 -0000 @@ -16,7 +16,7 @@ function book_install() { */ function book_uninstall() { // Delete menu links. - db_query("DELETE FROM {menu_links} WHERE module = 'book'"); + db_query("DELETE FROM [{menu_links}] WHERE [module] = 'book'"); menu_cache_clear_all(); // Remove tables. drupal_uninstall_schema('book'); Index: modules/book/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.module,v retrieving revision 1.469 diff -u -p -r1.469 book.module --- modules/book/book.module 27 Sep 2008 20:37:00 -0000 1.469 +++ modules/book/book.module 28 Sep 2008 16:44:07 -0000 @@ -210,7 +210,7 @@ function book_block($op = 'list', $delta } elseif ($current_bid) { // Only display this block when the user is browsing a book. - $title = db_result(db_query(db_rewrite_sql('SELECT n.title FROM {node} n WHERE n.nid = %d'), $node->book['bid'])); + $title = db_result(db_query(db_rewrite_sql('SELECT n.[title] FROM [{node}] n WHERE n.[nid] = %d'), $node->book['bid'])); // Only show the block if the user has view access for the top-level node. if ($title) { $tree = menu_tree_all_data($node->book['menu_name'], $node->book); @@ -266,14 +266,14 @@ function book_get_books() { if (!isset($all_books)) { $all_books = array(); - $result = db_query("SELECT DISTINCT(bid) FROM {book}"); + $result = db_query("SELECT DISTINCT([bid]) FROM [{book}]"); $nids = array(); while ($book = db_fetch_array($result)) { $nids[] = $book['bid']; } if ($nids) { - $result2 = db_query(db_rewrite_sql("SELECT n.type, n.title, b.*, ml.* FROM {book} b INNER JOIN {node} n on b.nid = n.nid INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE n.nid IN (" . implode(',', $nids) . ") AND n.status = 1 ORDER BY ml.weight, ml.link_title")); + $result2 = db_query(db_rewrite_sql("SELECT n.[type], n.[title], b.*, ml.* FROM [{book}] b INNER JOIN [{node}] n on b.[nid] = n.[nid] INNER JOIN [{menu_links}] ml ON b.[mlid] = ml.[mlid] WHERE n.[nid] IN (" . implode(',', $nids) . ") AND n.[status] = 1 ORDER BY ml.[weight], ml.[link_title]")); while ($link = db_fetch_array($result2)) { $link['href'] = $link['link_path']; $link['options'] = unserialize($link['options']); @@ -466,10 +466,10 @@ function _book_update_outline(&$node) { else { // Check in case the parent is not is this book; the book takes precedence. if (!empty($node->book['plid'])) { - $parent = db_fetch_array(db_query("SELECT * FROM {book} WHERE mlid = %d", $node->book['plid'])); + $parent = db_fetch_array(db_query("SELECT * FROM [{book}] WHERE [mlid] = %d", $node->book['plid'])); } if (empty($node->book['plid']) || !$parent || $parent['bid'] != $node->book['bid']) { - $node->book['plid'] = db_result(db_query("SELECT mlid FROM {book} WHERE nid = %d", $node->book['bid'])); + $node->book['plid'] = db_result(db_query("SELECT [mlid] FROM [{book}] WHERE [nid] = %d", $node->book['bid'])); $node->book['parent_mismatch'] = TRUE; // Likely when JS is disabled. } } @@ -477,10 +477,10 @@ function _book_update_outline(&$node) { if (menu_link_save($node->book)) { if ($new) { // Insert new. - db_query("INSERT INTO {book} (nid, mlid, bid) VALUES (%d, %d, %d)", $node->nid, $node->book['mlid'], $node->book['bid']); + db_query("INSERT INTO [{book}] ([nid], [mlid], [bid]) VALUES (%d, %d, %d)", $node->nid, $node->book['mlid'], $node->book['bid']); } else { - if ($node->book['bid'] != db_result(db_query("SELECT bid FROM {book} WHERE nid = %d", $node->nid))) { + if ($node->book['bid'] != db_result(db_query("SELECT [bid] FROM [{book}] WHERE [nid] = %d", $node->nid))) { // Update the bid for this page and all children. book_update_bid($node->book); } @@ -501,10 +501,10 @@ function _book_update_outline(&$node) { */ function book_update_bid($book_link) { for ($i = 1; $i <= MENU_MAX_DEPTH && $book_link["p$i"]; $i++) { - $match[] = "p$i = %d"; + $match[] = "[p$i] = %d"; $args[] = $book_link["p$i"]; } - $result = db_query("SELECT mlid FROM {menu_links} WHERE " . implode(' AND ', $match), $args); + $result = db_query("SELECT [mlid] FROM [{menu_links}] WHERE " . implode(' AND ', $match), $args); $mlids = array(); while ($a = db_fetch_array($result)) { @@ -512,7 +512,7 @@ function book_update_bid($book_link) { } if ($mlids) { - db_query("UPDATE {book} SET bid = %d WHERE mlid IN (" . implode(',', $mlids) . ")", $book_link['bid']); + db_query("UPDATE [{book}] SET [bid] = %d WHERE [mlid] IN (" . implode(',', $mlids) . ")", $book_link['bid']); } } @@ -677,7 +677,7 @@ function book_nodeapi(&$node, $op, $teas switch ($op) { case 'load': // Note - we cannot use book_link_load() because it will call node_load(). - $info['book'] = db_fetch_array(db_query('SELECT * FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid = %d', $node->nid)); + $info['book'] = db_fetch_array(db_query('SELECT * FROM [{book}] b INNER JOIN [{menu_links}] ml ON b.[mlid] = ml.[mlid] WHERE b.[nid] = %d', $node->nid)); if ($info['book']) { $info['book']['href'] = $info['book']['link_path']; @@ -732,7 +732,7 @@ function book_nodeapi(&$node, $op, $teas if (!empty($node->book['bid'])) { if ($node->nid == $node->book['bid']) { // Handle deletion of a top-level post. - $result = db_query("SELECT b.nid FROM {menu_links} ml INNER JOIN {book} b on b.mlid = ml.mlid WHERE ml.plid = %d", $node->book['mlid']); + $result = db_query("SELECT b.[nid] FROM [{menu_links}] ml INNER JOIN [{book}] b on b.[mlid] = ml.[mlid] WHERE ml.[plid] = %d", $node->book['mlid']); while ($child = db_fetch_array($result)) { $child_node = node_load($child['nid']); $child_node->book['bid'] = $child_node->nid; @@ -740,7 +740,7 @@ function book_nodeapi(&$node, $op, $teas } } menu_link_delete($node->book['mlid']); - db_query('DELETE FROM {book} WHERE mlid = %d', $node->book['mlid']); + db_query('DELETE FROM [{book}] WHERE [mlid] = %d', $node->book['mlid']); } break; @@ -1060,7 +1060,7 @@ function book_help($path, $arg) { * Do not call when loading a node, since this function may call node_load(). */ function book_link_load($mlid) { - if ($item = db_fetch_array(db_query("SELECT * FROM {menu_links} ml INNER JOIN {book} b ON b.mlid = ml.mlid LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = %d", $mlid))) { + if ($item = db_fetch_array(db_query("SELECT * FROM [{menu_links}] ml INNER JOIN [{book}] b ON b.[mlid] = ml.[mlid] LEFT JOIN [{menu_router}] m ON m.[path] = ml.[router_path] WHERE ml.[mlid] = %d", $mlid))) { _menu_link_translate($item); return $item; } @@ -1100,20 +1100,20 @@ function book_menu_subtree_data($item) { // If the subtree data was not in the cache, $data will be NULL. if (!isset($data)) { - $match = array("menu_name = '%s'"); + $match = array("[menu_name] = %s"); $args = array($item['menu_name']); $i = 1; while ($i <= MENU_MAX_DEPTH && $item["p$i"]) { - $match[] = "p$i = %d"; + $match[] = "[p$i] = %d"; $args[] = $item["p$i"]; $i++; } $sql = " - SELECT b.*, m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.* - FROM {menu_links} ml INNER JOIN {menu_router} m ON m.path = ml.router_path - INNER JOIN {book} b ON ml.mlid = b.mlid + SELECT b.*, m.[load_functions], m.[to_arg_functions], m.[access_callback], m.[access_arguments], m.[page_callback], m.[page_arguments], m.[title], m.[title_callback], m.[title_arguments], m.[type], ml.* + FROM [{menu_links}] ml INNER JOIN [{menu_router}] m ON m.[path] = ml.[router_path] + INNER JOIN [{book}] b ON ml.[mlid] = b.[mlid] WHERE " . implode(' AND ', $match) . " - ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC"; + ORDER BY [p1] ASC, [p2] ASC, [p3] ASC, [p4] ASC, [p5] ASC, [p6] ASC, [p7] ASC, [p8] ASC, [p9] ASC"; $data['tree'] = menu_tree_data(db_query($sql, $args), array(), $item['depth']); $data['node_links'] = array(); Index: modules/book/book.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.pages.inc,v retrieving revision 1.7 diff -u -p -r1.7 book.pages.inc --- modules/book/book.pages.inc 15 May 2008 21:19:24 -0000 1.7 +++ modules/book/book.pages.inc 28 Sep 2008 16:44:07 -0000 @@ -210,7 +210,7 @@ function book_remove_form_submit($form, if ($node->nid != $node->book['bid']) { // Only allowed when this is not a book (top-level page). menu_link_delete($node->book['mlid']); - db_query('DELETE FROM {book} WHERE nid = %d', $node->nid); + db_query('DELETE FROM [{book}] WHERE [nid] = %d', $node->nid); drupal_set_message(t('The post has been removed from the book.')); } $form_state['redirect'] = 'node/' . $node->nid; Index: modules/comment/comment.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.admin.inc,v retrieving revision 1.10 diff -u -p -r1.10 comment.admin.inc --- modules/comment/comment.admin.inc 16 Jul 2008 21:59:26 -0000 1.10 +++ modules/comment/comment.admin.inc 28 Sep 2008 16:44:07 -0000 @@ -68,7 +68,7 @@ function comment_admin_overview($type = array('data' => t('Time'), 'field' => 'timestamp', 'sort' => 'desc'), array('data' => t('Operations')), )); - $result = pager_query('SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid, n.title as node_title FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid INNER JOIN {node} n ON n.nid = c.nid WHERE c.status = %d' . tablesort_sql($form['header']['#value']), 50, 0, NULL, $status); + $result = pager_query('SELECT c.[subject], c.[nid], c.[cid], c.[comment], c.[timestamp], c.[status], c.[name], c.[homepage], u.[name] AS [registered_name], u.[uid], n.[title] as [node_title] FROM [{comments}] c INNER JOIN [{users}] u ON u.[uid] = c.[uid] INNER JOIN [{node}] n ON n.[nid] = c.[nid] WHERE c.[status] = %d' . tablesort_sql($form['header']['#value']), 50, 0, NULL, $status); // Build a table listing the appropriate comments. $destination = drupal_get_destination(); @@ -201,7 +201,7 @@ function comment_multiple_delete_confirm foreach (array_filter($edit['comments']) as $cid => $value) { $comment = comment_load($cid); if (is_object($comment) && is_numeric($comment->cid)) { - $subject = db_result(db_query('SELECT subject FROM {comments} WHERE cid = %d', $cid)); + $subject = db_result(db_query('SELECT [subject] FROM [{comments}] WHERE [cid] = %d', $cid)); $form['comments'][$cid] = array('#type' => 'hidden', '#value' => $cid, '#prefix' => '
  • ', '#suffix' => check_plain($subject) . '
  • '); $comment_counter++; } @@ -244,7 +244,7 @@ function comment_multiple_delete_confirm * The comment to be deleted. */ function comment_delete($cid = NULL) { - $comment = db_fetch_object(db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = %d', $cid)); + $comment = db_fetch_object(db_query('SELECT c.*, u.[name] AS [registered_name], u.[uid] FROM [{comments}] c INNER JOIN [{users}] u ON u.[uid] = c.[uid] WHERE c.[cid] = %d', $cid)); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; $output = ''; @@ -306,12 +306,12 @@ function _comment_delete_thread($comment } // Delete the comment. - db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid); + db_query('DELETE FROM [{comments}] WHERE [cid] = %d', $comment->cid); watchdog('content', 'Comment: deleted %subject.', array('%subject' => $comment->subject)); comment_invoke_comment($comment, 'delete'); // Delete the comment's replies. - $result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE pid = %d', $comment->cid); + $result = db_query('SELECT c.*, u.[name] AS [registered_name], u.[uid] FROM [{comments}] c INNER JOIN [{users}] u ON u.[uid] = c.[uid] WHERE [pid] = %d', $comment->cid); while ($comment = db_fetch_object($result)) { $comment->name = $comment->uid ? $comment->registered_name : $comment->name; _comment_delete_thread($comment); Index: modules/comment/comment.install =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v retrieving revision 1.26 diff -u -p -r1.26 comment.install --- modules/comment/comment.install 17 Sep 2008 07:11:56 -0000 1.26 +++ modules/comment/comment.install 28 Sep 2008 16:44:07 -0000 @@ -6,7 +6,7 @@ */ function comment_enable() { // Insert records into the node_comment_statistics for nodes that are missing. - db_query("INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) SELECT n.nid, n.changed, NULL, n.uid, 0 FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE c.comment_count IS NULL"); + db_query("INSERT INTO [{node_comment_statistics}] ([nid], [last_comment_timestamp], [last_comment_name], [last_comment_uid], [comment_count]) SELECT n.[nid], n.[changed], NULL, n.[uid], 0 FROM [{node}] n LEFT JOIN [{node_comment_statistics}] c ON n.[nid] = c.[nid] WHERE c.[comment_count] IS NULL"); } /** @@ -14,7 +14,7 @@ function comment_enable() { */ function comment_update_1() { // Change any future last comment timestamps to current time. - db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE last_comment_timestamp > %d', REQUEST_TIME, REQUEST_TIME); + db_query('UPDATE [{node_comment_statistics}] SET [last_comment_timestamp] = %d WHERE [last_comment_timestamp] > %d', REQUEST_TIME, REQUEST_TIME); // Unstuck node indexing timestamp if needed. if (($last = variable_get('node_cron_last', FALSE)) !== FALSE) { @@ -30,8 +30,8 @@ function comment_update_1() { */ function comment_update_6001() { - $ret[] = update_sql("ALTER TABLE {comments} DROP score"); - $ret[] = update_sql("ALTER TABLE {comments} DROP users"); + $ret[] = update_sql("ALTER TABLE [{comments}] DROP [score]"); + $ret[] = update_sql("ALTER TABLE [{comments}] DROP [users]"); return $ret; } @@ -101,9 +101,9 @@ function comment_update_7000() { */ function comment_update_7001() { $ret = array(); - $ret[] = update_sql("UPDATE {comments} SET status = 3 WHERE status = 0"); - $ret[] = update_sql("UPDATE {comments} SET status = 0 WHERE status = 1"); - $ret[] = update_sql("UPDATE {comments} SET status = 1 WHERE status = 3"); + $ret[] = update_sql("UPDATE [{comments}] SET [status] = 3 WHERE [status] = 0"); + $ret[] = update_sql("UPDATE [{comments}] SET [status] = 0 WHERE [status] = 1"); + $ret[] = update_sql("UPDATE [{comments}] SET [status] = 1 WHERE [status] = 3"); return $ret; } Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.652 diff -u -p -r1.652 comment.module --- modules/comment/comment.module 27 Sep 2008 20:37:00 -0000 1.652 +++ modules/comment/comment.module 28 Sep 2008 16:44:07 -0000 @@ -305,7 +305,7 @@ function comment_block($op = 'list', $de function comment_get_recent($number = 10) { // Step 1: Select a $number of nodes which have new comments, // and are visible to the current user. - $result = db_query_range(db_rewrite_sql("SELECT nc.nid FROM {node_comment_statistics} nc WHERE nc.comment_count > 0 ORDER BY nc.last_comment_timestamp DESC", 'nc'), 0, $number); + $result = db_query_range(db_rewrite_sql("SELECT nc.[nid] FROM [{node_comment_statistics}] nc WHERE nc.[comment_count] > 0 ORDER BY nc.[last_comment_timestamp] DESC", 'nc'), 0, $number); $nids = array(); while ($row = db_fetch_object($result)) { $nids[] = $row->nid; @@ -315,7 +315,7 @@ function comment_get_recent($number = 10 if (!empty($nids)) { // Step 2: From among the comments on the nodes selected in the first query, // find the $number of most recent comments. - $result = db_query_range('SELECT c.nid, c.subject, c.cid, c.timestamp FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE c.nid IN (' . implode(',', $nids) . ') AND n.status = 1 AND c.status = %d ORDER BY c.cid DESC', COMMENT_PUBLISHED, 0, $number); + $result = db_query_range('SELECT c.[nid], c.[subject], c.[cid], c.[timestamp] FROM [{comments}] c INNER JOIN [{node}] n ON n.[nid] = c.[nid] WHERE c.[nid] IN (' . implode(',', $nids) . ') AND n.[status] = 1 AND c.[status] = %d ORDER BY c.[cid] DESC', COMMENT_PUBLISHED, 0, $number); while ($comment = db_fetch_object($result)) { $comments[] = $comment; } @@ -353,9 +353,9 @@ function comment_new_page_count($num_com else { // Threaded comments. // Find the first thread with a new comment. - $result = db_query('(SELECT thread FROM {comments} WHERE nid = %d AND status = 0 ORDER BY timestamp DESC LIMIT %d) ORDER BY SUBSTRING(thread, 1, (LENGTH(thread) - 1)) LIMIT 1', $node->nid, $new_replies); + $result = db_query('(SELECT [thread] FROM [{comments}] WHERE [nid] = %d AND [status] = 0 ORDER BY [timestamp] DESC LIMIT %d) ORDER BY ' . db_substr() . '([thread], 1, (' . db_strlen() . '([thread]) - 1)) LIMIT 1', $node->nid, $new_replies); $thread = substr(db_result($result), 0, -1); - $result_count = db_query("SELECT COUNT(*) FROM {comments} WHERE nid = %d AND status = 0 AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < '" . $thread . "'", $node->nid); + $result_count = db_query("SELECT COUNT(*) FROM [{comments}] WHERE [nid] = %d AND [status] = 0 AND " . db_substr() . "([thread], 1, (" . db_strlen() . "([thread]) - 1)) < '" . $thread . "'", $node->nid); $count = db_result($result_count); $pageno = $count / $comments_per_page; } @@ -558,7 +558,7 @@ function comment_nodeapi(&$node, $op, $a switch ($op) { case 'load': if ($node->comment != COMMENT_NODE_DISABLED) { - return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid)); + return db_fetch_array(db_query("SELECT [last_comment_timestamp], [last_comment_name], [comment_count] FROM [{node_comment_statistics}] WHERE [nid] = %d", $node->nid)); } return array('last_comment_timestamp' => $node->created, 'last_comment_name' => '', 'comment_count' => 0); @@ -569,24 +569,24 @@ function comment_nodeapi(&$node, $op, $a break; case 'insert': - db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->changed, $node->uid); + db_query('INSERT INTO [{node_comment_statistics}] ([nid], [last_comment_timestamp], [last_comment_name], [last_comment_uid], [comment_count]) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->changed, $node->uid); break; case 'delete': - db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid); + db_query('DELETE FROM [{comments}] WHERE [nid] = %d', $node->nid); + db_query('DELETE FROM [{node_comment_statistics}] WHERE [nid] = %d', $node->nid); break; case 'update index': $text = ''; - $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = %d', $node->nid, COMMENT_PUBLISHED); + $comments = db_query('SELECT [subject], [comment], [format] FROM [{comments}] WHERE [nid] = %d AND [status] = %d', $node->nid, COMMENT_PUBLISHED); while ($comment = db_fetch_object($comments)) { $text .= '

    ' . check_plain($comment->subject) . '

    ' . check_markup($comment->comment, $comment->format, FALSE); } return $text; case 'search result': - $comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $node->nid)); + $comments = db_result(db_query('SELECT [comment_count] FROM [{node_comment_statistics}] WHERE [nid] = %d', $node->nid)); return format_plural($comments, '1 comment', '@count comments'); case 'rss item': @@ -604,8 +604,8 @@ function comment_nodeapi(&$node, $op, $a */ function comment_user($type, $edit, &$user, $category = NULL) { if ($type == 'delete') { - db_query('UPDATE {comments} SET uid = 0 WHERE uid = %d', $user->uid); - db_query('UPDATE {node_comment_statistics} SET last_comment_uid = 0 WHERE last_comment_uid = %d', $user->uid); + db_query('UPDATE [{comments}] SET [uid] = 0 WHERE [uid] = %d', $user->uid); + db_query('UPDATE [{node_comment_statistics}] SET [last_comment_uid] = 0 WHERE [last_comment_uid] = %d', $user->uid); } } @@ -664,7 +664,7 @@ function comment_save($edit) { ); if ($edit['cid']) { // Update the comment in the database. - db_query("UPDATE {comments} SET status = %d, timestamp = %d, subject = '%s', comment = '%s', format = %d, uid = %d, name = '%s', mail = '%s', homepage = '%s' WHERE cid = %d", $edit['status'], $edit['timestamp'], $edit['subject'], $edit['comment'], $edit['comment_format'], $edit['uid'], $edit['name'], $edit['mail'], $edit['homepage'], $edit['cid']); + db_query("UPDATE [{comments}] SET [status] = %d, [timestamp] = %d, [subject] = %s, [comment] = %s, [format] = %d, [uid] = %d, [name] = %s, [mail] = %s, [homepage] = %s WHERE [cid] = %d", $edit['status'], $edit['timestamp'], $edit['subject'], $edit['comment'], $edit['comment_format'], $edit['uid'], $edit['name'], $edit['mail'], $edit['homepage'], $edit['cid']); // Allow modules to respond to the updating of a comment. comment_invoke_comment($edit, 'update'); // Add an entry to the watchdog log. @@ -676,7 +676,7 @@ function comment_save($edit) { if ($edit['pid'] == 0) { // This is a comment with no parent comment (depth 0): we start // by retrieving the maximum thread level. - $max = db_result(db_query('SELECT MAX(thread) FROM {comments} WHERE nid = %d', $edit['nid'])); + $max = db_result(db_query('SELECT MAX([thread]) FROM [{comments}] WHERE [nid] = %d', $edit['nid'])); // Strip the "/" from the end of the thread. $max = rtrim($max, '/'); // Finally, build the thread field for this new comment. @@ -691,7 +691,7 @@ function comment_save($edit) { // Strip the "/" from the end of the parent thread. $parent->thread = (string) rtrim((string) $parent->thread, '/'); // Get the max value in *this* thread. - $max = db_query("SELECT MAX(thread) FROM {comments} WHERE thread LIKE :thread AND nid = :nid", array(':thread' => $parent->thread .'%', ':nid' => $edit['nid']))->fetchField(); + $max = db_query("SELECT MAX([thread]) FROM [{comments}] WHERE [thread] LIKE :thread AND [nid] = :nid", array(':thread' => $parent->thread . '%', ':nid' => $edit['nid']))->fetchField(); if ($max == '') { // First child of this parent. @@ -717,7 +717,7 @@ function comment_save($edit) { $edit['name'] = $user->name; } - db_query("INSERT INTO {comments} (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s')", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['comment_format'], ip_address(), $edit['timestamp'], $edit['status'], $thread, $edit['name'], $edit['mail'], $edit['homepage']); + db_query("INSERT INTO [{comments}] ([nid], [pid], [uid], [subject], [comment], [format], [hostname], [timestamp], [status], [thread], [name], [mail], [homepage]) VALUES (%d, %d, %d, %s, %s, %d, %s, %d, %d, %s, %s, %s, %s)", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['comment_format'], ip_address(), $edit['timestamp'], $edit['status'], $thread, $edit['name'], $edit['mail'], $edit['homepage']); $edit['cid'] = db_last_insert_id('comments', 'cid'); // Tell the other modules a new comment has been submitted. comment_invoke_comment($edit, 'insert'); @@ -895,10 +895,10 @@ function comment_render($node, $cid = 0) if ($cid && is_numeric($cid)) { // Single comment view. - $query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d'; + $query = 'SELECT c.[cid], c.[pid], c.[nid], c.[subject], c.[comment], c.[format], c.[timestamp], c.[name], c.[mail], c.[homepage], u.[uid], u.[name] AS [registered_name], u.[signature], u.[picture], u.[data], c.[status] FROM [{comments}] c INNER JOIN [{users}] u ON c.[uid] = u.[uid] WHERE c.[cid] = %d'; $query_args = array($cid); if (!user_access('administer comments')) { - $query .= ' AND c.status = %d'; + $query .= ' AND c.[status] = %d'; $query_args[] = COMMENT_PUBLISHED; } @@ -915,23 +915,23 @@ function comment_render($node, $cid = 0) } else { // Multiple comment view. - $query_count = 'SELECT COUNT(*) FROM {comments} c WHERE c.nid = %d'; - $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d'; + $query_count = 'SELECT COUNT(*) FROM [{comments}] c WHERE c.[nid] = %d'; + $query = 'SELECT c.[cid] as [cid], c.[pid], c.[nid], c.[subject], c.[comment], c.[format], c.[timestamp], c.[name], c.[mail], c.[homepage], u.[uid], u.[name] AS [registered_name], u.[signature], u.[picture], u.[data], c.[thread], c.[status] FROM [{comments}] c INNER JOIN [{users}] u ON c.[uid] = u.[uid] WHERE c.[nid] = %d'; $query_args = array($nid); if (!user_access('administer comments')) { - $query .= ' AND c.status = %d'; - $query_count .= ' AND c.status = %d'; + $query .= ' AND c.[status] = %d'; + $query_count .= ' AND c.[status] = %d'; $query_args[] = COMMENT_PUBLISHED; } if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) { - $query .= ' ORDER BY c.cid'; + $query .= ' ORDER BY c.[cid]'; } else { // See comment above. Analysis reveals that this doesn't cost too // much. It scales much much better than having the whole comment // structure. - $query .= ' ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))'; + $query .= ' ORDER BY ' . db_substr() . '(c.[thread], 1, (' . db_strlen() . '(c.[thread]) - 1))'; } $query = db_rewrite_sql($query, 'c', 'cid'); @@ -1005,20 +1005,20 @@ function comment_render($node, $cid = 0) function comment_operations($action = NULL) { if ($action == 'publish') { $operations = array( - 'publish' => array(t('Publish the selected comments'), 'UPDATE {comments} SET status = ' . COMMENT_PUBLISHED . ' WHERE cid = %d'), + 'publish' => array(t('Publish the selected comments'), 'UPDATE [{comments}] SET [status] = ' . COMMENT_PUBLISHED . ' WHERE [cid] = %d'), 'delete' => array(t('Delete the selected comments'), '') ); } elseif ($action == 'unpublish') { $operations = array( - 'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE {comments} SET status = ' . COMMENT_NOT_PUBLISHED . ' WHERE cid = %d'), + 'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE [{comments}] SET [status] = ' . COMMENT_NOT_PUBLISHED . ' WHERE [cid] = %d'), 'delete' => array(t('Delete the selected comments'), '') ); } else { $operations = array( - 'publish' => array(t('Publish the selected comments'), 'UPDATE {comments} SET status = ' . COMMENT_PUBLISHED . ' WHERE cid = %d'), - 'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE {comments} SET status = ' . COMMENT_NOT_PUBLISHED . ' WHERE cid = %d'), + 'publish' => array(t('Publish the selected comments'), 'UPDATE [{comments}] SET [status] = ' . COMMENT_PUBLISHED . ' WHERE [cid] = %d'), + 'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE [{comments}] SET [status] = ' . COMMENT_NOT_PUBLISHED . ' WHERE [cid] = %d'), 'delete' => array(t('Delete the selected comments'), '') ); } @@ -1039,7 +1039,7 @@ function comment_operations($action = NU * The comment object. */ function comment_load($cid) { - return db_fetch_object(db_query('SELECT * FROM {comments} WHERE cid = %d', $cid)); + return db_fetch_object(db_query('SELECT * FROM [{comments}] WHERE [cid] = %d', $cid)); } /** @@ -1054,7 +1054,7 @@ function comment_num_replies($pid) { static $cache; if (!isset($cache[$pid])) { - $cache[$pid] = db_result(db_query('SELECT COUNT(cid) FROM {comments} WHERE pid = %d AND status = %d', $pid, COMMENT_PUBLISHED)); + $cache[$pid] = db_result(db_query('SELECT COUNT([cid]) FROM [{comments}] WHERE [pid] = %d AND [status] = %d', $pid, COMMENT_PUBLISHED)); } return $cache[$pid]; @@ -1081,7 +1081,7 @@ function comment_num_new($nid, $timestam $timestamp = ($timestamp > NODE_NEW_LIMIT ? $timestamp : NODE_NEW_LIMIT); // Use the timestamp to retrieve the number of new comments. - $result = db_result(db_query('SELECT COUNT(c.cid) FROM {node} n INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = %d AND timestamp > %d AND c.status = %d', $nid, $timestamp, COMMENT_PUBLISHED)); + $result = db_result(db_query('SELECT COUNT(c.[cid]) FROM [{node}] n INNER JOIN [{comments}] c ON n.[nid] = c.[nid] WHERE n.[nid] = %d AND [timestamp] > %d AND c.[status] = %d', $nid, $timestamp, COMMENT_PUBLISHED)); return $result; } @@ -1120,7 +1120,7 @@ function comment_validate($edit) { $node = node_load($edit['nid']); if (variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) > COMMENT_ANONYMOUS_MAYNOT_CONTACT) { if ($edit['name']) { - $taken = db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE LOWER(name) = '%s'", $edit['name'])); + $taken = db_result(db_query("SELECT COUNT([uid]) FROM [{users}] WHERE LOWER([name]) = %s", $edit['name'])); if ($taken != 0) { form_set_error('name', t('The name you used belongs to a registered user.')); } @@ -1458,7 +1458,7 @@ function comment_form_add_preview($form, $output = ''; // Isn't this line a duplication of the first $output above? if ($edit['pid']) { - $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $edit['pid'], COMMENT_PUBLISHED)); + $comment = db_fetch_object(db_query('SELECT c.*, u.[uid], u.[name] AS [registered_name], u.[signature], u.[picture], u.[data] FROM [{comments}] c INNER JOIN [{users}] u ON c.[uid] = u.[uid] WHERE c.[cid] = %d AND c.[status] = %d', $edit['pid'], COMMENT_PUBLISHED)); $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; $output .= theme('comment_view', $comment, $node); @@ -1798,17 +1798,17 @@ function _comment_get_display_setting($s * - comment_count: the total number of approved/published comments on this node. */ function _comment_update_node_statistics($nid) { - $count = db_result(db_query('SELECT COUNT(cid) FROM {comments} WHERE nid = %d AND status = %d', $nid, COMMENT_PUBLISHED)); + $count = db_result(db_query('SELECT COUNT([cid]) FROM [{comments}] WHERE [nid] = %d AND [status] = %d', $nid, COMMENT_PUBLISHED)); if ($count > 0) { // Comments exist. - $last_reply = db_fetch_object(db_query_range('SELECT cid, name, timestamp, uid FROM {comments} WHERE nid = %d AND status = %d ORDER BY cid DESC', $nid, COMMENT_PUBLISHED, 0, 1)); - db_query("UPDATE {node_comment_statistics} SET comment_count = %d, last_comment_timestamp = %d, last_comment_name = '%s', last_comment_uid = %d WHERE nid = %d", $count, $last_reply->timestamp, $last_reply->uid ? '' : $last_reply->name, $last_reply->uid, $nid); + $last_reply = db_fetch_object(db_query_range('SELECT [cid], [name], [timestamp], [uid] FROM [{comments}] WHERE [nid] = %d AND [status] = %d ORDER BY [cid] DESC', $nid, COMMENT_PUBLISHED, 0, 1)); + db_query("UPDATE [{node_comment_statistics}] SET [comment_count] = %d, [last_comment_timestamp] = %d, [last_comment_name] = %s, [last_comment_uid] = %d WHERE [nid] = %d", $count, $last_reply->timestamp, $last_reply->uid ? '' : $last_reply->name, $last_reply->uid, $nid); } else { // Comments do not exist. - $node = db_fetch_object(db_query("SELECT uid, created FROM {node} WHERE nid = %d", $nid)); - db_query("UPDATE {node_comment_statistics} SET comment_count = 0, last_comment_timestamp = %d, last_comment_name = '', last_comment_uid = %d WHERE nid = %d", $node->created, $node->uid, $nid); + $node = db_fetch_object(db_query("SELECT [uid], [created] FROM [{node}] WHERE [nid] = %d", $nid)); + db_query("UPDATE [{node_comment_statistics}] SET [comment_count] = %d, [last_comment_timestamp] = %d, [last_comment_name] = %s, [last_comment_uid] = %d WHERE [nid] = %d", 0, $node->created, '', $node->uid, $nid); } } @@ -1928,9 +1928,9 @@ function comment_unpublish_action($comme } else { $cid = $context['cid']; - $subject = db_result(db_query("SELECT subject FROM {comments} WHERE cid = %d", $cid)); + $subject = db_result(db_query("SELECT [subject] FROM [{comments}] WHERE [cid] = %d", $cid)); } - db_query('UPDATE {comments} SET status = %d WHERE cid = %d', COMMENT_NOT_PUBLISHED, $cid); + db_query('UPDATE [{comments}] SET [status] = %d WHERE [cid] = %d', COMMENT_NOT_PUBLISHED, $cid); watchdog('action', 'Unpublished comment %subject.', array('%subject' => $subject)); } @@ -1972,7 +1972,7 @@ function comment_unpublish_by_keyword_ac function comment_unpublish_by_keyword_action($comment, $context) { foreach ($context['keywords'] as $keyword) { if (strstr($comment->comment, $keyword) || strstr($comment->subject, $keyword)) { - db_query('UPDATE {comments} SET status = %d WHERE cid = %d', COMMENT_NOT_PUBLISHED, $comment->cid); + db_query('UPDATE [{comments}] SET [status] = %d WHERE [cid] = %d', COMMENT_NOT_PUBLISHED, $comment->cid); watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject)); break; } @@ -1986,9 +1986,9 @@ function comment_ranking() { return array( 'comments' => array( 'title' => t('Number of comments'), - 'join' => 'LEFT JOIN {node_comment_statistics} node_comment_statistics ON node_comment_statistics.nid = i.sid', + 'join' => 'LEFT JOIN [{node_comment_statistics}] [node_comment_statistics] ON [node_comment_statistics].[nid] = i.[sid]', // Inverse law that maps the highest reply count on the site to 1 and 0 to 0. - 'score' => '2.0 - 2.0 / (1.0 + node_comment_statistics.comment_count * %f)', + 'score' => '2.0 - 2.0 / (1.0 + [node_comment_statistics].[comment_count] * %f)', 'arguments' => array(variable_get('node_cron_comments_scale', 0)), ), ); Index: modules/comment/comment.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.pages.inc,v retrieving revision 1.6 diff -u -p -r1.6 comment.pages.inc --- modules/comment/comment.pages.inc 24 Jun 2008 17:01:33 -0000 1.6 +++ modules/comment/comment.pages.inc 28 Sep 2008 16:44:07 -0000 @@ -15,7 +15,7 @@ */ function comment_edit($cid) { global $user; - $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $cid)); + $comment = db_fetch_object(db_query('SELECT c.*, u.[uid], u.[name] AS [registered_name], u.[data] FROM [{comments}] c INNER JOIN [{users}] u ON c.[uid] = u.[uid] WHERE c.[cid] = %d', $cid)); $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; @@ -69,7 +69,7 @@ function comment_reply($node, $pid = NUL // $pid indicates that this is a reply to a comment. if ($pid) { // Load the comment whose cid = $pid - if ($comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $pid, COMMENT_PUBLISHED))) { + if ($comment = db_fetch_object(db_query('SELECT c.*, u.[uid], u.[name] AS [registered_name], u.[signature], u.[picture], u.[data] FROM [{comments}] c INNER JOIN [{users}] u ON c.[uid] = u.[uid] WHERE c.[cid] = %d AND c.[status] = %d', $pid, COMMENT_PUBLISHED))) { // If that comment exists, make sure that the current comment and the // parent comment both belong to the same parent node. if ($comment->nid != $node->nid) { Index: modules/comment/comment.test =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.test,v retrieving revision 1.15 diff -u -p -r1.15 comment.test --- modules/comment/comment.test 24 Sep 2008 22:38:20 -0000 1.15 +++ modules/comment/comment.test 28 Sep 2008 16:44:07 -0000 @@ -308,7 +308,7 @@ class CommentInterfaceTest extends Comme $this->assertText('This discussion is closed', t('Posting to node with comments disabled')); $this->assertNoField('edit-comment', t('Comment body field found.')); - // Attempt to post to node with read-only comments. + // Attempt to post to node with read-only comments. $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_READ_ONLY)); $this->assertTrue($this->node, t('Article node created.')); $this->drupalGet('comment/reply/' . $this->node->nid); @@ -449,14 +449,14 @@ class CommentAnonymous extends CommentHe $this->drupalLogin($this->admin_user); $this->setAnonymousUserComment(FALSE, FALSE); - // Attempt to view comments while disallowed. + // Attempt to view comments while disallowed. // NOTE: if authenticated user has permission to post comments, then a // "Login or register to post comments" type link may be shown. $this->drupalLogout(); $this->drupalGet('node/' . $this->node->nid); $this->assertNoRaw('
    ', t('Comments were not displayed.')); $this->assertNoLink('Add new comment', t('Link to add comment was found.')); - + // Attempt to view node-comment form while disallowed. $this->drupalGet('comment/reply/' . $this->node->nid); $this->assertText('You are not authorized to view comments', t('Error attempting to post comment.')); Index: modules/contact/contact.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.admin.inc,v retrieving revision 1.5 diff -u -p -r1.5 contact.admin.inc --- modules/contact/contact.admin.inc 2 Jul 2008 20:05:11 -0000 1.5 +++ modules/contact/contact.admin.inc 28 Sep 2008 16:44:07 -0000 @@ -10,7 +10,7 @@ * Categories/list tab. */ function contact_admin_categories() { - $result = db_query('SELECT cid, category, recipients, selected FROM {contact} ORDER BY weight, category'); + $result = db_query('SELECT [cid], [category], [recipients], [selected] FROM [{contact}] ORDER BY [weight], [category]'); $rows = array(); while ($category = db_fetch_object($result)) { $rows[] = array($category->category, $category->recipients, ($category->selected ? t('Yes') : t('No')), l(t('edit'), 'admin/build/contact/edit/' . $category->cid), l(t('delete'), 'admin/build/contact/delete/' . $category->cid)); @@ -93,7 +93,7 @@ function contact_admin_edit_validate($fo function contact_admin_edit_submit($form, &$form_state) { if ($form_state['values']['selected']) { // Unselect all other contact categories. - db_query('UPDATE {contact} SET selected = 0'); + db_query('UPDATE [{contact}] SET [selected] = 0'); } $recipients = explode(',', $form_state['values']['recipients']); foreach ($recipients as $key => $recipient) { @@ -135,7 +135,7 @@ function contact_admin_delete(&$form_sta */ function contact_admin_delete_submit($form, &$form_state) { $contact = $form_state['values']['contact']; - db_query("DELETE FROM {contact} WHERE cid = %d", $contact['cid']); + db_query("DELETE FROM [{contact}] WHERE [cid] = %d", $contact['cid']); drupal_set_message(t('Category %category has been deleted.', array('%category' => $contact['category']))); watchdog('mail', 'Contact form: category %category deleted.', array('%category' => $contact['category']), WATCHDOG_NOTICE); Index: modules/contact/contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v retrieving revision 1.109 diff -u -p -r1.109 contact.module --- modules/contact/contact.module 17 Sep 2008 20:37:32 -0000 1.109 +++ modules/contact/contact.module 28 Sep 2008 16:44:07 -0000 @@ -125,7 +125,7 @@ function _contact_user_tab_access($accou * Load the data for a single contact category. */ function contact_load($cid) { - $contact = db_fetch_array(db_query("SELECT * FROM {contact} WHERE cid = %d", $cid)); + $contact = db_fetch_array(db_query("SELECT * FROM [{contact}] WHERE [cid] = %d", $cid)); return empty($contact) ? FALSE : $contact; } Index: modules/contact/contact.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.pages.inc,v retrieving revision 1.11 diff -u -p -r1.11 contact.pages.inc --- modules/contact/contact.pages.inc 16 Jul 2008 21:59:26 -0000 1.11 +++ modules/contact/contact.pages.inc 28 Sep 2008 16:44:07 -0000 @@ -28,7 +28,7 @@ function contact_mail_page() { $form = $categories = array(); - $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category'); + $result = db_query('SELECT [cid], [category], [selected] FROM [{contact}] ORDER BY [weight], [category]'); while ($category = db_fetch_object($result)) { $categories[$category->cid] = $category->category; if ($category->selected) { Index: modules/contact/contact.test =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.test,v retrieving revision 1.12 diff -u -p -r1.12 contact.test --- modules/contact/contact.test 17 Sep 2008 06:54:11 -0000 1.12 +++ modules/contact/contact.test 28 Sep 2008 16:44:07 -0000 @@ -72,7 +72,7 @@ class ContactSitewideTestCase extends Dr // Test update contact form category. $categories = $this->getCategories(); $category_id = $this->updateCategory($categories, $category = $this->randomName(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomName(30), FALSE); - $category_array = db_fetch_array(db_query('SELECT category, recipients, reply, selected FROM {contact} WHERE cid = %d', array($category_id))); + $category_array = db_fetch_array(db_query('SELECT [category], [recipients], [reply], [selected] FROM [{contact}] WHERE [cid] = %d', array($category_id))); $this->assertEqual($category_array['category'], $category); $this->assertEqual($category_array['recipients'], $recipients_str); $this->assertEqual($category_array['reply'], $reply); @@ -95,7 +95,7 @@ class ContactSitewideTestCase extends Dr $this->assertRaw(t('Category %category has been added.', array('%category' => $category)), t('Category successfully added.')); // Clear flood table in preparation for flood test and allow other checks to complete. - $this->assertTrue(db_query('DELETE FROM {flood}'), t('Flood table emptied.')); + $this->assertTrue(db_query('DELETE FROM [{flood}]'), t('Flood table emptied.')); // Check to see that anonymous user cannot see contact page without permission. $this->setPermission('anonymous user', array('access site-wide contact form' => FALSE)); @@ -132,7 +132,7 @@ class ContactSitewideTestCase extends Dr $this->assertText(t('Message field is required.'), t('Message required.')); // Test contact form with no default category selected. - db_query('UPDATE {contact} SET selected = 0'); + db_query('UPDATE [{contact}] SET [selected] = 0'); $this->drupalGet('contact'); $this->assertRaw(t('- Please choose -'), t('Without selected categories the visitor is asked to chose a category.')); @@ -215,7 +215,7 @@ class ContactSitewideTestCase extends Dr function deleteCategories() { $categories = $this->getCategories(); foreach ($categories as $category) { - $category_name = db_result(db_query('SELECT category FROM {contact} WHERE cid = %d', array($category))); + $category_name = db_result(db_query('SELECT [category] FROM [{contact}] WHERE [cid] = %d', array($category))); $this->drupalPost('admin/build/contact/delete/' . $category, array(), t('Delete')); $this->assertRaw(t('Category %category has been deleted.', array('%category' => $category_name)), t('Category deleted sucessfully.')); } @@ -227,7 +227,7 @@ class ContactSitewideTestCase extends Dr * @return array Category ids. */ function getCategories() { - $result = db_query('SELECT cid FROM {contact}'); + $result = db_query('SELECT [cid] FROM [{contact}]'); $categories = array(); while ($category = db_result($result)) { $categories[] = $category; @@ -243,7 +243,7 @@ class ContactSitewideTestCase extends Dr */ function setPermission($role, $permissions) { // Get role id (rid) for specified role. - $rid = db_result(db_query("SELECT rid FROM {role} WHERE name = '%s'", array($role))); + $rid = db_result(db_query("SELECT [rid] FROM [{role}] WHERE [name] = %s", array($role))); if ($rid === FALSE) { $this->fail(t(' [permission] Role "' . $role . '" not found.')); } @@ -316,7 +316,7 @@ class ContactPersonalTestCase extends Dr $this->assertText(t('The message has been sent.'), t('Message sent.')); // Clear flood table in preparation for flood test and allow other checks to complete. - $this->assertTrue(db_query('DELETE FROM {flood}'), t('Flood table emptied.')); + $this->assertTrue(db_query('DELETE FROM [{flood}]'), t('Flood table emptied.')); // Submit contact form with correct values and check flood interval. for ($i = 0; $i < $flood_control; $i++) { Index: modules/dblog/dblog.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/dblog/dblog.admin.inc,v retrieving revision 1.8 diff -u -p -r1.8 dblog.admin.inc --- modules/dblog/dblog.admin.inc 19 Jul 2008 07:44:45 -0000 1.8 +++ modules/dblog/dblog.admin.inc 28 Sep 2008 16:44:07 -0000 @@ -55,14 +55,14 @@ function dblog_overview() { $header = array( ' ', - array('data' => t('Type'), 'field' => 'w.type'), - array('data' => t('Date'), 'field' => 'w.wid', 'sort' => 'desc'), + array('data' => t('Type'), 'field' => 'w.[type]'), + array('data' => t('Date'), 'field' => 'w.[wid]', 'sort' => 'desc'), t('Message'), - array('data' => t('User'), 'field' => 'u.name'), + array('data' => t('User'), 'field' => 'u.[name]'), array('data' => t('Operations')), ); - $sql = "SELECT w.wid, w.uid, w.severity, w.type, w.timestamp, w.message, w.variables, w.link, u.name FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid"; + $sql = "SELECT w.[wid], w.[uid], w.[severity], w.[type], w.[timestamp], w.[message], w.[variables], w.[link], u.[name] FROM [{watchdog}] w INNER JOIN [{users}] u ON w.[uid] = u.[uid]"; $tablesort = tablesort_sql($header); if (!empty($filter['where'])) { $result = pager_query($sql . " WHERE " . $filter['where'] . $tablesort, 50, 0, NULL, $filter['args']); @@ -108,7 +108,7 @@ function dblog_top($type) { array('data' => t('Message'), 'field' => 'message') ); - $result = pager_query("SELECT COUNT(wid) AS count, message, variables FROM {watchdog} WHERE type = '%s' GROUP BY message, variables " . tablesort_sql($header), 30, 0, "SELECT COUNT(DISTINCT(message)) FROM {watchdog} WHERE type = '%s'", $type); + $result = pager_query("SELECT COUNT([wid]) AS [count], [message], [variables] FROM [{watchdog}] WHERE [type] = %s GROUP BY [message], [variables] " . tablesort_sql($header), 30, 0, "SELECT COUNT(DISTINCT([message])) FROM [{watchdog}] WHERE [type] = %s", $type); $rows = array(); while ($dblog = db_fetch_object($result)) { @@ -131,7 +131,7 @@ function dblog_top($type) { function dblog_event($id) { $severity = watchdog_severity_levels(); $output = ''; - $result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid WHERE w.wid = %d', $id); + $result = db_query('SELECT w.*, u.[name], u.[uid] FROM [{watchdog}] w INNER JOIN [{users}] u ON w.[uid] = u.[uid] WHERE w.[wid] = %d', $id); if ($dblog = db_fetch_object($result)) { $rows = array( array( @@ -221,14 +221,14 @@ function dblog_filters() { if (!empty($types)) { $filters['type'] = array( 'title' => t('Type'), - 'where' => "w.type = '%s'", + 'where' => "w.[type] = %s", 'options' => $types, ); } $filters['severity'] = array( 'title' => t('Severity'), - 'where' => 'w.severity = %d', + 'where' => 'w.[severity] = %d', 'options' => watchdog_severity_levels(), ); Index: modules/dblog/dblog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/dblog/dblog.module,v retrieving revision 1.27 diff -u -p -r1.27 dblog.module --- modules/dblog/dblog.module 21 Aug 2008 19:36:37 -0000 1.27 +++ modules/dblog/dblog.module 28 Sep 2008 16:44:07 -0000 @@ -96,8 +96,8 @@ function dblog_init() { */ function dblog_cron() { // Cleanup the watchdog table - $max = db_result(db_query('SELECT MAX(wid) FROM {watchdog}')); - db_query('DELETE FROM {watchdog} WHERE wid <= %d', $max - variable_get('dblog_row_limit', 1000)); + $max = db_result(db_query('SELECT MAX([wid]) FROM [{watchdog}]')); + db_query('DELETE FROM [{watchdog}] WHERE [wid] <= %d', $max - variable_get('dblog_row_limit', 1000)); } /** @@ -105,14 +105,14 @@ function dblog_cron() { */ function dblog_user($op, &$edit, &$user) { if ($op == 'delete') { - db_query('UPDATE {watchdog} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE [{watchdog}] SET [uid] = 0 WHERE [uid] = %d', $user->uid); } } function _dblog_get_message_types() { $types = array(); - $result = db_query('SELECT DISTINCT(type) FROM {watchdog} ORDER BY type'); + $result = db_query('SELECT DISTINCT([type]) FROM [{watchdog}] ORDER BY [type]'); while ($object = db_fetch_object($result)) { $types[] = $object->type; } @@ -122,10 +122,10 @@ function _dblog_get_message_types() { function dblog_watchdog($log = array()) { $current_db = db_set_active(); - db_query("INSERT INTO {watchdog} - (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) + db_query("INSERT INTO [{watchdog}] + ([uid], [type], [message], [variables], [severity], [link], [location], [referer], [hostname], [timestamp]) VALUES - (%d, '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', %d)", + (%d, %s, %s, %s, %d, %s, %s, %s, %s, %d)", $log['user']->uid, $log['type'], $log['message'], Index: modules/dblog/dblog.test =================================================================== RCS file: /cvs/drupal/drupal/modules/dblog/dblog.test,v retrieving revision 1.9 diff -u -p -r1.9 dblog.test --- modules/dblog/dblog.test 17 Sep 2008 07:11:56 -0000 1.9 +++ modules/dblog/dblog.test 28 Sep 2008 16:44:07 -0000 @@ -60,7 +60,7 @@ class DBLogTestCase extends DrupalWebTes $current_limit = variable_get('dblog_row_limit', 1000); $this->assertTrue($current_limit == $row_limit, t('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); // Verify dblog row limit equals specified row limit. - $current_limit = unserialize(db_result(db_query("SELECT value FROM {variable} WHERE name = '%s'", 'dblog_row_limit'))); + $current_limit = unserialize(db_result(db_query("SELECT [value] FROM [{variable}] WHERE [name] = %s", 'dblog_row_limit'))); $this->assertTrue($current_limit == $row_limit, t('[Variable table] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); } @@ -73,7 +73,7 @@ class DBLogTestCase extends DrupalWebTes // Generate additional log entries. $this->generateLogEntries($row_limit + 10); // Verify dblog row count exceeds row limit. - $count = db_result(db_query('SELECT COUNT(wid) FROM {watchdog}')); + $count = db_result(db_query('SELECT COUNT([wid]) FROM [{watchdog}]')); $this->assertTrue($count > $row_limit, t('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $row_limit))); // Run cron job. @@ -81,7 +81,7 @@ class DBLogTestCase extends DrupalWebTes $this->assertResponse(200); $this->assertText(t('Cron ran successfully'), t('Cron ran successfully')); // Verify dblog row count equals row limit plus one because cron adds a record after it runs. - $count = db_result(db_query('SELECT COUNT(wid) FROM {watchdog}')); + $count = db_result(db_query('SELECT COUNT([wid]) FROM [{watchdog}]')); $this->assertTrue($count == $row_limit + 1, t('Dblog row count of @count equals row limit of @limit plus one', array('@count' => $count, '@limit' => $row_limit))); } @@ -199,7 +199,7 @@ class DBLogTestCase extends DrupalWebTes // Logout user. $this->drupalLogout(); // Fetch row ids in watchdog that relate to the user. - $result = db_query('SELECT wid FROM {watchdog} WHERE uid = %d', $user->uid); + $result = db_query('SELECT [wid] FROM [{watchdog}] WHERE [uid] = %d', $user->uid); while ($row = db_fetch_array($result)) { $ids[] = $row['wid']; } @@ -208,7 +208,7 @@ class DBLogTestCase extends DrupalWebTes // Delete user. user_delete(array(), $user->uid); // Count rows that have uids for the user. - $count = db_result(db_query('SELECT COUNT(wid) FROM {watchdog} WHERE uid = %d', $user->uid)); + $count = db_result(db_query('SELECT COUNT([wid]) FROM [{watchdog}] WHERE [uid] = %d', $user->uid)); $this->assertTrue($count == 0, t('DBLog contains @count records for @name', array('@count' => $count, '@name' => $user->name))); // Count rows in watchdog that previously related to the deleted user. @@ -222,7 +222,7 @@ class DBLogTestCase extends DrupalWebTes $this->assertTrue($count_after == $count_before, t('DBLog contains @count records for @name that now have uid = 0', array('@count' => $count_before, '@name' => $user->name))); unset($ids); // Fetch row ids in watchdog that relate to the user. - $result = db_query('SELECT wid FROM {watchdog} WHERE uid = %d', $user->uid); + $result = db_query('SELECT [wid] FROM [{watchdog}] WHERE [uid] = %d', $user->uid); while ($row = db_fetch_array($result)) { $ids[] = $row['wid']; } Index: modules/filter/filter.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.admin.inc,v retrieving revision 1.13 diff -u -p -r1.13 filter.admin.inc --- modules/filter/filter.admin.inc 24 Jul 2008 16:27:51 -0000 1.13 +++ modules/filter/filter.admin.inc 28 Sep 2008 16:44:07 -0000 @@ -50,7 +50,7 @@ function filter_admin_overview_submit($f foreach ($form_state['values'] as $id => $data) { if (is_array($data) && isset($data['weight'])) { // Only update if this is a form element with weight. - db_query("UPDATE {filter_formats} SET weight = %d WHERE format = %d", $data['weight'], $id); + db_query("UPDATE [{filter_formats}] SET [weight] = %d WHERE [format] = %d", $data['weight'], $id); } } drupal_set_message(t('The input format ordering has been saved.')); @@ -179,7 +179,7 @@ function filter_admin_format_form(&$form function filter_admin_format_form_validate($form, &$form_state) { if (!isset($form_state['values']['format'])) { $name = trim($form_state['values']['name']); - $result = db_fetch_object(db_query("SELECT format FROM {filter_formats} WHERE name='%s'", $name)); + $result = db_fetch_object(db_query("SELECT [format] FROM [{filter_formats}] WHERE [name] = %s", $name)); if ($result) { form_set_error('name', t('Filter format names need to be unique. A format named %name already exists.', array('%name' => $name))); } @@ -198,21 +198,21 @@ function filter_admin_format_form_submit // Add a new filter format. if (!$format) { $new = TRUE; - db_query("INSERT INTO {filter_formats} (name) VALUES ('%s')", $name); - $format = db_result(db_query("SELECT MAX(format) AS format FROM {filter_formats}")); + db_query("INSERT INTO [{filter_formats}] ([name]) VALUES (%s)", $name); + $format = db_result(db_query("SELECT MAX([format]) AS [format] FROM [{filter_formats}]")); drupal_set_message(t('Added input format %format.', array('%format' => $name))); } else { drupal_set_message(t('The input format settings have been updated.')); } - db_query("DELETE FROM {filters} WHERE format = %d", $format); + db_query("DELETE FROM [{filters}] WHERE [format] = %d", $format); foreach ($form_state['values']['filters'] as $id => $checked) { if ($checked) { list($module, $delta) = explode('/', $id); // Add new filters to the bottom. $weight = isset($current[$id]->weight) ? $current[$id]->weight : 10; - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $format, $module, $delta, $weight); + db_query("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (%d, %s, %d, %d)", $format, $module, $delta, $weight); // Check if there are any 'no cache' filters. $cache &= !module_invoke($module, 'filter', 'no cache', $delta); @@ -237,7 +237,7 @@ function filter_admin_format_form_submit $roles = ',' . implode(',', $roles) . ','; } - db_query("UPDATE {filter_formats} SET cache = %d, name='%s', roles = '%s' WHERE format = %d", $cache, $name, $roles, $format); + db_query("UPDATE [{filter_formats}] SET [cache] = %d, [name] = %s, [roles] = %s WHERE [format] = %d", $cache, $name, $roles, $format); cache_clear_all($format . ':', 'cache_filter', TRUE); @@ -258,7 +258,7 @@ function filter_admin_format_form_submit */ function filter_admin_delete() { $format = arg(4); - $format = db_fetch_object(db_query('SELECT * FROM {filter_formats} WHERE format = %d', $format)); + $format = db_fetch_object(db_query('SELECT * FROM [{filter_formats}] WHERE [format] = %d', $format)); if ($format) { if ($format->format != variable_get('filter_default_format', 1)) { @@ -281,14 +281,14 @@ function filter_admin_delete() { * Process filter delete form submission. */ function filter_admin_delete_submit($form, &$form_state) { - db_query("DELETE FROM {filter_formats} WHERE format = %d", $form_state['values']['format']); - db_query("DELETE FROM {filters} WHERE format = %d", $form_state['values']['format']); + db_query("DELETE FROM [{filter_formats}] WHERE [format] = %d", $form_state['values']['format']); + db_query("DELETE FROM [{filters}] WHERE [format] = %d", $form_state['values']['format']); $default = variable_get('filter_default_format', 1); // Replace existing instances of the deleted format with the default format. - db_query("UPDATE {node_revisions} SET format = %d WHERE format = %d", $default, $form_state['values']['format']); - db_query("UPDATE {comments} SET format = %d WHERE format = %d", $default, $form_state['values']['format']); - db_query("UPDATE {boxes} SET format = %d WHERE format = %d", $default, $form_state['values']['format']); + db_query("UPDATE [{node_revisions}] SET [format] = %d WHERE [format] = %d", $default, $form_state['values']['format']); + db_query("UPDATE [{comments}] SET [format] = %d WHERE [format] = %d", $default, $form_state['values']['format']); + db_query("UPDATE [{boxes}] SET [format] = %d WHERE [format] = %d", $default, $form_state['values']['format']); cache_clear_all($form_state['values']['format'] . ':', 'cache_filter', TRUE); drupal_set_message(t('Deleted input format %format.', array('%format' => $form_state['values']['name']))); @@ -402,7 +402,7 @@ function theme_filter_admin_order($form) function filter_admin_order_submit($form, &$form_state) { foreach ($form_state['values']['weights'] as $id => $weight) { list($module, $delta) = explode('/', $id); - db_query("UPDATE {filters} SET weight = %d WHERE format = %d AND module = '%s' AND delta = %d", $weight, $form_state['values']['format'], $module, $delta); + db_query("UPDATE [{filters}] SET [weight] = %d WHERE [format] = %d AND [module] = %s AND [delta] = %d", $weight, $form_state['values']['format'], $module, $delta); } drupal_set_message(t('The filter ordering has been saved.')); Index: modules/filter/filter.install =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.install,v retrieving revision 1.9 diff -u -p -r1.9 filter.install --- modules/filter/filter.install 14 Apr 2008 17:48:37 -0000 1.9 +++ modules/filter/filter.install 28 Sep 2008 16:44:07 -0000 @@ -112,11 +112,11 @@ function filter_update_7000() { */ function filter_update_7001() { $ret = array(); - $result = db_query("SELECT format FROM {filter_formats}"); + $result = db_query("SELECT [format] FROM [{filter_formats}]"); while ($format = db_fetch_object($result)) { // Deprecated constants FILTER_HTML_STRIP = 1 and FILTER_HTML_ESCAPE = 2. if (variable_get('filter_html_' . $format->format, 1) == 2) { - $ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (" . $format->format . ", 'filter', 4, 0)"); + $ret[] = update_sql("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (" . $format->format . ", 'filter', 4, 0)"); } variable_del('filter_html_' . $format->format); } Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.227 diff -u -p -r1.227 filter.module --- modules/filter/filter.module 19 Sep 2008 07:53:59 -0000 1.227 +++ modules/filter/filter.module 28 Sep 2008 16:44:07 -0000 @@ -304,7 +304,7 @@ function filter_formats($index = NULL) { if (!$all) { $or = db_or()->condition('format', variable_get('filter_default_format', 1)); foreach ($user->roles as $rid => $role) { - $or->condition('roles', '%'. (int)$rid .'%', 'LIKE'); + $or->condition('roles', '%' . (int)$rid . '%', 'LIKE'); } $query->condition($or); } @@ -357,7 +357,7 @@ function filter_format_allowcache($forma static $cache = array(); $format = filter_resolve_format($format); if (!isset($cache[$format])) { - $cache[$format] = db_result(db_query('SELECT cache FROM {filter_formats} WHERE format = %d', $format)); + $cache[$format] = db_result(db_query('SELECT [cache] FROM [{filter_formats}] WHERE [format] = %d', $format)); } return $cache[$format]; } @@ -370,7 +370,7 @@ function filter_list_format($format) { if (!isset($filters[$format])) { $filters[$format] = array(); - $result = db_query("SELECT * FROM {filters} WHERE format = %d ORDER BY weight, module, delta", $format); + $result = db_query("SELECT * FROM [{filters}] WHERE [format] = %d ORDER BY [weight], [module], [delta]", $format); while ($filter = db_fetch_object($result)) { $list = module_invoke($filter->module, 'filter', 'list'); if (isset($list) && is_array($list) && isset($list[$filter->delta])) { @@ -552,7 +552,7 @@ function _filter_tips($format, $long = F $formats = filter_formats(); } else { - $formats = array(db_fetch_object(db_query("SELECT * FROM {filter_formats} WHERE format = %d", $format))); + $formats = array(db_fetch_object(db_query("SELECT * FROM [{filter_formats}] WHERE [format] = %d", $format))); } $tips = array(); Index: modules/filter/filter.test =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.test,v retrieving revision 1.7 diff -u -p -r1.7 filter.test --- modules/filter/filter.test 27 Sep 2008 19:47:42 -0000 1.7 +++ modules/filter/filter.test 28 Sep 2008 16:44:07 -0000 @@ -44,7 +44,7 @@ class FilterAdminTestCase extends Drupal $this->assertRaw(htmlentities($edit['allowed_html_1']), t('Tag displayed.')); - $result = db_fetch_object(db_query('SELECT * FROM {cache_filter}')); + $result = db_fetch_object(db_query('SELECT * FROM [{cache_filter}]')); $this->assertFalse($result, t('Cache cleared.')); // Reorder filters. @@ -54,7 +54,7 @@ class FilterAdminTestCase extends Drupal $this->drupalPost('admin/settings/filters/' . $filtered . '/order', $edit, t('Save configuration')); $this->assertText(t('The filter ordering has been saved.'), t('Order saved successfully.')); - $result = db_query('SELECT * FROM {filters} WHERE format = %d ORDER BY weight ASC', $filtered); + $result = db_query('SELECT * FROM [{filters}] WHERE [format] = %d ORDER BY [weight] ASC', $filtered); $filters = array(); while ($filter = db_fetch_object($result)) { if ($filter->delta == $second_filter || $filter->delta == $first_filter) { @@ -154,7 +154,7 @@ class FilterAdminTestCase extends Drupal * @return Array Array containing filtered and full filter ids. */ function checkFilterFormats() { - $result = db_query('SELECT format, name FROM {filter_formats}'); + $result = db_query('SELECT [format], [name] FROM [{filter_formats}]'); $filtered = -1; $full = -1; @@ -177,7 +177,7 @@ class FilterAdminTestCase extends Drupal * @return object Filter object. */ function getFilter($name) { - return db_fetch_object(db_query("SELECT * FROM {filter_formats} WHERE name = '%s'", $name)); + return db_fetch_object(db_query("SELECT * FROM [{filter_formats}] WHERE [name] = %s", $name)); } } @@ -226,7 +226,7 @@ class FilterTestCase extends DrupalWebTe 'filters[filter/' . $filter . ']' => TRUE, ); $this->drupalPost('admin/settings/filters/add', $edit, t('Save configuration')); - return db_fetch_object(db_query("SELECT * FROM {filter_formats} WHERE name = '%s'", $edit['name'])); + return db_fetch_object(db_query("SELECT * FROM [{filter_formats}] WHERE [name] = %s", $edit['name'])); } function deleteFormat($format) { Index: modules/forum/forum.install =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.install,v retrieving revision 1.19 diff -u -p -r1.19 forum.install --- modules/forum/forum.install 25 Jun 2008 07:47:20 -0000 1.19 +++ modules/forum/forum.install 28 Sep 2008 16:44:07 -0000 @@ -8,7 +8,7 @@ function forum_install() { // Create tables. drupal_install_schema('forum'); // Set the weight of the forum.module to 1 so it is loaded after the taxonomy.module. - db_query("UPDATE {system} SET weight = 1 WHERE name = 'forum'"); + db_query("UPDATE [{system}] SET [weight] = 1 WHERE [name] = 'forum'"); } function forum_enable() { @@ -50,7 +50,7 @@ function forum_uninstall() { $vid = variable_get('forum_nav_vocabulary', ''); taxonomy_del_vocabulary($vid); - db_query('DROP TABLE {forum}'); + db_query('DROP TABLE [{forum}]'); variable_del('forum_containers'); variable_del('forum_nav_vocabulary'); variable_del('forum_hot_topic'); Index: modules/forum/forum.module =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v retrieving revision 1.464 diff -u -p -r1.464 forum.module --- modules/forum/forum.module 19 Sep 2008 20:25:02 -0000 1.464 +++ modules/forum/forum.module 28 Sep 2008 16:44:07 -0000 @@ -74,7 +74,7 @@ function forum_theme() { * An associative array containing the term data or FALSE if the term cannot be loaded, or is not part of the forum vocabulary. */ function forum_term_load($tid) { - $result = db_query(db_rewrite_sql('SELECT t.tid, t.vid, t.name, t.description, t.weight FROM {term_data} t WHERE t.tid = %d AND t.vid = %d', 't', 'tid'), $tid, variable_get('forum_nav_vocabulary', '')); + $result = db_query(db_rewrite_sql('SELECT t.[tid], t.[vid], t.[name], t.[description], t.[weight] FROM [{term_data}] t WHERE t.[tid] = %d AND t.[vid] = %d', 't', 'tid'), $tid, variable_get('forum_nav_vocabulary', '')); return db_fetch_array($result); } @@ -222,7 +222,7 @@ function forum_nodeapi(&$node, $op, $tea $vocabulary = $vid; $containers = variable_get('forum_containers', array()); foreach ($node->taxonomy as $term) { - if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) { + if (db_result(db_query('SELECT COUNT(*) FROM [{term_data}] WHERE [tid] = %d AND [vid] = %d', $term, $vocabulary))) { if (in_array($term, $containers)) { $term = taxonomy_term_load($term); form_set_error('taxonomy', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name))); @@ -247,7 +247,7 @@ function forum_nodeapi(&$node, $op, $tea $node->tid = $term_id; } } - $old_tid = db_result(db_query_range("SELECT t.tid FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.nid = %d ORDER BY t.vid DESC", $node->nid, 0, 1)); + $old_tid = db_result(db_query_range("SELECT t.[tid] FROM [{term_node}] t INNER JOIN [{node}] n ON t.[vid] = n.[vid] WHERE n.[nid] = %d ORDER BY t.[vid] DESC", $node->nid, 0, 1)); if ($old_tid && isset($node->tid) && ($node->tid != $old_tid) && !empty($node->shadow)) { // A shadow copy needs to be created. Retain new term and add old term. $node->taxonomy[] = $old_tid; @@ -256,13 +256,13 @@ function forum_nodeapi(&$node, $op, $tea break; case 'update': - if (empty($node->revision) && db_result(db_query('SELECT tid FROM {forum} WHERE nid=%d', $node->nid))) { + if (empty($node->revision) && db_result(db_query('SELECT [tid] FROM [{forum}] WHERE [nid] = %d', $node->nid))) { if (!empty($node->tid)) { - db_query('UPDATE {forum} SET tid = %d WHERE vid = %d', $node->tid, $node->vid); + db_query('UPDATE [{forum}] SET [tid] = %d WHERE [vid] = %d', $node->tid, $node->vid); } // The node is removed from the forum. else { - db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid); + db_query('DELETE FROM [{forum}] WHERE [nid] = %d', $node->nid); } break; } @@ -270,16 +270,16 @@ function forum_nodeapi(&$node, $op, $tea case 'insert': if (!empty($node->tid)) { - db_query('INSERT INTO {forum} (tid, vid, nid) VALUES (%d, %d, %d)', $node->tid, $node->vid, $node->nid); + db_query('INSERT INTO [{forum}] ([tid], [vid], [nid]) VALUES (%d, %d, %d)', $node->tid, $node->vid, $node->nid); } break; case 'delete': - db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid); + db_query('DELETE FROM [{forum}] WHERE [nid] = %d', $node->nid); break; case 'load': - return db_fetch_array(db_query('SELECT tid AS forum_tid FROM {forum} WHERE vid = %d', $node->vid)); + return db_fetch_array(db_query('SELECT [tid] AS [forum_tid] FROM [{forum}] WHERE [vid] = %d', $node->vid)); } return; @@ -331,7 +331,7 @@ function forum_taxonomy($op, $type, $ter if ($op == 'delete' && $term['vid'] == variable_get('forum_nav_vocabulary', '')) { switch ($type) { case 'term': - $results = db_query('SELECT tn.nid FROM {term_node} tn WHERE tn.tid = %d', $term['tid']); + $results = db_query('SELECT tn.[nid] FROM [{term_node}] tn WHERE tn.[tid] = %d', $term['tid']); while ($node = db_fetch_object($results)) { // node_delete will also remove any association with non-forum vocabularies. node_delete($node->nid); @@ -388,7 +388,7 @@ function forum_form_alter(&$form, $form_ * Implementation of hook_load(). */ function forum_load($node) { - $forum = db_fetch_object(db_query('SELECT * FROM {term_node} WHERE vid = %d', $node->vid)); + $forum = db_fetch_object(db_query('SELECT * FROM [{term_node}] WHERE [vid] = %d', $node->vid)); return $forum; } @@ -419,14 +419,14 @@ function forum_block($op = 'list', $delt switch ($delta) { case 'active': $title = t('Active forum topics'); - $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid INNER JOIN {term_data} td ON td.tid = tn.tid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND td.vid = %d ORDER BY l.last_comment_timestamp DESC"); + $sql = db_rewrite_sql("SELECT n.[nid], n.[title], l.[comment_count], l.[last_comment_timestamp] FROM [{node}] n INNER JOIN [{term_node}] tn ON tn.[vid] = n.[vid] INNER JOIN [{term_data}] td ON td.[tid] = tn.[tid] INNER JOIN [{node_comment_statistics}] l ON n.[nid] = l.[nid] WHERE n.[status] = 1 AND td.[vid] = %d ORDER BY l.[last_comment_timestamp] DESC"); $result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_active', '5')); $content = node_title_list($result); break; case 'new': $title = t('New forum topics'); - $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid INNER JOIN {term_data} td ON td.tid = tn.tid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND td.vid = %d ORDER BY n.nid DESC"); + $sql = db_rewrite_sql("SELECT n.[nid], n.[title], l.[comment_count] FROM [{node}] n INNER JOIN [{term_node}] tn ON tn.[vid] = n.[vid] INNER JOIN [{term_data}] td ON td.[tid] = tn.[tid] INNER JOIN [{node_comment_statistics}] l ON n.[nid] = l.[nid] WHERE n.[status] = 1 AND td.[vid] = %d ORDER BY n.[nid] DESC"); $result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_new', '5')); $content = node_title_list($result); break; @@ -494,7 +494,7 @@ function forum_get_forums($tid = 0) { $counts = array(); - $sql = "SELECT r.tid, COUNT(n.nid) AS topic_count, SUM(l.comment_count) AS comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.vid = r.vid WHERE n.status = 1 GROUP BY r.tid"; + $sql = "SELECT r.[tid], COUNT(n.[nid]) AS [topic_count], SUM(l.[comment_count]) AS [comment_count] FROM [{node}] n INNER JOIN [{node_comment_statistics}] l ON n.[nid] = l.[nid] INNER JOIN [{term_node}] r ON n.[vid] = r.[vid] WHERE n.[status] = 1 GROUP BY r.[tid]"; $sql = db_rewrite_sql($sql); $_counts = db_query($sql); while ($count = db_fetch_object($_counts)) { @@ -519,7 +519,7 @@ function forum_get_forums($tid = 0) { // This query does not use full ANSI syntax since MySQL 3.x does not support // table1 INNER JOIN table2 INNER JOIN table3 ON table2_criteria ON table3_criteria // used to join node_comment_statistics to users. - $sql = "SELECT ncs.last_comment_timestamp, IF (ncs.last_comment_uid != 0, u2.name, ncs.last_comment_name) AS last_comment_name, ncs.last_comment_uid FROM {node} n INNER JOIN {users} u1 ON n.uid = u1.uid INNER JOIN {term_node} tn ON n.vid = tn.vid INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid INNER JOIN {users} u2 ON ncs.last_comment_uid=u2.uid WHERE n.status = 1 AND tn.tid = %d ORDER BY ncs.last_comment_timestamp DESC"; + $sql = "SELECT nc.[last_comment_timestamp], IF (nc.[last_comment_uid] <> 0, u2.[name], nc.[last_comment_name]) AS [last_comment_name], nc.[last_comment_uid] FROM [{node}] n INNER JOIN [{users}] u1 ON n.[uid] = u1.[uid] INNER JOIN [{term_node}] tn ON n.[vid] = tn.[vid] INNER JOIN [{node_comment_statistics}] nc ON n.[nid] = nc.[nid] INNER JOIN [{users}] u2 ON nc.[last_comment_uid] = u2.[uid] WHERE n.[status] = 1 AND tn.[tid] = %d ORDER BY nc.[last_comment_timestamp] DESC"; $sql = db_rewrite_sql($sql); $topic = db_fetch_object(db_query_range($sql, $forum->tid, 0, 1)); @@ -542,7 +542,7 @@ function forum_get_forums($tid = 0) { * than NODE_NEW_LIMIT. */ function _forum_topics_unread($term, $uid) { - $sql = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid AND tn.tid = %d LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d WHERE n.status = 1 AND n.created > %d AND h.nid IS NULL"; + $sql = "SELECT COUNT(n.[nid]) FROM [{node}] n INNER JOIN [{term_node}] tn ON n.[vid] = tn.[vid] AND tn.[tid] = %d LEFT JOIN [{history}] h ON n.[nid] = h.[nid] AND h.[uid] = %d WHERE n.[status] = 1 AND n.[created] > %d AND h.[nid] IS NULL"; $sql = db_rewrite_sql($sql); return db_result(db_query($sql, $term, $uid, NODE_NEW_LIMIT)); } @@ -567,11 +567,11 @@ function forum_get_topics($tid, $sortby, $term = taxonomy_term_load($tid); - $sql = db_rewrite_sql("SELECT n.nid, r.tid, n.title, n.type, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid != 0, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments, f.tid AS forum_tid FROM {node_comment_statistics} l INNER JOIN {node} n ON n.nid = l.nid INNER JOIN {users} cu ON l.last_comment_uid = cu.uid INNER JOIN {term_node} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {forum} f ON n.vid = f.vid WHERE n.status = 1 AND r.tid = %d"); - $sql .= tablesort_sql($forum_topic_list_header, 'n.sticky DESC,'); - $sql .= ', n.created DESC'; // Always add a secondary sort order so that the news forum topics are on top. + $sql = db_rewrite_sql("SELECT n.[nid], r.[tid], n.[title], n.[type], n.[sticky], u.[name], u.[uid], n.[created] AS [timestamp], n.[comment] AS [comment_mode], l.[last_comment_timestamp], IF(l.[last_comment_uid] <> 0, cu.[name], l.[last_comment_name]) AS [last_comment_name], l.[last_comment_uid], l.[comment_count] AS [num_comments], f.[tid] AS [forum_tid] FROM [{node_comment_statistics}] l INNER JOIN [{node}] n ON n.[nid] = l.[nid] INNER JOIN [{users}] cu ON l.[last_comment_uid] = cu.[uid] INNER JOIN [{term_node}] r ON n.[vid] = r.[vid] INNER JOIN [{users}] u ON n.[uid] = u.[uid] INNER JOIN [{forum}] f ON n.[vid] = f.[vid] WHERE n.[status] = 1 AND r.[tid] = %d"); + $sql .= tablesort_sql($forum_topic_list_header, 'n.[sticky] DESC,'); + $sql .= ', n.[created] DESC'; // Always add a secondary sort order so that the news forum topics are on top. - $sql_count = db_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.vid = r.vid AND r.tid = %d WHERE n.status = 1"); + $sql_count = db_rewrite_sql("SELECT COUNT(n.[nid]) FROM [{node}] n INNER JOIN [{term_node}] r ON n.[vid] = r.[vid] AND r.[tid] = %d WHERE n.[status] = 1"); $result = pager_query($sql, $forum_per_page, 0, $sql_count, $tid); $topics = array(); @@ -612,7 +612,7 @@ function forum_get_topics($tid, $sortby, function _forum_new($tid) { global $user; - $sql = "SELECT n.nid FROM {node} n LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND h.nid IS NULL AND n.created > %d ORDER BY created"; + $sql = "SELECT n.[nid] FROM [{node}] n LEFT JOIN [{history}] h ON n.[nid] = h.[nid] AND h.[uid] = %d INNER JOIN [{term_node}] r ON n.[nid] = r.[nid] AND r.[tid] = %d WHERE n.[status] = 1 AND h.[nid] IS NULL AND n.[created] > %d ORDER BY [created]"; $sql = db_rewrite_sql($sql); $nid = db_result(db_query_range($sql, $user->uid, $tid, NODE_NEW_LIMIT, 0, 1)); @@ -875,7 +875,7 @@ function template_preprocess_forum_topic $output = ''; // get previous and next topic - $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 ORDER BY n.sticky DESC, " . _forum_get_topic_order_sql(variable_get('forum_order', 1)); + $sql = "SELECT n.[nid], n.[title], n.[sticky], l.[comment_count], l.[last_comment_timestamp] FROM [{node}] n INNER JOIN [{node_comment_statistics}] l ON n.[nid] = l.[nid] INNER JOIN [{term_node}] r ON n.[nid] = r.[nid] AND r.[tid] = %d WHERE n.[status] = 1 ORDER BY n.[sticky] DESC, " . _forum_get_topic_order_sql(variable_get('forum_order', 1)); $result = db_query(db_rewrite_sql($sql), isset($variables['node']->tid) ? $variables['node']->tid : 0); $stop = $variables['prev'] = $variables['next'] = 0; @@ -916,7 +916,7 @@ function _forum_user_last_visit($nid) { static $history = array(); if (empty($history)) { - $result = db_query('SELECT nid, timestamp FROM {history} WHERE uid = %d', $user->uid); + $result = db_query('SELECT [nid], [timestamp] FROM [{history}] WHERE [uid] = %d', $user->uid); while ($t = db_fetch_object($result)) { $history[$t->nid] = $t->timestamp > NODE_NEW_LIMIT ? $t->timestamp : NODE_NEW_LIMIT; } @@ -943,5 +943,5 @@ function _forum_get_topic_order($sortby) function _forum_get_topic_order_sql($sortby) { $order = _forum_get_topic_order($sortby); - return $order['field'] . ' ' . strtoupper($order['sort']); + return db_escape_constraint($order['field']) . ' ' . strtoupper($order['sort']); } Index: modules/forum/forum.test =================================================================== RCS file: /cvs/drupal/drupal/modules/forum/forum.test,v retrieving revision 1.4 diff -u -p -r1.4 forum.test --- modules/forum/forum.test 19 Sep 2008 20:25:02 -0000 1.4 +++ modules/forum/forum.test 28 Sep 2008 16:44:07 -0000 @@ -92,7 +92,7 @@ class ForumTestCase extends DrupalWebTes $this->assertText(t('The block settings have been updated.'), t('[New forum topics] Forum block was enabled')); // Retrieve forum menu id. - $mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = 'forum' AND menu_name = 'navigation' AND module = 'system' ORDER BY mlid ASC", 0, 1)); + $mlid = db_result(db_query_range("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = 'forum' AND [menu_name] = 'navigation' AND [module] = 'system' ORDER BY [mlid] ASC", 0, 1)); // Add forum to navigation menu. $edit = array(); @@ -120,7 +120,7 @@ class ForumTestCase extends DrupalWebTes $vid = variable_get('forum_nav_vocabulary', ''); // This function returns NULL (the cache value is false). // $original_settings = taxonomy_vocabulary_load($vid); - $original_settings = db_fetch_array(db_query('SELECT v.* FROM {vocabulary} v WHERE v.vid = %d', $vid)); + $original_settings = db_fetch_array(db_query('SELECT v.* FROM [{vocabulary}] v WHERE v.[vid] = %d', $vid)); // Generate a random name/description. $title = $this->randomName(10); @@ -139,7 +139,7 @@ class ForumTestCase extends DrupalWebTes $this->assertRaw(t('Updated vocabulary %name.', array('%name' => $title)), t('Vocabulary was edited')); // Grab the newly edited vocabulary. - $cur_settings = db_fetch_array(db_query('SELECT v.* FROM {vocabulary} v WHERE v.vid = %d', $vid)); + $cur_settings = db_fetch_array(db_query('SELECT v.* FROM [{vocabulary}] v WHERE v.[vid] = %d', $vid)); // Make sure we actually edited the vocabulary properly. $this->assertTrue($cur_settings['name'] == $title, 'The name was updated'); @@ -165,7 +165,7 @@ class ForumTestCase extends DrupalWebTes // Verify original forum taxonomy. $original_settings = (array) $original_settings; taxonomy_save_vocabulary($original_settings); // This fails because taxonomy_vocabulary_load returns NULL. - $cur_settings = db_fetch_array(db_query('SELECT v.* FROM {vocabulary} v WHERE v.vid = %d', $vid)); + $cur_settings = db_fetch_array(db_query('SELECT v.* FROM [{vocabulary}] v WHERE v.[vid] = %d', $vid)); $this->assertTrue($cur_settings['name'] == $original_settings['name'], 'The name was restored'); $this->assertTrue(!isset($cur_settings['description']), 'The description was restored'); */ @@ -197,12 +197,12 @@ class ForumTestCase extends DrupalWebTes $this->assertRaw(t('Created new @type %term.', array('%term' => $name, '@type' => t($type))), t(ucfirst($type) . ' was created')); // Verify forum. - $term = db_fetch_array(db_query("SELECT * FROM {term_data} t WHERE t.vid = %d AND t.name = '%s' AND t.description = '%s'", variable_get('forum_nav_vocabulary', ''), $name, $description)); + $term = db_fetch_array(db_query("SELECT * FROM [{term_data}] t WHERE t.[vid] = %d AND t.[name] = %s AND t.[description] = %s", variable_get('forum_nav_vocabulary', ''), $name, $description)); $this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database'); // Verify forum hierarchy. $tid = $term['tid']; - $parent_tid = db_result(db_query("SELECT t.parent FROM {term_hierarchy} t WHERE t.tid = %d", $tid)); + $parent_tid = db_result(db_query("SELECT t.[parent] FROM [{term_hierarchy}] t WHERE t.[tid] = %d", $tid)); $this->assertTrue($parent == $parent_tid, 'The ' . $type . ' is linked to its container'); return $term; @@ -336,7 +336,7 @@ class ForumTestCase extends DrupalWebTes $this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit['title'])), t('Forum node was edited')); // Verify topic was moved to a different forum. - $forum_tid = db_result(db_query("SELECT tid FROM {forum} WHERE nid = %d AND vid = %d", $node->nid, $node->vid)); + $forum_tid = db_result(db_query("SELECT [tid] FROM [{forum}] WHERE [nid] = %d AND [vid] = %d", $node->nid, $node->vid)); $this->assertTrue($forum_tid == $this->root_forum['tid'], 'The forum topic is linked to a different forum'); // Delete forum node. Index: modules/help/help.test =================================================================== RCS file: /cvs/drupal/drupal/modules/help/help.test,v retrieving revision 1.2 diff -u -p -r1.2 help.test --- modules/help/help.test 30 May 2008 07:30:51 -0000 1.2 +++ modules/help/help.test 28 Sep 2008 16:44:07 -0000 @@ -76,7 +76,7 @@ class HelpTestCase extends DrupalWebTest */ private function getModuleList() { $this->modules = array(); - $result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC"); + $result = db_query("SELECT [name], [filename], [info] FROM [{system}] WHERE [type] = 'module' AND [status] = 1 ORDER BY [weight] ASC, [filename] ASC"); while ($module = db_fetch_object($result)) { if (file_exists($module->filename)) { $fullname = unserialize($module->info); Index: modules/locale/locale.install =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.install,v retrieving revision 1.30 diff -u -p -r1.30 locale.install --- modules/locale/locale.install 14 Apr 2008 17:48:37 -0000 1.30 +++ modules/locale/locale.install 28 Sep 2008 16:44:07 -0000 @@ -12,7 +12,7 @@ function locale_install() { // Create tables. drupal_install_schema('locale'); - db_query("INSERT INTO {languages} (language, name, native, direction, enabled, weight, javascript) VALUES ('en', 'English', 'English', '0', '1', '0', '')"); + db_query("INSERT INTO [{languages}] ([language], [name], [native], [direction], [enabled], [weight], [javascript]) VALUES (%s, %s, %s, %d, %d, %d, %s)", 'en', 'English', 'English', '0', '1', '0', ''); } /** @@ -100,17 +100,17 @@ function locale_update_6000() { db_create_table($ret, 'languages', $schema['languages']); // Save the languages - $ret[] = update_sql("INSERT INTO {languages} (language, name, native, direction, enabled, plurals, formula, domain, prefix, weight) SELECT locale, name, name, 0, enabled, plurals, formula, '', locale, 0 FROM {locales_meta}"); + $ret[] = update_sql("INSERT INTO [{languages}] ([language], [name], [native], [direction], [enabled], [plurals], [formula], [domain], [prefix], [weight]) SELECT [locale], [name], [name], 0, [enabled], [plurals], [formula], '', [locale], 0 FROM [{locales_meta}]"); // Save the language count in the variable table - $count = db_result(db_query('SELECT COUNT(*) FROM {languages} WHERE enabled = 1')); + $count = db_result(db_query('SELECT COUNT(*) FROM [{languages}] WHERE [enabled] = 1')); variable_set('language_count', $count); // Save the default language in the variable table - $default = db_fetch_object(db_query('SELECT * FROM {locales_meta} WHERE isdefault = 1')); + $default = db_fetch_object(db_query('SELECT * FROM [{locales_meta}] WHERE [isdefault] = 1')); variable_set('language_default', (object) array('language' => $default->locale, 'name' => $default->name, 'native' => '', 'direction' => 0, 'enabled' => 1, 'plurals' => $default->plurals, 'formula' => $default->formula, 'domain' => '', 'prefix' => $default->locale, 'weight' => 0)); - $ret[] = update_sql("DROP TABLE {locales_meta}"); + $ret[] = update_sql("DROP TABLE [{locales_meta}]"); return $ret; } @@ -122,7 +122,7 @@ function locale_update_6000() { */ function locale_update_6001() { $ret = array(); - $ret[] = update_sql('UPDATE {locales_target} SET language = locale'); + $ret[] = update_sql('UPDATE [{locales_target}] SET [language] = [locale]'); db_drop_field($ret, 'locales_target', 'locale'); return $ret; } @@ -132,7 +132,7 @@ function locale_update_6001() { */ function locale_update_6002() { $ret = array(); - $ret[] = update_sql("DELETE FROM {locales_target} WHERE translation = ''"); + $ret[] = update_sql("DELETE FROM [{locales_target}] WHERE [translation] = ''"); return $ret; } @@ -141,7 +141,7 @@ function locale_update_6002() { */ function locale_update_6003() { $ret = array(); - $ret[] = update_sql("DELETE FROM {locales_source} WHERE lid NOT IN (SELECT lid FROM {locales_target})"); + $ret[] = update_sql("DELETE FROM [{locales_source}] WHERE [lid] NOT IN (SELECT [lid] FROM [{locales_target}])"); return $ret; } @@ -196,7 +196,7 @@ function locale_update_6005() { } } // Update language count variable that might be overwritten. - $count = db_result(db_query('SELECT COUNT(*) FROM {languages} WHERE enabled = 1')); + $count = db_result(db_query('SELECT COUNT(*) FROM [{languages}] WHERE [enabled] = 1')); variable_set('language_count', $count); return array(); } @@ -210,7 +210,7 @@ function locale_update_6005() { */ function locale_uninstall() { // Delete all JavaScript translation files - $files = db_query('SELECT javascript FROM {languages}'); + $files = db_query('SELECT [javascript] FROM [{languages}]'); while ($file = db_fetch_object($files)) { if (!empty($file)) { file_delete(file_create_path($file->javascript)); @@ -361,7 +361,7 @@ function locale_schema() { ), 'translation' => array( 'type' => 'text', - 'mysql_type' => 'blob', + 'mysql_type' => 'BLOB', 'not null' => TRUE, 'description' => t('Translation string value in this language.'), ), Index: modules/locale/locale.module =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v retrieving revision 1.223 diff -u -p -r1.223 locale.module --- modules/locale/locale.module 20 Sep 2008 20:22:24 -0000 1.223 +++ modules/locale/locale.module 28 Sep 2008 16:44:07 -0000 @@ -363,7 +363,7 @@ function locale($string = NULL, $langcod // Refresh database stored cache of translations for given language. // We only store short strings used in current version, to improve // performance and consume less memory. - $result = db_query("SELECT s.source, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = 'default' AND s.version = '%s' AND LENGTH(s.source) < 75", $langcode, VERSION); + $result = db_query("SELECT s.[source], t.[translation], t.[language] FROM [{locales_source}] s LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] AND t.[language] = %s WHERE s.[textgroup] = 'default' AND s.[version] = %s AND " . db_strlen() . "(s.[source]) < 75", $langcode, VERSION); while ($data = db_fetch_object($result)) { $locale_t[$langcode][$data->source] = (empty($data->translation) ? TRUE : $data->translation); } @@ -376,7 +376,7 @@ function locale($string = NULL, $langcod if (!isset($locale_t[$langcode][$string])) { // We do not have this translation cached, so get it from the DB. - $translation = db_fetch_object(db_query("SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.source = '%s' AND s.textgroup = 'default'", $langcode, $string)); + $translation = db_fetch_object(db_query("SELECT s.[lid], t.[translation], s.[version] FROM [{locales_source}] s LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] AND t.[language] = %s WHERE s.[source] = %s AND s.[textgroup] = 'default'", $langcode, $string)); if ($translation) { // We have the source string at least. // Cache translation string or TRUE if no translation exists. @@ -386,13 +386,13 @@ function locale($string = NULL, $langcod // This is the first use of this string under current Drupal version. Save version // and clear cache, to include the string into caching next time. Saved version is // also a string-history information for later pruning of the tables. - db_query("UPDATE {locales_source} SET version = '%s' WHERE lid = %d", VERSION, $translation->lid); + db_query("UPDATE [{locales_source}] SET [version] = %s WHERE [lid] = %d", VERSION, $translation->lid); cache_clear_all('locale:', 'cache', TRUE); } } else { // We don't have the source string, cache this as untranslated. - db_query("INSERT INTO {locales_source} (location, source, textgroup, version) VALUES ('%s', '%s', 'default', '%s')", request_uri(), $string, VERSION); + db_query("INSERT INTO [{locales_source}] ([location], [source], [textgroup], [version]) VALUES (%s, %s, 'default', %s)", request_uri(), $string, VERSION); $locale_t[$langcode][$string] = TRUE; // Clear locale cache so this string can be added in a later request. cache_clear_all('locale:', 'cache', TRUE); Index: modules/menu/menu.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.admin.inc,v retrieving revision 1.33 diff -u -p -r1.33 menu.admin.inc --- modules/menu/menu.admin.inc 18 Sep 2008 10:44:19 -0000 1.33 +++ modules/menu/menu.admin.inc 28 Sep 2008 16:44:07 -0000 @@ -10,7 +10,7 @@ * Menu callback which shows an overview page of all the custom menus and their descriptions. */ function menu_overview_page() { - $result = db_query("SELECT * FROM {menu_custom} ORDER BY title"); + $result = db_query("SELECT * FROM [{menu_custom}] ORDER BY [title]"); $content = array(); while ($menu = db_fetch_array($result)) { $menu['href'] = 'admin/build/menu-customize/' . $menu['menu_name']; @@ -29,10 +29,10 @@ function menu_overview_page() { function menu_overview_form(&$form_state, $menu) { global $menu_admin; $sql = " - SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.* - FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path - WHERE ml.menu_name = '%s' - ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC"; + SELECT m.[load_functions], m.[to_arg_functions], m.[access_callback], m.[access_arguments], m.[page_callback], m.[page_arguments], m.[title], m.[title_callback], m.[title_arguments], m.[type], m.[description], ml.* + FROM [{menu_links}] ml LEFT JOIN [{menu_router}] m ON m.[path] = ml.[router_path] + WHERE ml.[menu_name] = %s + ORDER BY [p1] ASC, [p2] ASC, [p3] ASC, [p4] ASC, [p5] ASC, [p6] ASC, [p7] ASC, [p8] ASC, [p9] ASC"; $result = db_query($sql, $menu['menu_name']); $tree = menu_tree_data($result); $node_links = array(); @@ -452,7 +452,7 @@ function menu_delete_menu_page($menu) { function menu_delete_menu_confirm(&$form_state, $menu) { $form['#menu'] = $menu; $caption = ''; - $num_links = db_result(db_query("SELECT COUNT(*) FROM {menu_links} WHERE menu_name = '%s'", $menu['menu_name'])); + $num_links = db_result(db_query("SELECT COUNT(*) FROM [{menu_links}] WHERE [menu_name] = %s", $menu['menu_name'])); if ($num_links) { $caption .= '

    ' . format_plural($num_links, 'Warning: There is currently 1 menu item in %title. It will be deleted (system-defined items will be reset).', 'Warning: There are currently @count menu items in %title. They will be deleted (system-defined items will be reset).', array('%title' => $menu['title'])) . '

    '; } @@ -467,25 +467,25 @@ function menu_delete_menu_confirm_submit $menu = $form['#menu']; $form_state['redirect'] = 'admin/build/menu'; // System-defined menus may not be deleted - only menus defined by this module. - if (in_array($menu['menu_name'], menu_list_system_menus()) || !db_result(db_query("SELECT COUNT(*) FROM {menu_custom} WHERE menu_name = '%s'", $menu['menu_name']))) { + if (in_array($menu['menu_name'], menu_list_system_menus()) || !db_result(db_query("SELECT COUNT(*) FROM [{menu_custom}] WHERE [menu_name] = %s", $menu['menu_name']))) { return; } // Reset all the menu links defined by the system via hook_menu. - $result = db_query("SELECT * FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path WHERE ml.menu_name = '%s' AND ml.module = 'system' ORDER BY m.number_parts ASC", $menu['menu_name']); + $result = db_query("SELECT * FROM [{menu_links}] ml INNER JOIN [{menu_router}] m ON ml.[router_path] = m.[path] WHERE ml.[menu_name] = %s AND ml.[module] = 'system' ORDER BY m.[number_parts] ASC", $menu['menu_name']); while ($item = db_fetch_array($result)) { menu_reset_item($item); } // Delete all links to the overview page for this menu. - $result = db_query("SELECT mlid FROM {menu_links} ml WHERE ml.link_path = '%s'", 'admin/build/menu-customize/' . $menu['menu_name']); + $result = db_query("SELECT [mlid] FROM [{menu_links}] ml WHERE ml.[link_path] = %s", 'admin/build/menu-customize/' . $menu['menu_name']); while ($m = db_fetch_array($result)) { menu_link_delete($m['mlid']); } // Delete all the links in the menu and the menu from the list of custom menus. - db_query("DELETE FROM {menu_links} WHERE menu_name = '%s'", $menu['menu_name']); - db_query("DELETE FROM {menu_custom} WHERE menu_name = '%s'", $menu['menu_name']); + db_query("DELETE FROM [{menu_links}] WHERE [menu_name] = %s", $menu['menu_name']); + db_query("DELETE FROM [{menu_custom}] WHERE [menu_name] = %s", $menu['menu_name']); // Delete all the blocks for this menu. - db_query("DELETE FROM {blocks} WHERE module = 'menu' AND delta = '%s'", $menu['menu_name']); - db_query("DELETE FROM {blocks_roles} WHERE module = 'menu' AND delta = '%s'", $menu['menu_name']); + db_query("DELETE FROM [{blocks}] WHERE [module] = 'menu' AND [delta] = %s", $menu['menu_name']); + db_query("DELETE FROM [{blocks_roles}] WHERE [module] = 'menu' AND [delta] = %s", $menu['menu_name']); menu_cache_clear_all(); cache_clear_all(); $t_args = array('%title' => $menu['title']); @@ -507,8 +507,8 @@ function menu_edit_menu_validate($form, if ($form['#insert']) { // We will add 'menu-' to the menu name to help avoid name-space conflicts. $item['menu_name'] = 'menu-' . $item['menu_name']; - if (db_result(db_query("SELECT menu_name FROM {menu_custom} WHERE menu_name = '%s'", $item['menu_name'])) || - db_result(db_query_range("SELECT menu_name FROM {menu_links} WHERE menu_name = '%s'", $item['menu_name'], 0, 1))) { + if (db_result(db_query("SELECT [menu_name] FROM [{menu_custom}] WHERE [menu_name] = %s", $item['menu_name'])) || + db_result(db_query_range("SELECT [menu_name] FROM [{menu_links}] WHERE [menu_name] = %s", $item['menu_name'], 0, 1))) { form_set_error('menu_name', t('The menu already exists.')); } } @@ -527,13 +527,13 @@ function menu_edit_menu_submit($form, &$ $link['link_path'] = $path . $menu['menu_name']; $link['router_path'] = $path . '%'; $link['module'] = 'menu'; - $link['plid'] = db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", 'admin/build/menu', 'system')); + $link['plid'] = db_result(db_query("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = %s AND [module] = %s", 'admin/build/menu', 'system')); menu_link_save($link); - db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", $menu['menu_name'], $menu['title'], $menu['description']); + db_query("INSERT INTO [{menu_custom}] ([menu_name], [title], [description]) VALUES (%s, %s, %s)", $menu['menu_name'], $menu['title'], $menu['description']); } else { - db_query("UPDATE {menu_custom} SET title = '%s', description = '%s' WHERE menu_name = '%s'", $menu['title'], $menu['description'], $menu['menu_name']); - $result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", $path . $menu['menu_name']); + db_query("UPDATE [{menu_custom}] SET [title] = %s, [description] = %s WHERE [menu_name] = %s", $menu['title'], $menu['description'], $menu['menu_name']); + $result = db_query("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = %s", $path . $menu['menu_name']); while ($m = db_fetch_array($result)) { $link = menu_link_load($m['mlid']); $link['link_title'] = $menu['title']; Index: modules/menu/menu.install =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.install,v retrieving revision 1.13 diff -u -p -r1.13 menu.install --- modules/menu/menu.install 18 Sep 2008 10:44:19 -0000 1.13 +++ modules/menu/menu.install 28 Sep 2008 16:44:07 -0000 @@ -9,9 +9,9 @@ function menu_install() { drupal_install_schema('menu'); $t = get_t(); - db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'navigation', $t('Navigation'), $t('The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.')); - db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'main-menu', $t('Main menu'), $t('The Main menu is often used by themes to show the major sections of a site.')); - db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'secondary-menu', $t('Secondary menu'), $t('The Secondary menu is often used for pages like legal notices, contact details, and other navigation items that play a lesser role than the Main menu.')); + db_query("INSERT INTO [{menu_custom}] ([menu_name], [title], [description]) VALUES (%s, %s, %s)", 'navigation', $t('Navigation'), $t('The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.')); + db_query("INSERT INTO [{menu_custom}] ([menu_name], [title], [description]) VALUES (%s, %s, %s)", 'main-menu', $t('Main menu'), $t('The Main menu is often used by themes to show the major sections of a site.')); + db_query("INSERT INTO [{menu_custom}] ([menu_name], [title], [description]) VALUES (%s, %s, %s)", 'secondary-menu', $t('Secondary menu'), $t('The Secondary menu is often used for pages like legal notices, contact details, and other navigation items that play a lesser role than the Main menu.')); } /** Index: modules/menu/menu.module =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v retrieving revision 1.169 diff -u -p -r1.169 menu.module --- modules/menu/menu.module 27 Sep 2008 20:37:00 -0000 1.169 +++ modules/menu/menu.module 28 Sep 2008 16:44:07 -0000 @@ -151,15 +151,15 @@ function menu_theme() { */ function menu_enable() { menu_rebuild(); - $link = db_fetch_array(db_query("SELECT mlid AS plid, menu_name from {menu_links} WHERE link_path = 'admin/build/menu' AND module = 'system'")); + $link = db_fetch_array(db_query("SELECT [mlid] AS [plid], [menu_name] FROM [{menu_links}] WHERE [link_path] = %s AND [module] = %s", 'admin/build/menu', 'system')); $link['router_path'] = 'admin/build/menu-customize/%'; $link['module'] = 'menu'; - $result = db_query("SELECT * FROM {menu_custom}"); + $result = db_query("SELECT * FROM [{menu_custom}]"); while ($menu = db_fetch_array($result)) { $link['mlid'] = 0; $link['link_title'] = $menu['title']; $link['link_path'] = 'admin/build/menu-customize/' . $menu['menu_name']; - if (!db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND plid = %d", $link['link_path'], $link['plid']))) { + if (!db_result(db_query("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = %s AND [plid] = %d", $link['link_path'], $link['plid']))) { menu_link_save($link); } } @@ -177,7 +177,7 @@ function menu_overview_title($menu) { * Load the data for a single custom menu. */ function menu_load($menu_name) { - return db_fetch_array(db_query("SELECT * FROM {menu_custom} WHERE menu_name = '%s'", $menu_name)); + return db_fetch_array(db_query("SELECT * FROM [{menu_custom}] WHERE [menu_name] = %s", $menu_name)); } /** @@ -302,7 +302,7 @@ function menu_nodeapi(&$node, $op) { break; case 'delete': // Delete all menu module links that point to this node. - $result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path AND module = 'menu'", array(':path' => 'node/'. $node->nid)); + $result = db_query("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = :path AND [module] = 'menu'", array(':path' => 'node/'. $node->nid)); while ($m = db_fetch_array($result)) { menu_link_delete($m['mlid']); } @@ -314,13 +314,13 @@ function menu_nodeapi(&$node, $op) { $item = array(); if (isset($node->nid)) { // Give priority to the default menu - $mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name AND module = 'menu' ORDER BY mlid ASC", array( + $mlid = db_result(db_query_range("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = :path AND [menu_name] = :menu_name AND [module] = 'menu' ORDER BY [mlid] ASC", array( ':path' => 'node/'. $node->nid, ':menu_name' => $menu_name, ), 0, 1)); // Check all menus if a link does not exist in the default menu. if (!$mlid) { - $mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND module = 'menu' ORDER BY mlid ASC", array( + $mlid = db_result(db_query_range("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = :path AND [module] = 'menu' ORDER BY [mlid] ASC", array( ':path' => 'node/'. $node->nid, ), 0, 1)); } Index: modules/menu/menu.test =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.test,v retrieving revision 1.2 diff -u -p -r1.2 menu.test --- modules/menu/menu.test 30 May 2008 07:30:51 -0000 1.2 +++ modules/menu/menu.test 28 Sep 2008 16:44:07 -0000 @@ -199,7 +199,7 @@ class MenuTestCase extends DrupalWebTest $this->assertText($title, 'Menu item was added'); // Retrieve menu item. - $item = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE link_title = '%s'", $title)); + $item = db_fetch_array(db_query("SELECT * FROM [{menu_links}] WHERE [link_title] = %s", $title)); // Check the structure in the DB of the two menu items. // In general, if $n = $item['depth'] then $item['p'. $n] == $item['mlid'] and $item['p' . ($n - 1)] == $item['plid'] (unless depth == 0). @@ -374,7 +374,7 @@ class MenuTestCase extends DrupalWebTest private function getStandardMenuItem() { // Retrieve menu link id (presumably the Log out menu item, but not necessary). - $mlid = db_result(db_query("SELECT MIN(mlid) FROM {menu_links} WHERE module = 'system' AND hidden = 0 AND has_children = 0")); + $mlid = db_result(db_query("SELECT MIN([mlid]) FROM [{menu_links}] WHERE [module] = 'system' AND [hidden] = 0 AND [has_children] = 0")); $this->assertTrue($mlid > 0, 'Standard menu link id was found'); // Load menu item. // Use api function so that link is translated for rendering. Index: modules/node/content_types.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v retrieving revision 1.57 diff -u -p -r1.57 content_types.inc --- modules/node/content_types.inc 16 Jul 2008 21:59:27 -0000 1.57 +++ modules/node/content_types.inc 28 Sep 2008 16:44:07 -0000 @@ -383,7 +383,7 @@ function node_type_delete_confirm(&$form $message = t('Are you sure you want to delete the content type %type?', array('%type' => $type->name)); $caption = ''; - $num_nodes = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = '%s'", $type->type)); + $num_nodes = db_result(db_query("SELECT COUNT(*) FROM [{node}] WHERE [type] = %s", $type->type)); if ($num_nodes) { $caption .= '

    ' . format_plural($num_nodes, 'Warning: there is currently 1 %type post on your site. It may not be able to be displayed or edited correctly, once you have removed this content type.', 'Warning: there are currently @count %type posts on your site. They may not be able to be displayed or edited correctly, once you have removed this content type.', array('%type' => $type->name)) . '

    '; } Index: modules/node/node.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v retrieving revision 1.26 diff -u -p -r1.26 node.admin.inc --- modules/node/node.admin.inc 15 Sep 2008 20:48:08 -0000 1.26 +++ modules/node/node.admin.inc 28 Sep 2008 16:44:07 -0000 @@ -13,7 +13,7 @@ function node_configure() { // Only show rebuild button if there are either 0, or 2 or more, rows // in the {node_access} table, or if there are modules that // implement hook_node_grants(). - if (db_result(db_query('SELECT COUNT(*) FROM {node_access}')) != 1 || count(module_implements('node_grants')) > 0) { + if (db_result(db_query('SELECT COUNT(*) FROM [{node_access}]')) != 1 || count(module_implements('node_grants')) > 0) { $status = '

    ' . t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Possible causes for permission problems are disabling modules or configuration changes to permissions. Rebuilding will remove all privileges to posts, and replace them with permissions based on the current modules and settings.') . '

    '; $status .= '

    ' . t('Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed posts will automatically use the new permissions.') . '

    '; @@ -181,18 +181,18 @@ function node_build_filter_query() { case 'status': // Note: no exploitable hole as $key/$value have already been checked when submitted list($key, $value) = explode('-', $value, 2); - $where[] = 'n.' . $key . ' = %d'; + $where[] = 'n.[' . $key . '] = %d'; break; case 'category': $table = "tn$index"; - $where[] = "$table.tid = %d"; - $join .= "INNER JOIN {term_node} $table ON n.nid = $table.nid "; + $where[] = "$table.[tid] = %d"; + $join .= "INNER JOIN [{term_node}] $table ON n.[nid] = $table.[nid] "; break; case 'type': - $where[] = "n.type = '%s'"; + $where[] = "n.[type] = %s"; break; case 'language': - $where[] = "n.language = '%s'"; + $where[] = "n.[language] = %s"; break; } $args[] = $value; @@ -456,7 +456,7 @@ function node_admin_content($form_state) function node_admin_nodes() { // Enable language column if translation module is enabled // or if we have any node with language. - $multilanguage = (module_exists('translation') || db_result(db_query("SELECT COUNT(*) FROM {node} WHERE language != ''"))); + $multilanguage = (module_exists('translation') || db_result(db_query("SELECT COUNT(*) FROM [{node}] WHERE [language] <> %s", ''))); // Build the sortable table header. $header = array(); @@ -480,7 +480,7 @@ function node_admin_nodes() { $filter = node_build_filter_query(); $sort = tablesort_sql($header, '', 'n.changed DESC'); - $result = pager_query(db_rewrite_sql('SELECT n.*, u.name FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] . $sort), 50, 0, NULL, $filter['args']); + $result = pager_query(db_rewrite_sql('SELECT n.*, u.[name] FROM [{node}] n '. $filter['join'] .' INNER JOIN [{users}] u ON n.[uid] = u.[uid] '. $filter['where'] . $sort), 50, 0, NULL, $filter['args']); // Build the 'Update options' form. $form['options'] = array( @@ -623,7 +623,7 @@ function node_multiple_delete_confirm(&$ $form['nodes'] = array('#prefix' => '', '#tree' => TRUE); // array_filter returns only elements with TRUE values foreach ($nodes as $nid => $value) { - $title = db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $nid)); + $title = db_result(db_query('SELECT [title] FROM [{node}] WHERE [nid] = %d', $nid)); $form['nodes'][$nid] = array( '#type' => 'hidden', '#value' => $nid, Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.978 diff -u -p -r1.978 node.module --- modules/node/node.module 27 Sep 2008 19:47:43 -0000 1.978 +++ modules/node/node.module 28 Sep 2008 16:44:07 -0000 @@ -142,7 +142,7 @@ function node_theme() { * Implementation of hook_cron(). */ function node_cron() { - db_query('DELETE FROM {history} WHERE timestamp < %d', NODE_NEW_LIMIT); + db_query('DELETE FROM [{history}] WHERE [timestamp] < %d', NODE_NEW_LIMIT); } /** @@ -188,10 +188,10 @@ function node_tag_new($nid) { if ($user->uid) { if (node_last_viewed($nid)) { - db_query('UPDATE {history} SET timestamp = %d WHERE uid = %d AND nid = %d', REQUEST_TIME, $user->uid, $nid); + db_query('UPDATE [{history}] SET [timestamp] = %d WHERE [uid] = %d AND [nid] = %d', REQUEST_TIME, $user->uid, $nid); } else { - @db_query('INSERT INTO {history} (uid, nid, timestamp) VALUES (%d, %d, %d)', $user->uid, $nid, REQUEST_TIME); + @db_query('INSERT INTO [{history}] ([uid], [nid], [timestamp]) VALUES (%d, %d, %d)', $user->uid, $nid, REQUEST_TIME); } } } @@ -205,7 +205,7 @@ function node_last_viewed($nid) { static $history; if (!isset($history[$nid])) { - $history[$nid] = db_fetch_object(db_query("SELECT timestamp FROM {history} WHERE uid = %d AND nid = %d", $user->uid, $nid)); + $history[$nid] = db_fetch_object(db_query("SELECT [timestamp] FROM [{history}] WHERE [uid] = %d AND [nid] = %d", $user->uid, $nid)); } return (isset($history[$nid]->timestamp) ? $history[$nid]->timestamp : 0); @@ -507,7 +507,7 @@ function node_types_rebuild() { function node_type_save($info) { $is_existing = FALSE; $existing_type = !empty($info->old_type) ? $info->old_type : $info->type; - $is_existing = db_result(db_query("SELECT COUNT(*) FROM {node_type} WHERE type = '%s'", $existing_type)); + $is_existing = db_result(db_query("SELECT COUNT(*) FROM [{node_type}] WHERE [type] = %s", $existing_type)); if (!isset($info->help)) { $info->help = ''; } @@ -525,13 +525,13 @@ function node_type_save($info) { } if ($is_existing) { - db_query("UPDATE {node_type} SET type = '%s', name = '%s', module = '%s', has_title = %d, title_label = '%s', has_body = %d, body_label = '%s', description = '%s', help = '%s', min_word_count = %d, custom = %d, modified = %d, locked = %d WHERE type = '%s'", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $existing_type); + db_query("UPDATE [{node_type}] SET [type] = %s, [name] = %s, [module] = %s, [has_title] = %d, [title_label] = %s, [has_body] = %d, [body_label] = %s, [description] = %s, [help] = %s, [min_word_count] = %d, [custom] = %d, [modified] = %d, [locked] = %d WHERE [type] = %s", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $existing_type); module_invoke_all('node_type', 'update', $info); return SAVED_UPDATED; } else { - db_query("INSERT INTO {node_type} (type, name, module, has_title, title_label, has_body, body_label, description, help, min_word_count, custom, modified, locked, orig_type) VALUES ('%s', '%s', '%s', %d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d, '%s')", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $info->orig_type); + db_query("INSERT INTO [{node_type}] ([type], [name], [module], [has_title], [title_label], [has_body], [body_label], [description], [help], [min_word_count], [custom], [modified], [locked], [orig_type]) VALUES (%s, %s, %s, %d, %s, %d, %s, %s, %s, %d, %d, %d, %d, %s)", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $info->orig_type); module_invoke_all('node_type', 'insert', $info); return SAVED_NEW; @@ -546,7 +546,7 @@ function node_type_save($info) { */ function node_type_delete($type) { $info = node_get_types('type', $type); - db_query("DELETE FROM {node_type} WHERE type = '%s'", $type); + db_query("DELETE FROM [{node_type}] WHERE [type] = %s", $type); module_invoke_all('node_type', 'delete', $info); } @@ -562,7 +562,7 @@ function node_type_delete($type) { * The number of nodes whose node type field was modified. */ function node_type_update_nodes($old_type, $type) { - db_query("UPDATE {node} SET type = '%s' WHERE type = '%s'", $type, $old_type); + db_query("UPDATE [{node}] SET [type] = %s WHERE [type] = %s", $type, $old_type); return db_affected_rows(); } @@ -584,7 +584,7 @@ function _node_types_build() { $_node_names[$type] = $info['name']; } - $type_result = db_query(db_rewrite_sql('SELECT nt.type, nt.* FROM {node_type} nt ORDER BY nt.type ASC', 'nt', 'type')); + $type_result = db_query(db_rewrite_sql('SELECT nt.[type], nt.* FROM [{node_type}] nt ORDER BY nt.[type] ASC', 'nt', 'type')); while ($type_object = db_fetch_object($type_result)) { // Check for node types from disabled modules and mark their types for removal. // Types defined by the node module in the database (rather than by a separate @@ -746,13 +746,13 @@ function node_load($param = array(), $re return is_object($nodes[$param]) ? clone $nodes[$param] : $nodes[$param]; } } - $cond = 'n.nid = %d'; + $cond = 'n.[nid] = %d'; $arguments[] = $param; } elseif (is_array($param)) { // Turn the conditions into a query. foreach ($param as $key => $value) { - $cond[] = 'n.' . db_escape_table($key) . " = '%s'"; + $cond[] = 'n.[' . db_escape_table($key) . "] = %s"; $arguments[] = $value; } $cond = implode(' AND ', $cond); @@ -764,25 +764,25 @@ function node_load($param = array(), $re // Retrieve a field list based on the site's schema. $fields = drupal_schema_fields_sql('node', 'n'); $fields = array_merge($fields, drupal_schema_fields_sql('node_revisions', 'r')); - $fields = array_merge($fields, array('u.name', 'u.picture', 'u.data')); + $fields = array_merge($fields, array('u.[name]', 'u.[picture]', 'u.[data]')); // Remove fields not needed in the query: n.vid and r.nid are redundant, // n.title is unnecessary because the node title comes from the // node_revisions table. We'll keep r.vid, r.title, and n.nid. - $fields = array_diff($fields, array('n.vid', 'n.title', 'r.nid')); + $fields = array_diff($fields, array('n.[vid]', 'n.[title]', 'r.[nid]')); $fields = implode(', ', $fields); // Rename timestamp field for clarity. - $fields = str_replace('r.timestamp', 'r.timestamp AS revision_timestamp', $fields); + $fields = str_replace('r.[timestamp]', 'r.[timestamp] AS [revision_timestamp]', $fields); // Change name of revision uid so it doesn't conflict with n.uid. - $fields = str_replace('r.uid', 'r.uid AS revision_uid', $fields); + $fields = str_replace('r.[uid]', 'r.[uid] AS [revision_uid]', $fields); // Retrieve the node. // No db_rewrite_sql is applied so as to get complete indexing for search. if ($revision) { array_unshift($arguments, $revision); - $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE ' . $cond, $arguments)); + $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM [{node}] n INNER JOIN [{users}] u ON u.[uid] = n.[uid] INNER JOIN [{node_revisions}] r ON r.[nid] = n.[nid] AND r.[vid] = %d WHERE ' . $cond, $arguments)); } else { - $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE ' . $cond, $arguments)); + $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM [{node}] n INNER JOIN [{users}] u ON u.[uid] = n.[uid] INNER JOIN [{node_revisions}] r ON r.[vid] = n.[vid] WHERE ' . $cond, $arguments)); } if ($node && $node->nid) { @@ -959,7 +959,7 @@ function node_save(&$node) { $op = 'update'; } if ($update_node) { - db_query('UPDATE {node} SET vid = %d WHERE nid = %d', $node->vid, $node->nid); + db_query('UPDATE [{node}] SET [vid] = %d WHERE [nid] = %d', $node->vid, $node->nid); } // Call the node specific callback (if any). This can be @@ -1001,8 +1001,8 @@ function node_delete($nid) { $node = node_load($nid); if (node_access('delete', $node)) { - db_query('DELETE FROM {node} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid); + db_query('DELETE FROM [{node}] WHERE [nid] = %d', $node->nid); + db_query('DELETE FROM [{node_revisions}] WHERE [nid] = %d', $node->nid); // Call the node-specific callback (if any): node_invoke($node, 'delete'); @@ -1221,12 +1221,12 @@ function node_search($op = 'search', $ke return t('Content'); case 'reset': - db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = 'node'", REQUEST_TIME); + db_query("UPDATE [{search_dataset}] SET [reindex] = %d WHERE [type] = 'node'", REQUEST_TIME); return; case 'status': - $total = db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1')); - $remaining = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.sid IS NULL OR d.reindex <> 0")); + $total = db_result(db_query('SELECT COUNT(*) FROM [{node}] WHERE [status] = 1')); + $remaining = db_result(db_query("SELECT COUNT(*) FROM [{node}] n LEFT JOIN [{search_dataset}] d ON d.[type] = 'node' AND d.[sid] = n.[nid] WHERE n.[status] = 1 AND d.[sid] IS NULL OR d.[reindex] <> 0")); return array('remaining' => $remaining, 'total' => $total); case 'admin': @@ -1257,12 +1257,12 @@ function node_search($op = 'search', $ke // Build matching conditions list($join1, $where1) = _db_rewrite_sql(); $arguments1 = array(); - $conditions1 = 'n.status = 1'; + $conditions1 = 'n.[status] = 1'; if ($type = search_query_extract($keys, 'type')) { $types = array(); foreach (explode(',', $type) as $t) { - $types[] = "n.type = '%s'"; + $types[] = "n.[type] = %s"; $arguments1[] = $t; } $conditions1 .= ' AND (' . implode(' OR ', $types) . ')'; @@ -1272,18 +1272,18 @@ function node_search($op = 'search', $ke if ($category = search_query_extract($keys, 'category')) { $categories = array(); foreach (explode(',', $category) as $c) { - $categories[] = "tn.tid = %d"; + $categories[] = "tn.[tid] = %d"; $arguments1[] = $c; } $conditions1 .= ' AND (' . implode(' OR ', $categories) . ')'; - $join1 .= ' INNER JOIN {term_node} tn ON n.vid = tn.vid'; + $join1 .= ' INNER JOIN [{term_node}] tn ON n.[vid] = tn.[vid]'; $keys = search_query_insert($keys, 'category'); } if ($languages = search_query_extract($keys, 'language')) { $categories = array(); foreach (explode(',', $languages) as $l) { - $categories[] = "n.language = '%s'"; + $categories[] = "n.[language] = %s"; $arguments1[] = $l; } $conditions1 .= ' AND (' . implode(' OR ', $categories) . ')'; @@ -1299,17 +1299,17 @@ function node_search($op = 'search', $ke $total = 1; $arguments2 = array(); $join2 = ''; - $select2 = 'i.relevance AS score'; + $select2 = 'i.[relevance] AS [score]'; } else { $total = $rankings['total']; $arguments2 = $rankings['arguments']; $join2 = implode(' ', $rankings['join']); - $select2 = '('. implode(' + ', $rankings['score']) .') AS score'; + $select2 = '('. implode(' + ', $rankings['score']) .') AS [score]'; } // Do search. - $find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid ' . $join1, $conditions1 . (empty($where1) ? '' : ' AND ' . $where1), $arguments1, $select2, $join2, $arguments2); + $find = do_search($keys, 'node', 'INNER JOIN [{node}] n ON n.[nid] = i.[sid] ' . $join1, $conditions1 . (empty($where1) ? '' : ' AND ' . $where1), $arguments1, $select2, $join2, $arguments2); // Load results. $results = array(); @@ -1352,17 +1352,17 @@ function node_ranking() { 'relevance' => array( 'title' => t('Keyword relevance'), // Average relevance values hover around 0.15 - 'score' => 'i.relevance', + 'score' => 'i.[relevance]', ), 'sticky' => array( 'title' => t('Content is sticky at top of lists'), // The sticky flag is either 0 or 1, which is automatically normalized. - 'score' => 'n.sticky', + 'score' => 'n.[sticky]', ), 'promote' => array( 'title' => t('Content is promoted to the front page'), // The promote flag is either 0 or 1, which is automatically normalized. - 'score' => 'n.promote', + 'score' => 'n.[promote]', ), ); @@ -1371,7 +1371,7 @@ function node_ranking() { $ranking['recent'] = array( 'title' => t('Recently posted'), // Exponential decay with half-life of 6 months, starting at last indexed node - 'score' => '(POW(2, GREATEST(n.created, n.changed) - %d) * 6.43e-8)', + 'score' => '(POW(2, GREATEST(n.[created], n.[changed]) - %d) * 6.43e-8)', 'arguments' => array($node_cron_last), ); } @@ -1383,8 +1383,8 @@ function node_ranking() { */ function node_user($op, &$edit, &$user) { if ($op == 'delete') { - db_query('UPDATE {node} SET uid = 0 WHERE uid = %d', $user->uid); - db_query('UPDATE {node_revisions} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE [{node}] SET [uid] = 0 WHERE [uid] = %d', $user->uid); + db_query('UPDATE [{node_revisions}] SET [uid] = 0 WHERE [uid] = %d', $user->uid); } } @@ -1416,7 +1416,7 @@ function theme_node_search_admin($form) function node_comment_mode($nid) { static $comment_mode; if (!isset($comment_mode[$nid])) { - $comment_mode[$nid] = db_result(db_query('SELECT comment FROM {node} WHERE nid = %d', $nid)); + $comment_mode[$nid] = db_result(db_query('SELECT [comment] FROM [{node}] WHERE [nid] = %d', $nid)); } return $comment_mode[$nid]; } @@ -1452,7 +1452,7 @@ function _node_revision_access($node, $o // different revisions so there is no need for a separate database check. // Also, if you try to revert to or delete the current revision, that's // not good. - if ($is_current_revision && (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node->nid)) == 1 || $op == 'update' || $op == 'delete')) { + if ($is_current_revision && (db_result(db_query('SELECT COUNT([vid]) FROM [{node_revisions}] WHERE [nid] = %d', $node->nid)) == 1 || $op == 'update' || $op == 'delete')) { $access[$node->vid] = FALSE; } elseif (user_access('administer nodes')) { @@ -1661,7 +1661,7 @@ function node_init() { } function node_last_changed($nid) { - $node = db_fetch_object(db_query('SELECT changed FROM {node} WHERE nid = %d', $nid)); + $node = db_fetch_object(db_query('SELECT [changed] FROM [{node}] WHERE [nid] = %d', $nid)); return ($node->changed); } @@ -1670,7 +1670,7 @@ function node_last_changed($nid) { */ function node_revision_list($node) { $revisions = array(); - $result = db_query('SELECT r.vid, r.title, r.log, r.uid, n.vid AS current_vid, r.timestamp, u.name FROM {node_revisions} r LEFT JOIN {node} n ON n.vid = r.vid INNER JOIN {users} u ON u.uid = r.uid WHERE r.nid = %d ORDER BY r.timestamp DESC', $node->nid); + $result = db_query('SELECT r.[vid], r.[title], r.[log], r.[uid], n.[vid] AS [current_vid], r.[timestamp], u.[name] FROM [{node_revisions}] r LEFT JOIN [{node}] n ON n.[vid] = r.[vid] INNER JOIN [{users}] u ON u.[uid] = r.[uid] WHERE r.[nid] = %d ORDER BY r.[timestamp] DESC', $node->nid); while ($revision = db_fetch_object($result)) { $revisions[$revision->vid] = $revision; } @@ -1712,7 +1712,7 @@ function node_feed($nids = FALSE, $chann if ($nids === FALSE) { $nids = array(); - $result = db_query_range(db_rewrite_sql('SELECT n.nid, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, variable_get('feed_default_items', 10)); + $result = db_query_range(db_rewrite_sql('SELECT n.[nid], n.[created] FROM [{node}] n WHERE n.[promote] = 1 AND n.[status] = 1 ORDER BY n.[created] DESC'), 0, variable_get('feed_default_items', 10)); while ($row = db_fetch_object($result)) { $nids[] = $row->nid; } @@ -1793,7 +1793,7 @@ function node_feed($nids = FALSE, $chann * Menu callback; Generate a listing of promoted nodes. */ function node_page_default() { - $result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10)); + $result = pager_query(db_rewrite_sql('SELECT n.[nid], n.[sticky], n.[created] FROM [{node}] n WHERE n.[promote] = 1 AND n.[status] = 1 ORDER BY n.[sticky] DESC, n.[created] DESC'), variable_get('default_nodes_main', 10)); $output = ''; $num_rows = FALSE; @@ -1840,10 +1840,10 @@ function node_update_index() { $limit = (int)variable_get('search_cron_limit', 100); // Store the maximum possible comments per thread (used for ranking by reply count) - variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')))); - variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}')))); + variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX([comment_count]) FROM [{node_comment_statistics}]')))); + variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX([totalcount]) FROM [{node_counter}]')))); - $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit); + $result = db_query_range("SELECT n.[nid] FROM [{node}] n LEFT JOIN [{search_dataset}] d ON d.[type] = 'node' AND d.[sid] = n.[nid] WHERE d.[sid] IS NULL OR d.[reindex] <> 0 ORDER BY d.[reindex] ASC, n.[nid] ASC", 0, $limit); while ($node = db_fetch_object($result)) { _node_index_node($node); @@ -2101,7 +2101,7 @@ function node_access($op, $node, $accoun $grants = array(); foreach (node_access_grants($op, $account) as $realm => $gids) { foreach ($gids as $gid) { - $grants[] = "(gid = $gid AND realm = '$realm')"; + $grants[] = "([gid] = $gid AND [realm] = '$realm')"; } } @@ -2110,7 +2110,7 @@ function node_access($op, $node, $accoun $grants_sql = 'AND (' . implode(' OR ', $grants) . ')'; } - $sql = "SELECT COUNT(*) FROM {node_access} WHERE (nid = 0 OR nid = %d) $grants_sql AND grant_$op >= 1"; + $sql = "SELECT COUNT(*) FROM [{node_access}] WHERE ([nid] = 0 OR [nid] = %d) $grants_sql AND [grant_$op] >= 1"; $result = db_query($sql, $node->nid); return (db_result($result)); } @@ -2140,7 +2140,7 @@ function _node_access_join_sql($node_ali return ''; } - return 'INNER JOIN {node_access} ' . $node_access_alias . ' ON ' . $node_access_alias . '.nid = ' . $node_alias . '.nid'; + return 'INNER JOIN [{node_access}] ' . $node_access_alias . ' ON ' . $node_access_alias . '.[nid] = ' . $node_alias . '.[nid]'; } /** @@ -2165,7 +2165,7 @@ function _node_access_where_sql($op = 'v $grants = array(); foreach (node_access_grants($op, $account) as $realm => $gids) { foreach ($gids as $gid) { - $grants[] = "($node_access_alias.gid = $gid AND $node_access_alias.realm = '$realm')"; + $grants[] = "($node_access_alias.[gid] = $gid AND $node_access_alias.[realm] = '$realm')"; } } @@ -2174,7 +2174,7 @@ function _node_access_where_sql($op = 'v $grants_sql = 'AND (' . implode(' OR ', $grants) . ')'; } - $sql = "$node_access_alias.grant_$op >= 1 $grants_sql"; + $sql = "$node_access_alias.[grant_$op] >= 1 $grants_sql"; return $sql; } @@ -2213,7 +2213,7 @@ function node_access_view_all_nodes() { $grants = array(); foreach (node_access_grants('view') as $realm => $gids) { foreach ($gids as $gid) { - $grants[] = "(gid = $gid AND realm = '$realm')"; + $grants[] = "([gid] = $gid AND [realm] = '$realm')"; } } @@ -2222,7 +2222,7 @@ function node_access_view_all_nodes() { $grants_sql = 'AND (' . implode(' OR ', $grants) . ')'; } - $sql = "SELECT COUNT(*) FROM {node_access} WHERE nid = 0 $grants_sql AND grant_view >= 1"; + $sql = "SELECT COUNT(*) FROM [{node_access}] WHERE [nid] = 0 $grants_sql AND [grant_view] >= 1"; $result = db_query($sql); $access = db_result($result); } @@ -2342,7 +2342,7 @@ function node_access_write_grants($node, } // Only write grants; denies are implicit. if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) { - db_query("INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (%d, '%s', %d, %d, %d, %d)", $node->nid, $grant['realm'], $grant['gid'], $grant['grant_view'], $grant['grant_update'], $grant['grant_delete']); + db_query("INSERT INTO [{node_access}] ([nid], [realm], [gid], [grant_view], [grant_update], [grant_delete]) VALUES (%d, %s, %d, %d, %d, %d)", $node->nid, $grant['realm'], $grant['gid'], $grant['grant_view'], $grant['grant_update'], $grant['grant_delete']); } } } @@ -2400,7 +2400,7 @@ function node_access_needs_rebuild($rebu * hook_taxonomy, hook_node_type...) might consider using the non-batch mode. */ function node_access_rebuild($batch_mode = FALSE) { - db_query("DELETE FROM {node_access}"); + db_query("DELETE FROM [{node_access}]"); // Only recalculate if the site is using a node_access module. if (count(module_implements('node_grants'))) { if ($batch_mode) { @@ -2418,7 +2418,7 @@ function node_access_rebuild($batch_mode if (!ini_get('safe_mode')) { set_time_limit(240); } - $result = db_query("SELECT nid FROM {node}"); + $result = db_query("SELECT [nid] FROM [{node}]"); while ($node = db_fetch_object($result)) { $loaded_node = node_load($node->nid, NULL, TRUE); // To preserve database integrity, only aquire grants if the node @@ -2431,7 +2431,7 @@ function node_access_rebuild($batch_mode } else { // Not using any node_access modules. Add the default grant. - db_query("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0)"); + db_query("INSERT INTO [{node_access}] VALUES (0, 0, 'all', 1, 0, 0)"); } if (!isset($batch)) { @@ -2453,12 +2453,12 @@ function _node_access_rebuild_batch_oper // Initiate multistep processing. $context['sandbox']['progress'] = 0; $context['sandbox']['current_node'] = 0; - $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT nid) FROM {node}')); + $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT [nid]) FROM [{node}]')); } // Process the next 20 nodes. $limit = 20; - $result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit); + $result = db_query_range("SELECT [nid] FROM [{node}] WHERE [nid] > %d ORDER BY [nid] ASC", $context['sandbox']['current_node'], 0, $limit); while ($row = db_fetch_array($result)) { $loaded_node = node_load($row['nid'], NULL, TRUE); // To preserve database integrity, only aquire grants if the node @@ -2771,22 +2771,22 @@ function node_save_action($node) { */ function node_assign_owner_action(&$node, $context) { $node->uid = $context['owner_uid']; - $owner_name = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $context['owner_uid'])); + $owner_name = db_result(db_query("SELECT [name] FROM [{users}] WHERE [uid] = %d", $context['owner_uid'])); watchdog('action', 'Changed owner of @type %title to uid %name.', array('@type' => node_get_types('type', $node), '%title' => $node->title, '%name' => $owner_name)); } function node_assign_owner_action_form($context) { $description = t('The username of the user to which you would like to assign ownership.'); - $count = db_result(db_query("SELECT COUNT(*) FROM {users}")); + $count = db_result(db_query("SELECT COUNT(*) FROM [{users}]")); $owner_name = ''; if (isset($context['owner_uid'])) { - $owner_name = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $context['owner_uid'])); + $owner_name = db_result(db_query("SELECT [name] FROM [{users}] WHERE [uid] = %d", $context['owner_uid'])); } // Use dropdown for fewer than 200 users; textbox for more than that. if (intval($count) < 200) { $options = array(); - $result = db_query("SELECT uid, name FROM {users} WHERE uid > 0 ORDER BY name"); + $result = db_query("SELECT [uid], [name] FROM [{users}] WHERE [uid] > 0 ORDER BY [name]"); while ($data = db_fetch_object($result)) { $options[$data->name] = $data->name; } @@ -2813,7 +2813,7 @@ function node_assign_owner_action_form($ } function node_assign_owner_action_validate($form, $form_state) { - $count = db_result(db_query("SELECT COUNT(*) FROM {users} WHERE name = '%s'", $form_state['values']['owner_name'])); + $count = db_result(db_query("SELECT COUNT(*) FROM [{users}] WHERE [name] = %s", $form_state['values']['owner_name'])); if (intval($count) != 1) { form_set_error('owner_name', t('Please enter a valid username.')); } @@ -2821,7 +2821,7 @@ function node_assign_owner_action_valida function node_assign_owner_action_submit($form, $form_state) { // Username can change, so we need to store the ID, not the username. - $uid = db_result(db_query("SELECT uid from {users} WHERE name = '%s'", $form_state['values']['owner_name'])); + $uid = db_result(db_query("SELECT [uid] from [{users}] WHERE [name] = %s", $form_state['values']['owner_name'])); return array('owner_uid' => $uid); } Index: modules/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.39 diff -u -p -r1.39 node.pages.inc --- modules/node/node.pages.inc 27 Sep 2008 20:37:00 -0000 1.39 +++ modules/node/node.pages.inc 28 Sep 2008 16:44:07 -0000 @@ -575,12 +575,12 @@ function node_revision_delete_confirm($f function node_revision_delete_confirm_submit($form, &$form_state) { $node_revision = $form['#node_revision']; - db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $node_revision->nid, $node_revision->vid); + db_query("DELETE FROM [{node_revisions}] WHERE [nid] = %d AND [vid] = %d", $node_revision->nid, $node_revision->vid); node_invoke_nodeapi($node_revision, 'delete revision'); watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid)); drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_get_types('name', $node_revision), '%title' => $node_revision->title))); $form_state['redirect'] = 'node/' . $node_revision->nid; - if (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node_revision->nid)) > 1) { + if (db_result(db_query('SELECT COUNT([vid]) FROM [{node_revisions}] WHERE [nid] = %d', $node_revision->nid)) > 1) { $form_state['redirect'] .= '/revisions'; } } Index: modules/node/node.test =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.test,v retrieving revision 1.6 diff -u -p -r1.6 node.test --- modules/node/node.test 17 Sep 2008 05:26:51 -0000 1.6 +++ modules/node/node.test 28 Sep 2008 16:44:07 -0000 @@ -88,7 +88,7 @@ class NodeRevisionsTestCase extends Drup $this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($nodes[1]->revision_timestamp), '@type' => 'Page', '%title' => $nodes[1]->title)), t('Revision deleted.')); - $this->assertTrue(db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d and vid = %d', $node->nid, $nodes[1]->vid)) == 0, t('Revision not found.')); + $this->assertTrue(db_result(db_query('SELECT COUNT([vid]) FROM [{node_revisions}] WHERE [nid] = %d AND [vid] = %d', $node->nid, $nodes[1]->vid)) == 0, t('Revision not found.')); } } Index: modules/openid/openid.module =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.module,v retrieving revision 1.29 diff -u -p -r1.29 openid.module --- modules/openid/openid.module 17 Sep 2008 07:11:57 -0000 1.29 +++ modules/openid/openid.module 28 Sep 2008 16:44:07 -0000 @@ -333,10 +333,10 @@ function openid_association($op_endpoint module_load_include('inc', 'openid'); // Remove Old Associations: - db_query("DELETE FROM {openid_association} WHERE created + expires_in < %d", REQUEST_TIME); + db_query("DELETE FROM [{openid_association}] WHERE [created] + [expires_in] < %d", REQUEST_TIME); // Check to see if we have an association for this IdP already - $assoc_handle = db_result(db_query("SELECT assoc_handle FROM {openid_association} WHERE idp_endpoint_uri = '%s'", $op_endpoint)); + $assoc_handle = db_result(db_query("SELECT [assoc_handle] FROM [{openid_association}] WHERE [idp_endpoint_uri] = %s", $op_endpoint)); if (empty($assoc_handle)) { $mod = OPENID_DH_DEFAULT_MOD; $gen = OPENID_DH_DEFAULT_GEN; @@ -366,7 +366,7 @@ function openid_association($op_endpoint $shared = bcpowmod($spub, $private, $mod); $assoc_response['mac_key'] = base64_encode(_openid_dh_xorsecret($shared, $enc_mac_key)); } - db_query("INSERT INTO {openid_association} (idp_endpoint_uri, session_type, assoc_handle, assoc_type, expires_in, mac_key, created) VALUES('%s', '%s', '%s', '%s', %d, '%s', %d)", + db_query("INSERT INTO [{openid_association}] ([idp_endpoint_uri], [session_type], [assoc_handle], [assoc_type], [expires_in], [mac_key], [created]) VALUES(%s, %s, %s, %s, %d, %s, %d)", $op_endpoint, $assoc_response['session_type'], $assoc_response['assoc_handle'], $assoc_response['assoc_type'], $assoc_response['expires_in'], $assoc_response['mac_key'], REQUEST_TIME); $assoc_handle = $assoc_response['assoc_handle']; @@ -494,7 +494,7 @@ function openid_verify_assertion($op_end $valid = FALSE; - $association = db_fetch_object(db_query("SELECT * FROM {openid_association} WHERE assoc_handle = '%s'", $response['openid.assoc_handle'])); + $association = db_fetch_object(db_query("SELECT * FROM [{openid_association}] WHERE [assoc_handle] = %s", $response['openid.assoc_handle'])); if ($association && isset($association->session_type)) { $keys_to_sign = explode(',', $response['openid.signed']); $self_sig = _openid_signature($association, $response, $keys_to_sign); Index: modules/openid/openid.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.pages.inc,v retrieving revision 1.6 diff -u -p -r1.6 openid.pages.inc --- modules/openid/openid.pages.inc 14 Apr 2008 17:48:38 -0000 1.6 +++ modules/openid/openid.pages.inc 28 Sep 2008 16:44:07 -0000 @@ -35,14 +35,14 @@ function openid_user_identities($account $result = openid_complete(); if ($result['status'] == 'success') { $identity = $result['openid.claimed_id']; - db_query("INSERT INTO {authmap} (uid, authname, module) VALUES (%d, '%s','openid')", $account->uid, $identity); + db_query("INSERT INTO [{authmap}] ([uid], [authname], [module]) VALUES (%d, %s,'openid')", $account->uid, $identity); drupal_set_message(t('Successfully added %identity', array('%identity' => $identity))); } $header = array(t('OpenID'), t('Operations')); $rows = array(); - $result = db_query("SELECT * FROM {authmap} WHERE module='openid' AND uid=%d", $account->uid); + $result = db_query("SELECT * FROM [{authmap}] WHERE [module] = 'openid' AND [uid] = %d", $account->uid); while ($identity = db_fetch_object($result)) { $rows[] = array($identity->authname, l(t('Delete'), 'user/' . $account->uid . '/openid/delete/' . $identity->aid)); } @@ -70,7 +70,7 @@ function openid_user_add() { function openid_user_add_validate($form, &$form_state) { // Check for existing entries. $claimed_id = _openid_normalize($form_state['values']['openid_identifier']); - if (db_result(db_query("SELECT authname FROM {authmap} WHERE authname='%s'", $claimed_id))) { + if (db_result(db_query("SELECT [authname] FROM [{authmap}] WHERE [authname] = %s", $claimed_id))) { form_set_error('openid_identifier', t('That OpenID is already in use on this site.')); } else { @@ -83,7 +83,7 @@ function openid_user_add_validate($form, * Menu callback; Delete the specified OpenID identity from the system. */ function openid_user_delete($account, $aid = 0) { - db_query("DELETE FROM {authmap} WHERE uid=%d AND aid=%d AND module='openid'", $account->uid, $aid); + db_query("DELETE FROM [{authmap}] WHERE [uid] = %d AND [aid] = %d AND [module] = 'openid'", $account->uid, $aid); if (db_affected_rows()) { drupal_set_message(t('OpenID deleted.')); } Index: modules/path/path.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.admin.inc,v retrieving revision 1.10 diff -u -p -r1.10 path.admin.inc --- modules/path/path.admin.inc 21 Aug 2008 19:36:37 -0000 1.10 +++ modules/path/path.admin.inc 28 Sep 2008 16:44:07 -0000 @@ -15,17 +15,17 @@ function path_admin_overview($keys = NUL // Add the filter form above the overview table. $output = drupal_get_form('path_admin_filter_form', $keys); // Enable language column if locale is enabled or if we have any alias with language - $count = db_result(db_query("SELECT COUNT(*) FROM {url_alias} WHERE language != ''")); + $count = db_result(db_query("SELECT COUNT(*) FROM [{url_alias}] WHERE [language] <> %s", '')); $multilanguage = (module_exists('locale') || $count); if ($keys) { // Replace wildcards with PDO wildcards. $keys = preg_replace('!\*+!', '%', $keys); - $sql = "SELECT * FROM {url_alias} WHERE dst LIKE :keys"; - $args = array(':keys' => '%'. $keys .'%'); + $sql = "SELECT * FROM [{url_alias}] WHERE [dst] LIKE :keys"; + $args = array(':keys' => '%' . $keys . '%'); } else { - $sql = 'SELECT * FROM {url_alias}'; + $sql = 'SELECT * FROM [{url_alias}]'; $args = array(); } $header = array( @@ -137,7 +137,7 @@ function path_admin_form_validate($form, // Language is only set if locale module is enabled, otherwise save for all languages. $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : ''; - if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s' AND language = '%s'", $pid, $dst, $language))) { + if (db_result(db_query("SELECT COUNT([dst]) FROM [{url_alias}] WHERE [pid] <> %d AND [dst] = %s AND [language] = %s", $pid, $dst, $language))) { form_set_error('dst', t('The alias %alias is already in use in this language.', array('%alias' => $dst))); } $item = menu_get_item($src); Index: modules/path/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.146 diff -u -p -r1.146 path.module --- modules/path/path.module 27 Sep 2008 20:37:00 -0000 1.146 +++ modules/path/path.module 28 Sep 2008 16:44:07 -0000 @@ -71,7 +71,7 @@ function path_menu() { * Post-confirmation; delete an URL alias. */ function path_admin_delete($pid = 0) { - db_query('DELETE FROM {url_alias} WHERE pid = %d', $pid); + db_query('DELETE FROM [{url_alias}] WHERE [pid] = %d', $pid); drupal_set_message(t('The alias has been deleted.')); } @@ -86,11 +86,11 @@ function path_set_alias($path = NULL, $a // An existing alias. if (!$path || !$alias) { // Delete the alias based on pid. - db_query('DELETE FROM {url_alias} WHERE pid = %d', $pid); + db_query('DELETE FROM [{url_alias}] WHERE [pid] = %d', $pid); } else { // Update the existing alias. - db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE pid = %d", $path, $alias, $language, $pid); + db_query("UPDATE [{url_alias}] SET [src] = %s, [dst] = %s, [language] = %s WHERE [pid] = %d", $path, $alias, $language, $pid); } } else if ($path && $alias) { @@ -98,20 +98,20 @@ function path_set_alias($path = NULL, $a if ($alias == drupal_get_path_alias($path, $language)) { // There is already such an alias, neutral or in this language. // Update the alias based on alias; setting the language if not yet done. - db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE dst = '%s'", $path, $alias, $language, $alias); + db_query("UPDATE [{url_alias}] SET [src] = %s, [dst] = %s, [language] = %s WHERE [dst] = %s", $path, $alias, $language, $alias); } else { // A new alias. Add it to the database. - db_query("INSERT INTO {url_alias} (src, dst, language) VALUES ('%s', '%s', '%s')", $path, $alias, $language); + db_query("INSERT INTO [{url_alias}] ([src], [dst], [language]) VALUES (%s, %s, %s)", $path, $alias, $language); } } else { // Delete the alias. if ($alias) { - db_query("DELETE FROM {url_alias} WHERE dst = '%s'", $alias); + db_query("DELETE FROM [{url_alias}] WHERE [dst] = %s", $alias); } else { - db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path); + db_query("DELETE FROM [{url_alias}] WHERE [src] = %s", $path); } } drupal_clear_path_cache(); @@ -132,7 +132,7 @@ function path_nodeapi(&$node, $op, $arg) case 'validate': if (isset($node->path)) { $node->path = trim($node->path); - if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s' AND language = '%s'", $node->path, "node/$node->nid", $language))) { + if (db_result(db_query("SELECT COUNT([dst]) FROM [{url_alias}] WHERE [dst] = %s AND [src] <> %s AND [language] = %s", $node->path, "node/$node->nid", $language))) { form_set_error('path', t('The path is already in use.')); } } @@ -193,7 +193,7 @@ function path_form_alter(&$form, $form_s if ($path) { $form['path']['pid'] = array( '#type' => 'value', - '#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s' AND language = '%s'", $path, $form['#node']->language)) + '#value' => db_result(db_query("SELECT [pid] FROM [{url_alias}] WHERE [dst] = %s AND [language] = %s", $path, $form['#node']->language)) ); } } @@ -213,5 +213,5 @@ function path_perm() { * Fetch a specific URL alias from the database. */ function path_load($pid) { - return db_fetch_array(db_query('SELECT * FROM {url_alias} WHERE pid = %d', $pid)); + return db_fetch_array(db_query('SELECT * FROM [{url_alias}] WHERE [pid] = %d', $pid)); } Index: modules/path/path.test =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.test,v retrieving revision 1.3 diff -u -p -r1.3 path.test --- modules/path/path.test 21 Aug 2008 19:36:37 -0000 1.3 +++ modules/path/path.test 28 Sep 2008 16:44:07 -0000 @@ -121,7 +121,7 @@ class PathTestCase extends DrupalWebTest } function getPID($dst) { - return db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s'", $dst)); + return db_result(db_query("SELECT [pid] FROM [{url_alias}] WHERE [dst] = %s", $dst)); } function createNode() { Index: modules/php/php.install =================================================================== RCS file: /cvs/drupal/drupal/modules/php/php.install,v retrieving revision 1.2 diff -u -p -r1.2 php.install --- modules/php/php.install 14 Apr 2008 17:48:41 -0000 1.2 +++ modules/php/php.install 28 Sep 2008 16:44:07 -0000 @@ -5,17 +5,17 @@ * Implementation of hook_install(). */ function php_install() { - $format_exists = db_result(db_query("SELECT COUNT(*) FROM {filter_formats} WHERE name = 'PHP code'")); + $format_exists = db_result(db_query("SELECT COUNT(*) FROM [{filter_formats}] WHERE [name] = %s", 'PHP code')); // Add a PHP code input format, if it does not exist. Do this only for the // first install (or if the format has been manually deleted) as there is no // reliable method to identify the format in an uninstall hook or in // subsequent clean installs. if (!$format_exists) { - db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('PHP code', '', 0)"); - $format = db_result(db_query("SELECT MAX(format) FROM {filter_formats}")); + db_query("INSERT INTO [{filter_formats}] ([name], [roles], [cache]) VALUES (%s, %s, %d)", 'PHP code', '', 0); + $format = db_result(db_query("SELECT MAX([format]) FROM [{filter_formats}]")); // Enable the PHP evaluator filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, 'php', 0, 0)", $format); + db_query("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (%d, %s, %d, %d)", $format, 'php', 0, 0); drupal_set_message(t('A !php-code input format has been created.', array('!php-code' => l('PHP code', 'admin/settings/filters/' . $format)))); } Index: modules/poll/poll.module =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v retrieving revision 1.272 diff -u -p -r1.272 poll.module --- modules/poll/poll.module 17 Sep 2008 07:11:57 -0000 1.272 +++ modules/poll/poll.module 28 Sep 2008 16:44:07 -0000 @@ -139,7 +139,7 @@ function poll_block($op = 'list', $delta } else if ($op == 'view') { // Retrieve the latest poll. - $sql = db_rewrite_sql("SELECT MAX(n.created) FROM {node} n INNER JOIN {poll} p ON p.nid = n.nid WHERE n.status = 1 AND p.active = 1"); + $sql = db_rewrite_sql("SELECT MAX(n.[created]) FROM [{node}] n INNER JOIN [{poll}] p ON p.[nid] = n.[nid] WHERE n.[status] = 1 AND p.[active] = 1"); $timestamp = db_result(db_query($sql)); if ($timestamp) { $poll = node_load(array('type' => 'poll', 'created' => $timestamp, 'status' => 1)); @@ -161,9 +161,9 @@ function poll_block($op = 'list', $delta * Closes polls that have exceeded their allowed runtime. */ function poll_cron() { - $result = db_query('SELECT p.nid FROM {poll} p INNER JOIN {node} n ON p.nid = n.nid WHERE (n.created + p.runtime) < ' . REQUEST_TIME . ' AND p.active = 1 AND p.runtime != 0'); + $result = db_query('SELECT p.[nid] FROM [{poll}] p INNER JOIN [{node}] n ON p.[nid] = n.[nid] WHERE (n.[created] + p.[runtime]) < ' . REQUEST_TIME . ' AND p.[active] = 1 AND p.[runtime] <> 0'); while ($poll = db_fetch_object($result)) { - db_query("UPDATE {poll} SET active = 0 WHERE nid = %d", $poll->nid); + db_query("UPDATE [{poll}] SET [active] = 0 WHERE [nid] = %d", $poll->nid); } } @@ -443,10 +443,10 @@ function poll_validate($node) { function poll_load($node) { global $user; - $poll = db_fetch_object(db_query("SELECT runtime, active FROM {poll} WHERE nid = %d", $node->nid)); + $poll = db_fetch_object(db_query("SELECT [runtime], [active] FROM [{poll}] WHERE [nid] = %d", $node->nid)); // Load the appropriate choices into the $poll object. - $result = db_query("SELECT chid, chtext, chvotes, weight FROM {poll_choices} WHERE nid = %d ORDER BY weight", $node->nid); + $result = db_query("SELECT [chid], [chtext], [chvotes], [weight] FROM [{poll_choices}] WHERE [nid] = %d ORDER BY [weight]", $node->nid); while ($choice = db_fetch_array($result)) { $poll->choice[$choice['chid']] = $choice; } @@ -455,10 +455,10 @@ function poll_load($node) { $poll->allowvotes = FALSE; if (user_access('vote on polls') && $poll->active) { if ($user->uid) { - $result = db_fetch_object(db_query('SELECT chid FROM {poll_votes} WHERE nid = %d AND uid = %d', $node->nid, $user->uid)); + $result = db_fetch_object(db_query('SELECT [chid] FROM [{poll_votes}] WHERE [nid] = %d AND [uid] = %d', $node->nid, $user->uid)); } else { - $result = db_fetch_object(db_query("SELECT chid FROM {poll_votes} WHERE nid = %d AND hostname = '%s'", $node->nid, ip_address())); + $result = db_fetch_object(db_query("SELECT [chid] FROM [{poll_votes}] WHERE [nid] = %d AND [hostname] = %s", $node->nid, ip_address())); } if (isset($result->chid)) { $poll->vote = $result->chid; @@ -483,11 +483,11 @@ function poll_insert($node) { $node->active = 1; } - db_query("INSERT INTO {poll} (nid, runtime, active) VALUES (%d, %d, %d)", $node->nid, $node->runtime, $node->active); + db_query("INSERT INTO [{poll}] ([nid], [runtime], [active]) VALUES (%d, %d, %d)", $node->nid, $node->runtime, $node->active); foreach ($node->choice as $choice) { if ($choice['chtext'] != '') { - db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, weight) VALUES (%d, '%s', %d, %d)", $node->nid, $choice['chtext'], $choice['chvotes'], $choice['weight']); + db_query("INSERT INTO [{poll_choices}] ([nid], [chtext], [chvotes], [weight]) VALUES (%d, %s, %d, %d)", $node->nid, $choice['chtext'], $choice['chvotes'], $choice['weight']); } } } @@ -497,21 +497,21 @@ function poll_insert($node) { */ function poll_update($node) { // Update poll settings. - db_query('UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d', $node->runtime, $node->active, $node->nid); + db_query('UPDATE [{poll}] SET [runtime] = %d, [active] = %d WHERE [nid] = %d', $node->runtime, $node->active, $node->nid); // Poll choices with empty titles signifies removal. We remove all votes to // the removed options, so people who voted on them can vote again. foreach ($node->choice as $key => $choice) { if (!empty($choice['chtext'])) { if (isset($choice['chid'])) { - db_query("UPDATE {poll_choices} SET chtext = '%s', chvotes = %d, weight = %d WHERE chid = %d", $choice['chtext'], (int)$choice['chvotes'], $choice['weight'], $choice['chid']); + db_query("UPDATE [{poll_choices}] SET [chtext] = %s, [chvotes] = %d, [weight] = %d WHERE [chid] = %d", $choice['chtext'], (int)$choice['chvotes'], $choice['weight'], $choice['chid']); } else { - db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, weight) VALUES (%d, '%s', %d, %d)", $node->nid, $choice['chtext'], (int)$choice['chvotes'], $choice['weight']); + db_query("INSERT INTO [{poll_choices}] ([nid], [chtext], [chvotes], [weight]) VALUES (%d, %s, %d, %d)", $node->nid, $choice['chtext'], (int)$choice['chvotes'], $choice['weight']); } } else { - db_query("DELETE FROM {poll_votes} WHERE nid = %d AND chid = %d", $node->nid, $key); + db_query("DELETE FROM [{poll_votes}] WHERE [nid] = %d AND [chid] = %d", $node->nid, $key); } } } @@ -520,9 +520,9 @@ function poll_update($node) { * Implementation of hook_delete(). */ function poll_delete($node) { - db_query("DELETE FROM {poll} WHERE nid = %d", $node->nid); - db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid); - db_query("DELETE FROM {poll_votes} WHERE nid = %d", $node->nid); + db_query("DELETE FROM [{poll}] WHERE [nid] = %d", $node->nid); + db_query("DELETE FROM [{poll_choices}] WHERE [nid] = %d", $node->nid); + db_query("DELETE FROM [{poll_votes}] WHERE [nid] = %d", $node->nid); } /** @@ -637,14 +637,14 @@ function poll_vote($form, &$form_state) global $user; if ($user->uid) { - db_query('INSERT INTO {poll_votes} (nid, chid, uid) VALUES (%d, %d, %d)', $node->nid, $choice, $user->uid); + db_query('INSERT INTO [{poll_votes}] ([nid], [chid], [uid]) VALUES (%d, %d, %d)', $node->nid, $choice, $user->uid); } else { - db_query("INSERT INTO {poll_votes} (nid, chid, hostname) VALUES (%d, %d, '%s')", $node->nid, $choice, ip_address()); + db_query("INSERT INTO [{poll_votes}] ([nid], [chid], [hostname]) VALUES (%d, %d, %s)", $node->nid, $choice, ip_address()); } // Add one to the votes. - db_query("UPDATE {poll_choices} SET chvotes = chvotes + 1 WHERE chid = %d", $choice); + db_query("UPDATE [{poll_choices}] SET [chvotes] = [chvotes] + 1 WHERE [chid] = %d", $choice); cache_clear_all(); drupal_set_message(t('Your vote was recorded.')); @@ -812,14 +812,14 @@ function poll_cancel($form, &$form_state global $user; if ($user->uid) { - db_query('DELETE FROM {poll_votes} WHERE nid = %d and uid = %d', $node->nid, $user->uid); + db_query('DELETE FROM [{poll_votes}] WHERE [nid] = %d and [uid] = %d', $node->nid, $user->uid); } else { - db_query("DELETE FROM {poll_votes} WHERE nid = %d and hostname = '%s'", $node->nid, ip_address()); + db_query("DELETE FROM [{poll_votes}] WHERE [nid] = %d and [hostname] = %s", $node->nid, ip_address()); } // Subtract from the votes. - db_query("UPDATE {poll_choices} SET chvotes = chvotes - 1 WHERE chid = %d", $node->vote); + db_query("UPDATE [{poll_choices}] SET [chvotes] = [chvotes] - 1 WHERE [chid] = %d", $node->vote); } /** @@ -827,6 +827,6 @@ function poll_cancel($form, &$form_state */ function poll_user($op, &$edit, &$user) { if ($op == 'delete') { - db_query('UPDATE {poll_votes} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE [{poll_votes}] SET [uid] = 0 WHERE [uid] = %d', $user->uid); } } Index: modules/poll/poll.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.pages.inc,v retrieving revision 1.6 diff -u -p -r1.6 poll.pages.inc --- modules/poll/poll.pages.inc 15 May 2008 20:55:58 -0000 1.6 +++ modules/poll/poll.pages.inc 28 Sep 2008 16:44:07 -0000 @@ -11,9 +11,9 @@ */ function poll_page() { // List all polls. - $sql = db_rewrite_sql("SELECT n.nid, n.title, p.active, n.created, SUM(c.chvotes) AS votes FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid INNER JOIN {poll_choices} c ON n.nid = c.nid WHERE n.status = 1 GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC"); + $sql = db_rewrite_sql("SELECT n.[nid], n.[title], p.[active], n.[created], SUM(c.[chvotes]) AS [votes] FROM [{node}] n INNER JOIN [{poll}] p ON n.[nid] = p.[nid] INNER JOIN [{poll_choices}] c ON n.[nid] = c.[nid] WHERE n.[status] = 1 GROUP BY n.[nid], n.[title], p.[active], n.[created] ORDER BY n.[created] DESC"); // Count all polls for the pager. - $count_sql = db_rewrite_sql('SELECT COUNT(*) FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid WHERE n.status = 1'); + $count_sql = db_rewrite_sql('SELECT COUNT(*) FROM [{node}] n INNER JOIN [{poll}] p ON n.[nid] = p.[nid] WHERE n.[status] = 1'); $result = pager_query($sql, 15, 0, $count_sql); $output = '