diff -urpN drupal-6.x-dev-200708121839/includes/common.inc drupal-6.x-dev-rmnumrow-0.9/includes/common.inc --- drupal-6.x-dev-200708121839/includes/common.inc 2007-08-03 04:08:52.000000000 +0800 +++ drupal-6.x-dev-rmnumrow-0.9/includes/common.inc 2007-08-12 18:45:10.000000000 +0800 @@ -807,7 +807,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_num_rows(db_query("SELECT event FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, ip_address(), time() - 3600)); + $number = db_result(db_query("SELECT COUNT(*) FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, ip_address(), time() - 3600)); return ($number < $threshold ? TRUE : FALSE); } diff -urpN drupal-6.x-dev-200708121839/includes/database.mysqli.inc drupal-6.x-dev-rmnumrow-0.9/includes/database.mysqli.inc --- drupal-6.x-dev-200708121839/includes/database.mysqli.inc 2007-08-11 22:14:46.000000000 +0800 +++ drupal-6.x-dev-rmnumrow-0.9/includes/database.mysqli.inc 2007-08-12 18:45:10.000000000 +0800 @@ -190,20 +190,6 @@ function db_fetch_array($result) { } /** - * Determine how many result rows were found by the preceding query. - * - * @param $result - * A database query result resource, as returned from db_query(). - * @return - * The number of result rows. - */ -function db_num_rows($result) { - if ($result) { - return mysqli_num_rows($result); - } -} - -/** * Return an individual result field from the previous query. * * Only use this function if exactly one field is being selected; otherwise, @@ -294,9 +280,8 @@ function db_query_range($query) { * so that they can be properly escaped to avoid SQL injection attacks. * * Note that if you need to know how many results were returned, you should do - * a SELECT COUNT(*) on the temporary table afterwards. db_num_rows() and - * db_affected_rows() do not give consistent result across different database - * types in this case. + * a SELECT COUNT(*) on the temporary table afterwards. db_affected_rows() does + * not give consistent result across different database types in this case. * * @param $query * A string containing a normal SELECT SQL query. @@ -382,14 +367,14 @@ function db_unlock_tables() { * Check if a table exists. */ function db_table_exists($table) { - return db_num_rows(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'")); + return db_fetch_object(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'")) ? TRUE : FALSE; } /** * Check if a column exists in the given table. */ function db_column_exists($table, $column) { - return db_num_rows(db_query("SHOW COLUMNS FROM {%s} LIKE '%s'", $table, $column)); + return db_fetch_object(db_query("SHOW COLUMNS FROM {%s} LIKE '%s'", $table, $column)) ? TRUE : FALSE; } /** diff -urpN drupal-6.x-dev-200708121839/includes/database.mysql.inc drupal-6.x-dev-rmnumrow-0.9/includes/database.mysql.inc --- drupal-6.x-dev-200708121839/includes/database.mysql.inc 2007-08-11 22:14:46.000000000 +0800 +++ drupal-6.x-dev-rmnumrow-0.9/includes/database.mysql.inc 2007-08-12 18:45:10.000000000 +0800 @@ -191,20 +191,6 @@ function db_fetch_array($result) { } /** - * Determine how many result rows were found by the preceding query. - * - * @param $result - * A database query result resource, as returned from db_query(). - * @return - * The number of result rows. - */ -function db_num_rows($result) { - if ($result) { - return mysql_num_rows($result); - } -} - -/** * Return an individual result field from the previous query. * * Only use this function if exactly one field is being selected; otherwise, @@ -295,9 +281,8 @@ function db_query_range($query) { * so that they can be properly escaped to avoid SQL injection attacks. * * Note that if you need to know how many results were returned, you should do - * a SELECT COUNT(*) on the temporary table afterwards. db_num_rows() and - * db_affected_rows() do not give consistent result across different database - * types in this case. + * a SELECT COUNT(*) on the temporary table afterwards. db_affected_rows() does + * not give consistent result across different database types in this case. * * @param $query * A string containing a normal SELECT SQL query. @@ -383,14 +368,14 @@ function db_unlock_tables() { * Check if a table exists. */ function db_table_exists($table) { - return db_num_rows(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'")); + return db_fetch_object(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'")) ? TRUE : FALSE; } /** * Check if a column exists in the given table. */ function db_column_exists($table, $column) { - return db_num_rows(db_query("SHOW COLUMNS FROM {%s} LIKE '%s'", $table, $column)); + return db_fetch_object(db_query("SHOW COLUMNS FROM {%s} LIKE '%s'", $table, $column)) ? TRUE : FALSE; } /** diff -urpN drupal-6.x-dev-200708121839/includes/database.pgsql.inc drupal-6.x-dev-rmnumrow-0.9/includes/database.pgsql.inc --- drupal-6.x-dev-200708121839/includes/database.pgsql.inc 2007-08-11 22:14:46.000000000 +0800 +++ drupal-6.x-dev-rmnumrow-0.9/includes/database.pgsql.inc 2007-08-12 18:45:10.000000000 +0800 @@ -208,20 +208,6 @@ function db_fetch_array($result) { } /** - * Determine how many result rows were found by the preceding query. - * - * @param $result - * A database query result resource, as returned from db_query(). - * @return - * The number of result rows. - */ -function db_num_rows($result) { - if ($result) { - return pg_num_rows($result); - } -} - -/** * Return an individual result field from the previous query. * * Only use this function if exactly one field is being selected; otherwise, @@ -323,9 +309,8 @@ function db_query_range($query) { * so that they can be properly escaped to avoid SQL injection attacks. * * Note that if you need to know how many results were returned, you should do - * a SELECT COUNT(*) on the temporary table afterwards. db_num_rows() and - * db_affected_rows() do not give consistent result across different database - * types in this case. + * a SELECT COUNT(*) on the temporary table afterwards. db_affected_rows() does + * not give consistent result across different database types in this case. * * @param $query * A string containing a normal SELECT SQL query. @@ -414,7 +399,7 @@ function db_unlock_tables() { * Check if a table exists. */ function db_table_exists($table) { - return db_num_rows(db_query("SELECT relname FROM pg_class WHERE relname = '{". db_escape_table($table) ."}'")); + return db_result(db_query("SELECT COUNT(*) FROM pg_class WHERE relname = '{". db_escape_table($table) ."}'")); } /** diff -urpN drupal-6.x-dev-200708121839/includes/locale.inc drupal-6.x-dev-rmnumrow-0.9/includes/locale.inc --- drupal-6.x-dev-200708121839/includes/locale.inc 2007-08-09 18:12:14.000000000 +0800 +++ drupal-6.x-dev-rmnumrow-0.9/includes/locale.inc 2007-08-12 18:45:10.000000000 +0800 @@ -282,7 +282,7 @@ function _locale_languages_common_contro function locale_languages_predefined_form_validate($form, &$form_state) { $langcode = $form_state['values']['langcode']; - if ($duplicate = db_num_rows(db_query("SELECT language 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))); } diff -urpN drupal-6.x-dev-200708121839/includes/menu.inc drupal-6.x-dev-rmnumrow-0.9/includes/menu.inc --- drupal-6.x-dev-200708121839/includes/menu.inc 2007-08-11 22:06:14.000000000 +0800 +++ drupal-6.x-dev-rmnumrow-0.9/includes/menu.inc 2007-08-12 18:52:01.000000000 +0800 @@ -720,11 +720,13 @@ function menu_tree_page_data($menu_name // 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)); + $num_rows = 0; while ($item = db_fetch_array($result)) { $args[] = $item['mlid']; + $num_rows++; } $placeholders = implode(', ', array_fill(0, count($args), '%d')); - } while (db_num_rows($result)); + } while ($num_rows); } array_unshift($args, $menu_name); } diff -urpN drupal-6.x-dev-200708121839/includes/session.inc drupal-6.x-dev-rmnumrow-0.9/includes/session.inc --- drupal-6.x-dev-200708121839/includes/session.inc 2007-07-23 15:29:29.000000000 +0800 +++ drupal-6.x-dev-rmnumrow-0.9/includes/session.inc 2007-08-12 19:41:48.000000000 +0800 @@ -61,9 +61,9 @@ function sess_write($key, $value) { return TRUE; } - $result = db_query("SELECT sid FROM {sessions} WHERE sid = '%s'", $key); + $num_rows = db_result(db_query("SELECT COUNT(*) FROM {sessions} WHERE sid = '%s'", $key)); - if (!db_num_rows($result)) { + if (!$num_rows) { // Only save session data when when the browser sends a cookie. This keeps // crawlers out of session table. This reduces memory and server load, // and gives more useful statistics. We can't eliminate anonymous session diff -urpN drupal-6.x-dev-200708121839/modules/aggregator/aggregator.module drupal-6.x-dev-rmnumrow-0.9/modules/aggregator/aggregator.module --- drupal-6.x-dev-200708121839/modules/aggregator/aggregator.module 2007-07-16 20:43:04.000000000 +0800 +++ drupal-6.x-dev-rmnumrow-0.9/modules/aggregator/aggregator.module 2007-08-12 18:53:15.000000000 +0800 @@ -963,11 +963,13 @@ function aggregator_parse_feed(&$data, $ $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(); + $num_rows = 0; + while ($item = db_fetch_object($result)) { + $items[] = $item->iid; + $num_rows++; + } + 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); } diff -urpN drupal-6.x-dev-200708121839/modules/block/block.admin.inc drupal-6.x-dev-rmnumrow-0.9/modules/block/block.admin.inc --- drupal-6.x-dev-200708121839/modules/block/block.admin.inc 2007-07-25 02:17:30.000000000 +0800 +++ drupal-6.x-dev-rmnumrow-0.9/modules/block/block.admin.inc 2007-08-12 18:45:10.000000000 +0800 @@ -219,7 +219,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_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_sta } 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 -urpN drupal-6.x-dev-200708121839/modules/blog/blog.module drupal-6.x-dev-rmnumrow-0.9/modules/blog/blog.module --- drupal-6.x-dev-200708121839/modules/blog/blog.module 2007-07-22 14:48:25.000000000 +0800 +++ drupal-6.x-dev-rmnumrow-0.9/modules/blog/blog.module 2007-08-12 18:45:10.000000000 +0800 @@ -192,8 +192,8 @@ function blog_block($op = 'list', $delta 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'] .= '
'. 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)) .'
'; } diff -urpN drupal-6.x-dev-200708121839/modules/node/node.module drupal-6.x-dev-rmnumrow-0.9/modules/node/node.module --- drupal-6.x-dev-200708121839/modules/node/node.module 2007-08-10 19:14:22.000000000 +0800 +++ drupal-6.x-dev-rmnumrow-0.9/modules/node/node.module 2007-08-12 19:00:48.000000000 +0800 @@ -106,19 +106,26 @@ 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 thenode_comment_statistics table so that the comment_count 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 node_comment_statistics table so that the
+ * comment_count 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();
+ $num_rows = 0;
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());
+ $num_rows++;
}
- return theme('node_list', $items, $title);
+ return $num_rows ? theme('node_list', $items, $title) : FALSE;
}
/**
@@ -377,7 +384,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 +2558,16 @@ 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 = '';
+ $num_rows = 0;
+ while ($node = db_fetch_object($result)) {
+ $output .= node_view(node_load($node->nid), 1);
+ $num_rows++;
+ }
+
+ if ($num_rows) {
$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 -urpN drupal-6.x-dev-200708121839/modules/ping/ping.module drupal-6.x-dev-rmnumrow-0.9/modules/ping/ping.module
--- drupal-6.x-dev-200708121839/modules/ping/ping.module 2007-07-01 03:46:57.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9/modules/ping/ping.module 2007-08-12 18:45:10.000000000 +0800
@@ -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 -urpN drupal-6.x-dev-200708121839/modules/statistics/statistics.module drupal-6.x-dev-rmnumrow-0.9/modules/statistics/statistics.module
--- drupal-6.x-dev-200708121839/modules/statistics/statistics.module 2007-07-04 04:10:50.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9/modules/statistics/statistics.module 2007-08-12 18:45:10.000000000 +0800
@@ -525,18 +525,18 @@ function statistics_block($op = 'list',
$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 -urpN drupal-6.x-dev-200708121839/modules/system/system.install drupal-6.x-dev-rmnumrow-0.9/modules/system/system.install
--- drupal-6.x-dev-200708121839/modules/system/system.install 2007-08-11 22:06:15.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9/modules/system/system.install 2007-08-12 19:03:47.000000000 +0800
@@ -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);
+ $num_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 ($num_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 ($num_rows < 20) {
$ret[] = update_sql('ALTER TABLE {old_revisions} DROP done');
}
else {
@@ -2168,6 +2169,7 @@ function system_update_179() {
$limit = 20;
$args = array_merge(array($_SESSION['system_update_179_uid'], $_SESSION['system_update_179_fid'], $_SESSION['system_update_179_uid']), $_SESSION['system_update_179_fields']);
$result = db_query_range("SELECT fid, uid, value FROM {profile_values} WHERE ((uid = %d AND fid > %d) OR uid > %d) AND fid IN ". $_SESSION['system_update_179_field_string'] .' ORDER BY uid ASC, fid ASC', $args, 0, $limit);
+ $num_rows = 0;
while ($field = db_fetch_object($result)) {
$_SESSION['system_update_179_uid'] = $field->uid;
$_SESSION['system_update_179_fid'] = $field->fid;
@@ -2175,11 +2177,11 @@ function system_update_179() {
if ($field->value !== FALSE) {
db_query("UPDATE {profile_values} SET value = '%s' WHERE uid = %d AND fid = %d", $field->value, $field->uid, $field->fid);
}
-
+ $num_rows++;
}
// Done?
- if (db_num_rows($result) == 0) {
+ if ($num_rows == 0) {
unset($_SESSION['system_update_179_uid']);
unset($_SESSION['system_update_179_fid']);
unset($_SESSION['system_update_179_max']);
diff -urpN drupal-6.x-dev-200708121839/modules/system/system.module drupal-6.x-dev-rmnumrow-0.9/modules/system/system.module
--- drupal-6.x-dev-200708121839/modules/system/system.module 2007-08-12 03:17:17.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9/modules/system/system.module 2007-08-12 18:45:10.000000000 +0800
@@ -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 -urpN drupal-6.x-dev-200708121839/modules/taxonomy/taxonomy.module drupal-6.x-dev-rmnumrow-0.9/modules/taxonomy/taxonomy.module
--- drupal-6.x-dev-200708121839/modules/taxonomy/taxonomy.module 2007-08-08 15:18:19.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9/modules/taxonomy/taxonomy.module 2007-08-12 19:04:43.000000000 +0800
@@ -983,10 +983,12 @@ function taxonomy_select_nodes($tids = a
*/
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);
- }
+ $num_rows = 0;
+ while ($node = db_fetch_object($result)) {
+ $output .= node_view(node_load($node->nid), 1);
+ $num_rows++;
+ }
+ if ($num_rows) {
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0);
}
else {
diff -urpN drupal-6.x-dev-200708121839/modules/translation/translation.module drupal-6.x-dev-rmnumrow-0.9/modules/translation/translation.module
--- drupal-6.x-dev-200708121839/modules/translation/translation.module 2007-07-05 16:48:58.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9/modules/translation/translation.module 2007-08-12 18:45:10.000000000 +0800
@@ -282,7 +282,7 @@ function translation_nodeapi(&$node, $op
*/
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 -urpN drupal-6.x-dev-200708121839/modules/user/user.module drupal-6.x-dev-rmnumrow-0.9/modules/user/user.module
--- drupal-6.x-dev-200708121839/modules/user/user.module 2007-08-09 18:49:26.000000000 +0800
+++ drupal-6.x-dev-rmnumrow-0.9/modules/user/user.module 2007-08-12 19:37:11.000000000 +0800
@@ -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
// 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
// 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,13 @@ 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();
+ $num_rows = 0;
+ while ($authmap = db_fetch_object($result)) {
+ $authmaps[$authmap->module] = $authmap->authname;
+ $num_rows++;
}
+ return $num_rows > 0 ? $authmaps : 0;
}
function user_set_authmaps($account, $authmaps) {
@@ -1653,7 +1653,7 @@ function _user_edit_validate($uid, &$edi
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 +1665,7 @@ function _user_edit_validate($uid, &$edi
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. Have you forgotten your password?', array('%email' => $edit['mail'], '@password' => url('user/password'))));
}
else if (drupal_is_denied('mail', $edit['mail'])) {