diff --git a/database/database.mysql b/database/database.mysql index 88126a0fb24a56573bb3f6d41745ffefb1dd6ab5..3b3f866431e9205e5bad0839bf9293a32684f5cd 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -334,7 +334,9 @@ CREATE TABLE node ( KEY status (status), KEY uid (uid), KEY node_moderate (moderate), - KEY node_promote_status (promote, status) + KEY node_promote_status (promote, status), + KEY node_created (created), + KEY node_changed (changed) ) TYPE=MyISAM; -- diff --git a/database/database.pgsql b/database/database.pgsql index 73c737a33e848bc14449ff56b41f7ee185d7d7b5..65a18c73c216af3d1339b3abe7c06c8c0a1f6c35 100644 --- a/database/database.pgsql +++ b/database/database.pgsql @@ -336,6 +336,8 @@ CREATE INDEX node_status_idx ON node(status); CREATE INDEX node_uid_idx ON node(uid); CREATE INDEX node_moderate_idx ON node (moderate); CREATE INDEX node_promote_status_idx ON node (promote, status); +CREATE INDEX node_created ON node(created); +CREATE INDEX node_changed ON node(changed); -- -- Table structure for table 'node_counter' diff --git a/database/updates.inc b/database/updates.inc index ef53af326127680349397b219896779d812014fe..1f200ed551f1f62129780d5d59a93be856ad2f5f 100644 --- a/database/updates.inc +++ b/database/updates.inc @@ -61,7 +61,8 @@ "2004-05-18" => "update_87", "2004-06-11" => "update_88", "2004-06-18" => "update_89", - "2004-06-27" => "update_90" + "2004-06-27" => "update_90", + "2004-06-30" => "update_91" ); function update_32() { @@ -1128,6 +1129,19 @@ function update_90() { return $ret; } +function update_91() { + $ret = array(); + if ($GLOBALS["db_type"] == "pgsql") { + $ret[] = update_sql("CREATE INDEX node_created ON {node} (created)"); + $ret[] = update_sql("CREATE INDEX node_changed ON {node} (changed)"); + } + else { + $ret[] = update_sql("ALTER TABLE {node} ADD INDEX node_created (created)"); + $ret[] = update_sql("ALTER TABLE {node} ADD INDEX node_changed (changed)"); + } + return $ret; +} + function update_sql($sql) { $edit = $_POST["edit"]; $result = db_query($sql); diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index d1c9580c7db46438e4710a25e48656c57da4efe8..2f3e8dbfeaa5f36fe8f6fb2703ea8ca31f2677ce 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -95,7 +95,7 @@ function page_get_cache() { global $user; $cache = NULL; - + /* * Note, we do not serve cached pages when status messages are waiting (from * a redirected form submission which was completed). diff --git a/modules/blog.module b/modules/blog.module index 12efee5e4974c98f1525df33cf4939499c0855d5..43118fa40ce3af4a0188b40144bd8e9f5131a78a 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -104,7 +104,7 @@ function blog_feed_user($uid = 0) { $account = $user; } - $result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15); + $result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.created DESC", $uid, 0, 15); $channel['title'] = $account->name ."'s blog"; $channel['link'] = url("blog/$uid", NULL, NULL, TRUE); $channel['description'] = $term->description; @@ -115,7 +115,7 @@ function blog_feed_user($uid = 0) { * Displays an RSS feed containing recent blog entries of all users. */ function blog_feed_last() { - $result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 15); + $result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC", 0, 15); $channel['title'] = variable_get('site_name', 'drupal') .' blogs'; $channel['link'] = url('blog'); $channel['description'] = $term->description; @@ -143,7 +143,7 @@ function blog_page_user($uid) { $title = t("%name's blog", array('%name' => $account->name)); $output = ''; - $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY sticky DESC, nid DESC", variable_get('default_nodes_main', 10)); + $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY sticky DESC, created DESC", variable_get('default_nodes_main', 10)); while ($node = db_fetch_object($result)) { $output .= node_view(node_load(array('nid' => $node->nid)), 1); } @@ -162,7 +162,7 @@ function blog_page_last() { $output = ''; - $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", variable_get('default_nodes_main', 10)); + $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY created DESC", variable_get('default_nodes_main', 10)); while ($node = db_fetch_object($result)) { $output .= node_view(node_load(array('nid' => $node->nid)), 1); @@ -301,7 +301,7 @@ function blog_block($op = 'list', $delta = 0) { } else { if (user_access('access content')) { - $block['content'] = node_title_list(db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10)); + $block['content'] = node_title_list(db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC", 0, 10)); $block['content'] .= '<div class="more-link">'. l(t('more'), 'blog', array('title' => t('Read the latest blog entries.'))) .'</div>'; $block['subject'] = t('Blogs'); } diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 12efee5e4974c98f1525df33cf4939499c0855d5..43118fa40ce3af4a0188b40144bd8e9f5131a78a 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -104,7 +104,7 @@ function blog_feed_user($uid = 0) { $account = $user; } - $result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15); + $result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.created DESC", $uid, 0, 15); $channel['title'] = $account->name ."'s blog"; $channel['link'] = url("blog/$uid", NULL, NULL, TRUE); $channel['description'] = $term->description; @@ -115,7 +115,7 @@ function blog_feed_user($uid = 0) { * Displays an RSS feed containing recent blog entries of all users. */ function blog_feed_last() { - $result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 15); + $result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC", 0, 15); $channel['title'] = variable_get('site_name', 'drupal') .' blogs'; $channel['link'] = url('blog'); $channel['description'] = $term->description; @@ -143,7 +143,7 @@ function blog_page_user($uid) { $title = t("%name's blog", array('%name' => $account->name)); $output = ''; - $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY sticky DESC, nid DESC", variable_get('default_nodes_main', 10)); + $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY sticky DESC, created DESC", variable_get('default_nodes_main', 10)); while ($node = db_fetch_object($result)) { $output .= node_view(node_load(array('nid' => $node->nid)), 1); } @@ -162,7 +162,7 @@ function blog_page_last() { $output = ''; - $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", variable_get('default_nodes_main', 10)); + $result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY created DESC", variable_get('default_nodes_main', 10)); while ($node = db_fetch_object($result)) { $output .= node_view(node_load(array('nid' => $node->nid)), 1); @@ -301,7 +301,7 @@ function blog_block($op = 'list', $delta = 0) { } else { if (user_access('access content')) { - $block['content'] = node_title_list(db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10)); + $block['content'] = node_title_list(db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC", 0, 10)); $block['content'] .= '<div class="more-link">'. l(t('more'), 'blog', array('title' => t('Read the latest blog entries.'))) .'</div>'; $block['subject'] = t('Blogs'); }