diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-08-12 16:12:00 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-08-12 16:12:00 +0000 |
commit | c17499b6fe5e9b388d09151d2c3525976fde065c (patch) | |
tree | 0203a1d7f6cbeba58fc2056ae4f6c6caa30119d0 /modules | |
parent | b134b023e11902ceae12f3ab861da1f0a2fdbdbd (diff) | |
download | brdo-c17499b6fe5e9b388d09151d2c3525976fde065c.tar.gz brdo-c17499b6fe5e9b388d09151d2c3525976fde065c.tar.bz2 |
- Patch #163191 by hswong3i: removed db_num_rows() for compatibility with Oracle and DB2. Also a performance improvement. (Correct version this time.)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/aggregator/aggregator.module | 4 | ||||
-rw-r--r-- | modules/comment/comment.module | 7 | ||||
-rw-r--r-- | modules/node/node.module | 8 | ||||
-rw-r--r-- | modules/system/system.install | 11 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 4 | ||||
-rw-r--r-- | modules/user/user.module | 4 |
6 files changed, 26 insertions, 12 deletions
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 3fc060fc7..d6cf89923 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -964,10 +964,12 @@ function aggregator_parse_feed(&$data, $feed) { $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age); $items = array(); + $num_rows = FALSE; while ($item = db_fetch_object($result)) { $items[] = $item->iid; + $num_rows = TRUE; } - if ($item) { + 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 --git a/modules/comment/comment.module b/modules/comment/comment.module index 7a534a044..82db5cae0 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1019,6 +1019,7 @@ function comment_render($node, $cid = 0) { $divs = 0; $last_depth = 0; + $num_rows = FALSE; $comments = ''; drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css'); while ($comment = db_fetch_object($result)) { @@ -1053,9 +1054,11 @@ function comment_render($node, $cid = 0) { else if ($mode == COMMENT_MODE_THREADED_EXPANDED) { $comments .= theme('comment_thread_expanded', $comment, $node); } + + $num_rows = TRUE; } - if ($comment && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) { + if ($num_rows && (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; @@ -1065,7 +1068,7 @@ function comment_render($node, $cid = 0) { } $output .= theme('pager', NULL, $comments_per_page, 0); - if ($comment && (variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_BELOW || variable_get('comment_controls', COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_ABOVE_BELOW)) { + if ($num_rows && (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/node/node.module b/modules/node/node.module index 5c2e75ba5..b7d2bcb76 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -119,11 +119,13 @@ function node_cron() { */ function node_title_list($result, $title = NULL) { $items = array(); + $num_rows = FALSE; 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 = TRUE; } - return $node ? theme('node_list', $items, $title) : FALSE; + return $num_rows ? theme('node_list', $items, $title) : FALSE; } /** @@ -2557,11 +2559,13 @@ 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)); $output = ''; + $num_rows = FALSE; while ($node = db_fetch_object($result)) { $output .= node_view(node_load($node->nid), 1); + $num_rows = TRUE; } - if ($node) { + if ($num_rows) { $feed_url = url('rss.xml', array('absolute' => TRUE)); drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS')); $output .= theme('pager', NULL, variable_get('default_nodes_main', 10)); diff --git a/modules/system/system.install b/modules/system/system.install index a1ab612d2..e0aa4d35e 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -1428,9 +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)); + $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 ($result_rows) { + if ($num_rows) { $vid = db_next_id('{node_revisions}_vid'); while ($node = db_fetch_object($result)) { $revisions = unserialize($node->revisions); @@ -1520,7 +1520,7 @@ function system_update_159() { } } - if ($result_rows < 20) { + if ($num_rows < 20) { $ret[] = update_sql('ALTER TABLE {old_revisions} DROP done'); } else { @@ -2169,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; @@ -2176,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 (!$field) { + if ($num_rows == 0) { unset($_SESSION['system_update_179_uid']); unset($_SESSION['system_update_179_fid']); unset($_SESSION['system_update_179_max']); diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 977c3e8dc..738448e97 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -983,10 +983,12 @@ function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $p */ function taxonomy_render_nodes($result) { $output = ''; + $num_rows = 0; while ($node = db_fetch_object($result)) { $output .= node_view(node_load($node->nid), 1); + $num_rows++; } - if ($node) { + if ($num_rows > 0) { $output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0); } else { diff --git a/modules/user/user.module b/modules/user/user.module index 9a3e1d863..5dbabe8aa 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1096,10 +1096,12 @@ function user_current_to_arg($arg) { function user_get_authmaps($authname = NULL) { $result = db_query("SELECT authname, module FROM {authmap} WHERE authname = '%s'", $authname); $authmaps = array(); + $num_rows = 0; while ($authmap = db_fetch_object($result)) { $authmaps[$authmap->module] = $authmap->authname; + $num_rows++; } - return count($authmaps) ? $authmaps : 0; + return $num_rows > 0 ? $authmaps : 0; } function user_set_authmaps($account, $authmaps) { |