summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-08-12 15:55:36 +0000
committerDries Buytaert <dries@buytaert.net>2007-08-12 15:55:36 +0000
commitb134b023e11902ceae12f3ab861da1f0a2fdbdbd (patch)
treefc0f0be2b23f047dd692e615e3671318f6d60f4d /modules
parent4e6068baf2c4dcb776efbdeb16621ffbdfa42c0f (diff)
downloadbrdo-b134b023e11902ceae12f3ab861da1f0a2fdbdbd.tar.gz
brdo-b134b023e11902ceae12f3ab861da1f0a2fdbdbd.tar.bz2
- Patch #163191 by hswong3i: removed db_num_rows() for compatibility with Oracle and DB2. Also a performance improvement.
Diffstat (limited to 'modules')
-rw-r--r--modules/aggregator/aggregator.module10
-rw-r--r--modules/block/block.admin.inc4
-rw-r--r--modules/blog/blog.module4
-rw-r--r--modules/comment/comment.module24
-rw-r--r--modules/drupal/drupal.module3
-rw-r--r--modules/forum/forum.module8
-rw-r--r--modules/node/content_types.inc2
-rw-r--r--modules/node/node.module25
-rw-r--r--modules/ping/ping.module2
-rw-r--r--modules/statistics/statistics.module12
-rw-r--r--modules/system/system.install7
-rw-r--r--modules/system/system.module6
-rw-r--r--modules/taxonomy/taxonomy.module8
-rw-r--r--modules/translation/translation.module2
-rw-r--r--modules/user/user.module40
15 files changed, 80 insertions, 77 deletions
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index f6c6fb4ba..3fc060fc7 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -963,11 +963,11 @@ function aggregator_parse_feed(&$data, $feed) {
$age = time() - variable_get('aggregator_clear', 9676800);
$result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
- if (db_num_rows($result)) {
- $items = array();
- while ($item = db_fetch_object($result)) {
- $items[] = $item->iid;
- }
+ $items = array();
+ while ($item = db_fetch_object($result)) {
+ $items[] = $item->iid;
+ }
+ if ($item) {
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);
}
diff --git a/modules/block/block.admin.inc b/modules/block/block.admin.inc
index 81d4dcfe4..39b7df0fe 100644
--- a/modules/block/block.admin.inc
+++ b/modules/block/block.admin.inc
@@ -219,7 +219,7 @@ function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
function block_admin_configure_validate($form, &$form_state) {
if ($form_state['values']['module'] == 'block') {
- if (empty($form_state['values']['info']) || db_num_rows(db_query("SELECT bid 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.'));
}
}
@@ -248,7 +248,7 @@ function block_add_block_form(&$form_state) {
}
function block_add_block_form_validate($form, &$form_state) {
- if (empty($form_state['values']['info']) || db_num_rows(db_query("SELECT info 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.'));
}
}
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index c6c05e4af..8d1a08a42 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -192,8 +192,8 @@ function blog_block($op = 'list', $delta = 0) {
else if ($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);
- if (db_num_rows($result)) {
- $block['content'] = node_title_list($result);
+ if ($node_title_list = node_title_list($result)) {
+ $block['content'] = $node_title_list;
$block['content'] .= '<div class="more-link">'. l(t('more'), 'blog', array('title' => t('Read the latest blog entries.'))) .'</div>';
$block['subject'] = t('Recent blog posts');
return $block;
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index b5eccdef1..7a534a044 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -1016,12 +1016,10 @@ function comment_render($node, $cid = 0) {
// Start a form, for use with comment control.
$result = pager_query($query, $comments_per_page, 0, $query_count, $query_args);
- if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
- $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
- }
$divs = 0;
$last_depth = 0;
+ $comments = '';
drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
while ($comment = db_fetch_object($result)) {
$comment = drupal_unpack($comment);
@@ -1031,37 +1029,43 @@ function comment_render($node, $cid = 0) {
if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) {
if ($comment->depth > $last_depth) {
$divs++;
- $output .= '<div class="indented">';
+ $comments .= '<div class="indented">';
$last_depth++;
}
else {
while ($comment->depth < $last_depth) {
$divs--;
- $output .= '</div>';
+ $comments .= '</div>';
$last_depth--;
}
}
}
if ($mode == COMMENT_MODE_FLAT_COLLAPSED) {
- $output .= theme('comment_flat_collapsed', $comment, $node);
+ $comments .= theme('comment_flat_collapsed', $comment, $node);
}
else if ($mode == COMMENT_MODE_FLAT_EXPANDED) {
- $output .= theme('comment_flat_expanded', $comment, $node);
+ $comments .= theme('comment_flat_expanded', $comment, $node);
}
else if ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
- $output .= theme('comment_thread_collapsed', $comment, $node);
+ $comments .= theme('comment_thread_collapsed', $comment, $node);
}
else if ($mode == COMMENT_MODE_THREADED_EXPANDED) {
- $output .= theme('comment_thread_expanded', $comment, $node);
+ $comments .= theme('comment_thread_expanded', $comment, $node);
}
}
+
+ if ($comment && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
+ $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
+ }
+ $output .= $comments;
+
for ($i = 0; $i < $divs; $i++) {
$output .= '</div>';
}
$output .= theme('pager', NULL, $comments_per_page, 0);
- if (db_num_rows($result) && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
+ if ($comment && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) {
$output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
}
}
diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module
index 63638523d..ab0921fed 100644
--- a/modules/drupal/drupal.module
+++ b/modules/drupal/drupal.module
@@ -251,8 +251,7 @@ function drupal_client_ping($client, $system) {
if ($client['link'] && $client['name'] && $client['mail'] && $client['slogan'] && $client['mission']) {
$result = db_query("SELECT cid FROM {client} WHERE link = '%s'", $client['link']);
- if (db_num_rows($result)) {
- $record = db_fetch_object($result);
+ if ($record = db_fetch_object($result)) {
$client['cid'] = $record->cid;
// We have an existing record.
db_query("UPDATE {client} SET link = '%s', name = '%s', mail = '%s', slogan = '%s', mission = '%s', users = %d, nodes = %d, version = '%s', changed = '%s' WHERE cid = %d", $client['uid'], $client['link'], $client['name'], $client['mail'], $client['slogan'], $client['mission'], $client['users'], $client['nodes'], $client['version'], time(), $client['cid']);
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 96b5c42ab..c529682f9 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -375,18 +375,14 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) {
$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.nid = n.nid 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_0', '5'));
- if (db_num_rows($result)) {
- $content = node_title_list($result);
- }
+ $content = node_title_list($result);
break;
case 1:
$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.nid = n.nid 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_1', '5'));
- if (db_num_rows($result)) {
- $content = node_title_list($result);
- }
+ $content = node_title_list($result);
break;
}
diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc
index d4999d637..3c380add9 100644
--- a/modules/node/content_types.inc
+++ b/modules/node/content_types.inc
@@ -385,7 +385,7 @@ function node_type_delete_confirm(&$form_state, $type) {
$message = t('Are you sure you want to delete the content type %type?', array('%type' => $type->name));
$caption = '';
- $num_nodes = db_num_rows(db_query("SELECT * 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 .= '<p>'. format_plural($num_nodes, '<strong>Warning:</strong> 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.', '<strong>Warning:</strong> 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)) .'</p>';
}
diff --git a/modules/node/node.module b/modules/node/node.module
index d7fe1681a..5c2e75ba5 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -106,19 +106,24 @@ function node_cron() {
* Gather a listing of links to nodes.
*
* @param $result
- * A DB result object from a query to fetch node objects. If your query joins the <code>node_comment_statistics</code> table so that the <code>comment_count</code> field is available, a title attribute will be added to show the number of comments.
+ * A DB result object from a query to fetch node objects. If your query
+ * joins the <code>node_comment_statistics</code> table so that the
+ * <code>comment_count</code> field is available, a title attribute will
+ * be added to show the number of comments.
* @param $title
* A heading for the resulting list.
*
* @return
- * An HTML list suitable as content for a block.
+ * An HTML list suitable as content for a block, or FALSE if no result can
+ * fetch from DB result object.
*/
function node_title_list($result, $title = NULL) {
+ $items = array();
while ($node = db_fetch_object($result)) {
$items[] = l($node->title, 'node/'. $node->nid, !empty($node->comment_count) ? array('title' => format_plural($node->comment_count, '1 comment', '@count comments')) : array());
}
- return theme('node_list', $items, $title);
+ return $node ? theme('node_list', $items, $title) : FALSE;
}
/**
@@ -377,7 +382,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_num_rows(db_query("SELECT * 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 = '';
}
@@ -2551,14 +2556,14 @@ function node_revisions() {
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));
- if (db_num_rows($result)) {
+ $output = '';
+ while ($node = db_fetch_object($result)) {
+ $output .= node_view(node_load($node->nid), 1);
+ }
+
+ if ($node) {
$feed_url = url('rss.xml', array('absolute' => TRUE));
drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS'));
-
- $output = '';
- while ($node = db_fetch_object($result)) {
- $output .= node_view(node_load($node->nid), 1);
- }
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
}
else {
diff --git a/modules/ping/ping.module b/modules/ping/ping.module
index cbb21fbe2..5993f719c 100644
--- a/modules/ping/ping.module
+++ b/modules/ping/ping.module
@@ -28,7 +28,7 @@ function ping_cron() {
global $base_url;
if (variable_get('site_name', 0)) {
- if (db_num_rows(db_query("SELECT nid FROM {node} WHERE status = 1 AND (created > '". variable_get('cron_last', time()) ."' OR changed > '". variable_get('cron_last', time()) ."')"))) {
+ if (db_result(db_query("SELECT COUNT(*) FROM {node} WHERE status = 1 AND (created > '". variable_get('cron_last', time()) ."' OR changed > '". variable_get('cron_last', time()) ."')"))) {
_ping_notify(variable_get('site_name', ''), $base_url);
}
}
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 759f7dccd..e84901285 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -525,18 +525,18 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) {
$content = array();
$daytop = variable_get('statistics_block_top_day_num', 0);
- if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && db_num_rows($result)) {
- $content[] = node_title_list($result, t("Today's:"));
+ if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && ($node_title_list = node_title_list($result, t("Today's:")))) {
+ $content[] = $node_title_list;
}
$alltimetop = variable_get('statistics_block_top_all_num', 0);
- if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && db_num_rows($result)) {
- $content[] = node_title_list($result, t('All time:'));
+ if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && ($node_title_list = node_title_list($result, t('All time:')))) {
+ $content[] = $node_title_list;
}
$lasttop = variable_get('statistics_block_top_last_num', 0);
- if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && db_num_rows($result)) {
- $content[] = node_title_list($result, t('Last viewed:'));
+ if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && ($node_title_list = node_title_list($result, t('Last viewed:')))) {
+ $content[] = $node_title_list;
}
if (count($content)) {
diff --git a/modules/system/system.install b/modules/system/system.install
index 37f67941c..a1ab612d2 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -1428,8 +1428,9 @@ function system_update_159() {
$ret = array();
$result = db_query_range("SELECT * FROM {old_revisions} WHERE done = 0 AND type IN ('page', 'story', 'poll', 'book', 'forum', 'blog') ORDER BY nid DESC", 0, 20);
+ $result_rows = db_result(db_query_range("SELECT COUNT(*) FROM {old_revisions} WHERE done = 0 AND type IN ('page', 'story', 'poll', 'book', 'forum', 'blog') ORDER BY nid DESC", 0, 20));
- if (db_num_rows($result)) {
+ if ($result_rows) {
$vid = db_next_id('{node_revisions}_vid');
while ($node = db_fetch_object($result)) {
$revisions = unserialize($node->revisions);
@@ -1519,7 +1520,7 @@ function system_update_159() {
}
}
- if (db_num_rows($result) < 20) {
+ if ($result_rows < 20) {
$ret[] = update_sql('ALTER TABLE {old_revisions} DROP done');
}
else {
@@ -2179,7 +2180,7 @@ function system_update_179() {
}
// Done?
- if (db_num_rows($result) == 0) {
+ if (!$field) {
unset($_SESSION['system_update_179_uid']);
unset($_SESSION['system_update_179_fid']);
unset($_SESSION['system_update_179_max']);
diff --git a/modules/system/system.module b/modules/system/system.module
index 681c520d7..db2d8712f 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -463,8 +463,8 @@ function system_admin_theme_settings() {
function system_admin_theme_submit($form, &$form_state) {
// If we're changing themes, make sure the theme has its blocks initialized.
if ($form_state['values']['admin_theme'] != variable_get('admin_theme', '0')) {
- $result = db_query("SELECT status FROM {blocks} WHERE theme = '%s'", $form_state['values']['admin_theme']);
- if (!db_num_rows($result)) {
+ $result = db_result(db_query("SELECT COUNT(*) FROM {blocks} WHERE theme = '%s'", $form_state['values']['admin_theme']));
+ if (!$result) {
system_initialize_theme_blocks($form_state['values']['admin_theme']);
}
}
@@ -1266,7 +1266,7 @@ function system_default_region($theme) {
*/
function system_initialize_theme_blocks($theme) {
// Initialize theme's blocks if none already registered.
- if (!(db_num_rows(db_query("SELECT module FROM {blocks} WHERE theme = '%s'", $theme)))) {
+ if (!(db_result(db_query("SELECT COUNT(*) FROM {blocks} WHERE theme = '%s'", $theme)))) {
$default_theme = variable_get('theme_default', 'garland');
$regions = system_region_list($theme);
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $default_theme);
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 3c300fe8d..977c3e8dc 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -983,10 +983,10 @@ function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $p
*/
function taxonomy_render_nodes($result) {
$output = '';
- if (db_num_rows($result) > 0) {
- while ($node = db_fetch_object($result)) {
- $output .= node_view(node_load($node->nid), 1);
- }
+ while ($node = db_fetch_object($result)) {
+ $output .= node_view(node_load($node->nid), 1);
+ }
+ if ($node) {
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0);
}
else {
diff --git a/modules/translation/translation.module b/modules/translation/translation.module
index 4197e2763..68a30e971 100644
--- a/modules/translation/translation.module
+++ b/modules/translation/translation.module
@@ -282,7 +282,7 @@ function translation_nodeapi(&$node, $op, $teaser, $page) {
*/
function translation_remove_from_set($node) {
if (isset($node->tnid)) {
- if (db_num_rows(db_query('SELECT tnid FROM {node} WHERE tnid = %d', $node->tnid)) <= 2) {
+ if (db_result(db_query('SELECT COUNT(*) FROM {node} WHERE tnid = %d', $node->tnid)) <= 2) {
// There would only be one node left in the set: remove the set altogether.
db_query('UPDATE {node} SET tnid = 0, translate = 0 WHERE tnid = %d', $node->tnid);
}
diff --git a/modules/user/user.module b/modules/user/user.module
index b1bc3f96b..9a3e1d863 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -151,8 +151,7 @@ function user_load($array = array()) {
}
$result = db_query('SELECT * FROM {users} u WHERE '. implode(' AND ', $query), $params);
- if (db_num_rows($result)) {
- $user = db_fetch_object($result);
+ if ($user = db_fetch_object($result)) {
$user = drupal_unpack($user);
$user->roles = array();
@@ -474,8 +473,8 @@ function user_fields() {
if (!$fields) {
$result = db_query('SELECT * FROM {users} WHERE uid = 1');
- if (db_num_rows($result)) {
- $fields = array_keys(db_fetch_array($result));
+ if ($field = db_fetch_array($result)) {
+ $fields = array_keys($field);
}
else {
// Make sure we return the default fields at least
@@ -700,7 +699,16 @@ function user_block($op = 'list', $delta = 0, $edit = array()) {
// rather than u.access because it is much faster.
$anonymous_count = sess_count($interval);
$authenticated_users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval);
- $authenticated_count = db_num_rows($authenticated_users);
+ $authenticated_count = 0;
+ $max_users = variable_get('user_block_max_list_count', 10);
+ $items = array();
+ while ($account = db_fetch_object($authenticated_users)) {
+ if ($max_users > 0) {
+ $items[] = $account;
+ $max_users--;
+ }
+ $authenticated_count++;
+ }
// Format the output with proper grammar.
if ($anonymous_count == 1 && $authenticated_count == 1) {
@@ -713,12 +721,6 @@ function user_block($op = 'list', $delta = 0, $edit = array()) {
// Display a list of currently online users.
$max_users = variable_get('user_block_max_list_count', 10);
if ($authenticated_count && $max_users) {
- $items = array();
-
- while ($max_users-- && $account = db_fetch_object($authenticated_users)) {
- $items[] = $account;
- }
-
$output .= theme('user_list', $items, t('Online users'));
}
@@ -1093,15 +1095,11 @@ function user_current_to_arg($arg) {
*/
function user_get_authmaps($authname = NULL) {
$result = db_query("SELECT authname, module FROM {authmap} WHERE authname = '%s'", $authname);
- if (db_num_rows($result) > 0) {
- while ($authmap = db_fetch_object($result)) {
- $authmaps[$authmap->module] = $authmap->authname;
- }
- return $authmaps;
- }
- else {
- return 0;
+ $authmaps = array();
+ while ($authmap = db_fetch_object($result)) {
+ $authmaps[$authmap->module] = $authmap->authname;
}
+ return count($authmaps) ? $authmaps : 0;
}
function user_set_authmaps($account, $authmaps) {
@@ -1653,7 +1651,7 @@ function _user_edit_validate($uid, &$edit) {
if ($error = user_validate_name($edit['name'])) {
form_set_error('name', $error);
}
- else if (db_num_rows(db_query("SELECT uid FROM {users} WHERE uid != %d AND LOWER(name) = LOWER('%s')", $uid, $edit['name'])) > 0) {
+ else if (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE uid != %d AND LOWER(name) = LOWER('%s')", $uid, $edit['name'])) > 0) {
form_set_error('name', t('The name %name is already taken.', array('%name' => $edit['name'])));
}
else if (drupal_is_denied('user', $edit['name'])) {
@@ -1665,7 +1663,7 @@ function _user_edit_validate($uid, &$edit) {
if ($error = user_validate_mail($edit['mail'])) {
form_set_error('mail', $error);
}
- else if (db_num_rows(db_query("SELECT uid FROM {users} WHERE uid != %d AND LOWER(mail) = LOWER('%s')", $uid, $edit['mail'])) > 0) {
+ else if (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE uid != %d AND LOWER(mail) = LOWER('%s')", $uid, $edit['mail'])) > 0) {
form_set_error('mail', t('The e-mail address %email is already registered. <a href="@password">Have you forgotten your password?</a>', array('%email' => $edit['mail'], '@password' => url('user/password'))));
}
else if (drupal_is_denied('mail', $edit['mail'])) {