Make WordPress Core

Opened 17 years ago

Last modified 4 months ago

#11398 assigned enhancement

new sort method for query_posts (order by last comment date)

Reported by: erden.ozkan Owned by:
Priority: normal Milestone:
Component: Query Version: 2.9
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

I think we need sorting by latest post comment ability for query_posts. "Recent comments" plugins does this but we need this sorting in the core.

BBPress is planned as a WP plugin according latest chat logs posted by Matt. We gonna have to need this anyway.

Attachments (2)

11398.diff​ (1.0 KB ) - added by wonderboymusic 13 years ago.
11398.2.diff​ (3.2 KB ) - added by wonderboymusic 13 years ago.

Download all attachments as: .zip

Change History (17)

#1 @ryan
17 years ago

  • Milestone 2.9 → 3.0

#2 @Denis-de-Bernardy
17 years ago

  • Keywords needs-patch added; query_posts removed
  • Milestone 3.0 → Future Release

#3 @wojtek.szkutnik
16 years ago

  • Keywords gsoc added

#4 follow-up: @wonderboymusic
13 years ago

  • Keywords has-patch added; needs-patch gsoc removed
  • Milestone Future Release → 3.7

Gonna move this into 3.7 for review. It's actually a pretty easy patch. 11398.diff​ adds comment_date as an allowed key for orderby:

$posts = get_posts( array( 'fields' => 'ids', 'orderby' => 'comment_date' ) );

The big issue is that it requires a JOIN of posts and comments which won't work if the tables are partitioned or something. This could be an option for the user, but maybe something that core never uses.

#5 @wonderboymusic
13 years ago

updated to LEFT JOIN, my posts_per_page was wrong so I didn't notice the limit was off

#6 @greenshady
13 years ago

  • Cc justin@… added

#7 @wonderboymusic
13 years ago

  • Keywords commit added

.2.diff has Unit Tests - tests revealed the need for:

$orderby = "ISNULL($wpdb->comments.comment_date), $wpdb->comments.comment_date";

#8 in reply to: ↑ 4 @nacin
13 years ago

Replying to wonderboymusic:

The big issue is that it requires a JOIN of posts and comments which won't work if the tables are partitioned or something. This could be an option for the user, but maybe something that core never uses.

WordPress assumes that all blog-level tables are in the same dataset can be joined, including posts, terms, comments, and the associated meta tables. Users is considered a global table, so it cannot be joined with comments, posts, etc. (and is not in core).

#9 @wonderboymusic
13 years ago

hence meta_query all over the B*Press - this is unfortunate

#10 @wonderboymusic
13 years ago

Ideas via @nacin and @jjj in IRC:

  1. sort by comment date
  2. put uncommented posts on the top, on the bottom, or ignore them completely
  3. uncommented posts should instead be sorted by post_date (possible with a CASE clause)
  4. sort by "freshest" - which may mean post_modified?

#11 @helen
13 years ago

  • Keywords commit removed
  • Milestone 3.7 → Future Release

#12 @ryan
12 years ago

  • Owner ryan removed
  • Status new → assigned

#13 @chriscct7
11 years ago

  • Keywords needs-patch added; has-patch removed

This ticket was mentioned in ​PR #12344 on ​WordPress/wordpress-develop by ​@sukhendu2002.


4 months ago
#15

  • Keywords has-patch has-unit-tests added; needs-patch removed
Note: See TracTickets for help on using tickets.