Index: trunk/extensions/LiquidThreads/LiquidThreads.php |
— | — | @@ -172,3 +172,9 @@ |
173 | 173 | |
174 | 174 | /* Whether or not to activate LiquidThreads email notifications */ |
175 | 175 | $wgLqtEnotif = true; |
| 176 | + |
| 177 | +/* Thread actions which do *not* cause threads to be "bumped" to the top */ |
| 178 | +/* Using numbers because the change type constants are defined in Thread.php, don't |
| 179 | + want to have to parse it on every page view */ |
| 180 | +$wgThreadActionsNoBump = array( 3 /* Edited summary */, 10 /* Merged from */, |
| 181 | + 12 /* Split from */ ); |
Index: trunk/extensions/LiquidThreads/classes/Hooks.php |
— | — | @@ -326,6 +326,7 @@ |
327 | 327 | $wgExtNewFields[] = array( "thread", "thread_subject", "$dir/schema-changes/store_subject-author.sql" ); |
328 | 328 | $wgExtNewFields[] = array( "thread", "thread_author_id", "$dir/schema-changes/store_subject-author.sql" ); |
329 | 329 | $wgExtNewFields[] = array( "thread", "thread_author_name", "$dir/schema-changes/store_subject-author.sql" ); |
| 330 | + $wgExtNewFields[] = array( "thread", "thread_sortkey", "$dir/schema-changes/new-sortkey.sql" ); |
330 | 331 | |
331 | 332 | $wgExtNewIndexes[] = array( 'thread', 'thread_summary_page', '(thread_summary_page)' ); |
332 | 333 | |
Index: trunk/extensions/LiquidThreads/classes/Thread.php |
— | — | @@ -25,6 +25,7 @@ |
26 | 26 | /* Timestamps: */ |
27 | 27 | protected $modified; |
28 | 28 | protected $created; |
| 29 | + protected $sortkey; |
29 | 30 | |
30 | 31 | protected $id; |
31 | 32 | protected $type; |
— | — | @@ -132,6 +133,11 @@ |
133 | 134 | function commitRevision( $change_type, $change_object = null, $reason = "" ) { |
134 | 135 | $this->dieIfHistorical(); |
135 | 136 | global $wgUser; |
| 137 | + |
| 138 | + global $wgThreadActionsNoBump; |
| 139 | + if ( !in_array( $change_type, $wgThreadActionsNoBump ) ) { |
| 140 | + $this->sortkey = wfTimestampNow(); |
| 141 | + } |
136 | 142 | |
137 | 143 | $this->modified = wfTimestampNow(); |
138 | 144 | $this->updateEditedness( $change_type ); |
— | — | @@ -212,6 +218,7 @@ |
213 | 219 | 'thread_author_name' => $this->authorName, |
214 | 220 | 'thread_summary_page' => $this->summaryId, |
215 | 221 | 'thread_editedness' => $this->editedness, |
| 222 | + 'thread_sortkey' => $this->sortkey, |
216 | 223 | ); |
217 | 224 | } |
218 | 225 | |
— | — | @@ -311,6 +318,7 @@ |
312 | 319 | if ( is_null($line) ) { // For Thread::create(). |
313 | 320 | $this->modified = wfTimestampNow(); |
314 | 321 | $this->created = wfTimestampNow(); |
| 322 | + $this->sortkey = wfTimestampNow(); |
315 | 323 | $this->editedness = Threads::EDITED_NEVER; |
316 | 324 | return; |
317 | 325 | } |
— | — | @@ -330,6 +338,7 @@ |
331 | 339 | 'thread_subject' => 'subject', |
332 | 340 | 'thread_author_id' => 'authorId', |
333 | 341 | 'thread_author_name' => 'authorName', |
| 342 | + 'thread_sortkey' => 'sortkey', |
334 | 343 | ); |
335 | 344 | |
336 | 345 | foreach( $dataLoads as $db_field => $member_field ) { |
Index: trunk/extensions/LiquidThreads/lqt.sql |
— | — | @@ -18,6 +18,9 @@ |
19 | 19 | |
20 | 20 | -- Special thread types (deleted/move trace/normal) |
21 | 21 | thread_type int(4) unsigned NOT NULL default 0, |
| 22 | + |
| 23 | + -- Sort key |
| 24 | + thread_sortkey varchar(255) NOT NULL default '', |
22 | 25 | |
23 | 26 | PRIMARY KEY thread_id (thread_id), |
24 | 27 | UNIQUE INDEX thread_root_page (thread_root), |
— | — | @@ -26,7 +29,8 @@ |
27 | 30 | INDEX thread_modified (thread_modified), |
28 | 31 | INDEX thread_created (thread_created), |
29 | 32 | INDEX thread_summary_page (thread_summary_page), |
30 | | - INDEX (thread_author_id,thread_author_name) |
| 33 | + INDEX (thread_author_id,thread_author_name), |
| 34 | + INDEX (thread_sortkey) |
31 | 35 | ) /*$wgDBTableOptions*/; |
32 | 36 | |
33 | 37 | |
Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php |
— | — | @@ -383,7 +383,7 @@ |
384 | 384 | function getIndexField() { |
385 | 385 | switch( $this->orderType ) { |
386 | 386 | case LQT_NEWEST_CHANGES: |
387 | | - return 'thread_modified'; |
| 387 | + return 'thread_sortkey'; |
388 | 388 | case LQT_OLDEST_THREADS: |
389 | 389 | case LQT_NEWEST_THREADS: |
390 | 390 | return 'thread_created'; |
Index: trunk/extensions/LiquidThreads/migrateDatabase.php |
— | — | @@ -20,6 +20,7 @@ |
21 | 21 | 'thread_subject' => 'store_subject-author.sql', |
22 | 22 | 'thread_author_id' => 'store_subject-author.sql', |
23 | 23 | 'thread_author_name' => 'store_subject-author.sql', |
| 24 | + 'thread_sortkey' => 'new-sortkey.sql', |
24 | 25 | ); |
25 | 26 | $threadIndexUpdates = array('thread_summary_page' => 'index-summary_page.sql'); |
26 | 27 | |
Index: trunk/extensions/LiquidThreads/schema-changes/new-sortkey.sql |
— | — | @@ -0,0 +1,5 @@ |
| 2 | +-- Add and populate the thread_sortkey field |
| 3 | +ALTER TABLE /*_*/thread ADD COLUMN thread_sortkey varchar(255) NOT NULL default ''; |
| 4 | +ALTER TABLE /*_*/thread ADD INDEX thread_sortkey (thread_sortkey); |
| 5 | + |
| 6 | +UPDATE /*_*/thread SET thread_sortkey=thread_modified; |