r56739 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56738‎ | r56739 | r56740 >
Date:22:23, 21 September 2009
Author:werdna
Status:deferred
Tags:
Comment:
LiquidThreads sort order adjustments:
* Do not bump threads to the top for some actions, split from, merge from and summarize.
* Adds a new field thread_sortkey, updated for most actions (but not all).
* Actions configurable with the global $wgThreadActionsNoBump
Modified paths:
  • /trunk/extensions/LiquidThreads/LiquidThreads.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Hooks.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/Thread.php (modified) (history)
  • /trunk/extensions/LiquidThreads/lqt.sql (modified) (history)
  • /trunk/extensions/LiquidThreads/migrateDatabase.php (modified) (history)
  • /trunk/extensions/LiquidThreads/pages/TalkpageView.php (modified) (history)
  • /trunk/extensions/LiquidThreads/schema-changes/new-sortkey.sql (added) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/LiquidThreads.php
@@ -172,3 +172,9 @@
173173
174174 /* Whether or not to activate LiquidThreads email notifications */
175175 $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 @@
327327 $wgExtNewFields[] = array( "thread", "thread_subject", "$dir/schema-changes/store_subject-author.sql" );
328328 $wgExtNewFields[] = array( "thread", "thread_author_id", "$dir/schema-changes/store_subject-author.sql" );
329329 $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" );
330331
331332 $wgExtNewIndexes[] = array( 'thread', 'thread_summary_page', '(thread_summary_page)' );
332333
Index: trunk/extensions/LiquidThreads/classes/Thread.php
@@ -25,6 +25,7 @@
2626 /* Timestamps: */
2727 protected $modified;
2828 protected $created;
 29+ protected $sortkey;
2930
3031 protected $id;
3132 protected $type;
@@ -132,6 +133,11 @@
133134 function commitRevision( $change_type, $change_object = null, $reason = "" ) {
134135 $this->dieIfHistorical();
135136 global $wgUser;
 137+
 138+ global $wgThreadActionsNoBump;
 139+ if ( !in_array( $change_type, $wgThreadActionsNoBump ) ) {
 140+ $this->sortkey = wfTimestampNow();
 141+ }
136142
137143 $this->modified = wfTimestampNow();
138144 $this->updateEditedness( $change_type );
@@ -212,6 +218,7 @@
213219 'thread_author_name' => $this->authorName,
214220 'thread_summary_page' => $this->summaryId,
215221 'thread_editedness' => $this->editedness,
 222+ 'thread_sortkey' => $this->sortkey,
216223 );
217224 }
218225
@@ -311,6 +318,7 @@
312319 if ( is_null($line) ) { // For Thread::create().
313320 $this->modified = wfTimestampNow();
314321 $this->created = wfTimestampNow();
 322+ $this->sortkey = wfTimestampNow();
315323 $this->editedness = Threads::EDITED_NEVER;
316324 return;
317325 }
@@ -330,6 +338,7 @@
331339 'thread_subject' => 'subject',
332340 'thread_author_id' => 'authorId',
333341 'thread_author_name' => 'authorName',
 342+ 'thread_sortkey' => 'sortkey',
334343 );
335344
336345 foreach( $dataLoads as $db_field => $member_field ) {
Index: trunk/extensions/LiquidThreads/lqt.sql
@@ -18,6 +18,9 @@
1919
2020 -- Special thread types (deleted/move trace/normal)
2121 thread_type int(4) unsigned NOT NULL default 0,
 22+
 23+ -- Sort key
 24+ thread_sortkey varchar(255) NOT NULL default '',
2225
2326 PRIMARY KEY thread_id (thread_id),
2427 UNIQUE INDEX thread_root_page (thread_root),
@@ -26,7 +29,8 @@
2730 INDEX thread_modified (thread_modified),
2831 INDEX thread_created (thread_created),
2932 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)
3135 ) /*$wgDBTableOptions*/;
3236
3337
Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php
@@ -383,7 +383,7 @@
384384 function getIndexField() {
385385 switch( $this->orderType ) {
386386 case LQT_NEWEST_CHANGES:
387 - return 'thread_modified';
 387+ return 'thread_sortkey';
388388 case LQT_OLDEST_THREADS:
389389 case LQT_NEWEST_THREADS:
390390 return 'thread_created';
Index: trunk/extensions/LiquidThreads/migrateDatabase.php
@@ -20,6 +20,7 @@
2121 'thread_subject' => 'store_subject-author.sql',
2222 'thread_author_id' => 'store_subject-author.sql',
2323 'thread_author_name' => 'store_subject-author.sql',
 24+ 'thread_sortkey' => 'new-sortkey.sql',
2425 );
2526 $threadIndexUpdates = array('thread_summary_page' => 'index-summary_page.sql');
2627
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;

Status & tagging log