Index: trunk/extensions/LiquidThreads/classes/Thread.php |
— | — | @@ -475,7 +475,7 @@ |
476 | 476 | // Load a list of threads in bulk, including all subthreads. |
477 | 477 | static function bulkLoad( $rows ) { |
478 | 478 | // Preload subthreads |
479 | | - $thread_ids = array(); |
| 479 | + $top_thread_ids = array(); |
480 | 480 | $all_thread_rows = $rows; |
481 | 481 | $pageIds = array(); |
482 | 482 | $linkBatch = new LinkBatch(); |
— | — | @@ -488,7 +488,11 @@ |
489 | 489 | // Build a list of threads for which to pull replies, and page IDs to pull data for. |
490 | 490 | // Also, pre-initialise the reply cache. |
491 | 491 | 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 | + } |
493 | 497 | |
494 | 498 | // Grab page data while we're here. |
495 | 499 | if ( $row->thread_root ) |
— | — | @@ -503,10 +507,10 @@ |
504 | 508 | |
505 | 509 | // Pull replies to the threads provided, and as above, pull page IDs to pull data for, |
506 | 510 | // pre-initialise the reply cache, and stash the row object for later use. |
507 | | - if ( count( $thread_ids ) ) { |
| 511 | + if ( count( $top_thread_ids ) ) { |
508 | 512 | $dbr = wfGetDB( DB_SLAVE ); |
509 | 513 | $res = $dbr->select( 'thread', '*', |
510 | | - array( 'thread_ancestor' => $thread_ids, |
| 514 | + array( 'thread_ancestor' => $top_thread_ids, |
511 | 515 | 'thread_type != ' . $dbr->addQuotes( Threads::TYPE_DELETED ) ), |
512 | 516 | __METHOD__ ); |
513 | 517 | |