Commit e3e051cc authored by Dries's avatar Dries
Browse files

- Patch #8585 by Junyor: sort blog items by creation date. Added some database indices.

parent 4f001824
......@@ -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;
--
......
......@@ -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'
......
......@@ -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);
......
......@@ -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).
......
......@@ -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');
}
......
......@@ -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');
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment