r59218 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59217‎ | r59218 | r59219 >
Date:21:18, 18 November 2009
Author:werdna
Status:deferred
Tags:
Comment:
LiquidThreads: fix bug in bulk loading whereby replies would not be properly loaded if a middle-tier thread was not being loaded if its top-level thread was not being bulk-loaded. Fixes bug in which thread permalinks would be missing replies. I still would like to find out why those replies were not bulk-loaded beforehand, though.
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/Thread.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/Thread.php
@@ -475,7 +475,7 @@
476476 // Load a list of threads in bulk, including all subthreads.
477477 static function bulkLoad( $rows ) {
478478 // Preload subthreads
479 - $thread_ids = array();
 479+ $top_thread_ids = array();
480480 $all_thread_rows = $rows;
481481 $pageIds = array();
482482 $linkBatch = new LinkBatch();
@@ -488,7 +488,11 @@
489489 // Build a list of threads for which to pull replies, and page IDs to pull data for.
490490 // Also, pre-initialise the reply cache.
491491 foreach ( $rows as $row ) {
492 - $thread_ids[] = $row->thread_id;
 492+ if ( $row->thread_ancestor ) {
 493+ $top_thread_ids[] = $row->thread_ancestor;
 494+ } else {
 495+ $top_thread_ids[] = $row->thread_id;
 496+ }
493497
494498 // Grab page data while we're here.
495499 if ( $row->thread_root )
@@ -503,10 +507,10 @@
504508
505509 // Pull replies to the threads provided, and as above, pull page IDs to pull data for,
506510 // pre-initialise the reply cache, and stash the row object for later use.
507 - if ( count( $thread_ids ) ) {
 511+ if ( count( $top_thread_ids ) ) {
508512 $dbr = wfGetDB( DB_SLAVE );
509513 $res = $dbr->select( 'thread', '*',
510 - array( 'thread_ancestor' => $thread_ids,
 514+ array( 'thread_ancestor' => $top_thread_ids,
511515 'thread_type != ' . $dbr->addQuotes( Threads::TYPE_DELETED ) ),
512516 __METHOD__ );
513517

Follow-up revisions

RevisionCommit summaryAuthorDate
r59220Merge r59218werdna21:41, 18 November 2009

Status & tagging log