Index: trunk/extensions/LiquidThreads/classes/Hooks.php |
— | — | @@ -206,7 +206,7 @@ |
207 | 207 | Threads::TYPE_DELETED => 'deleted' ); |
208 | 208 | // Is it a thread |
209 | 209 | if ( !empty($row->thread_id) ) { |
210 | | - $thread = new Thread( $row ); |
| 210 | + $thread = Thread::newFromRow( $row ); |
211 | 211 | $threadInfo = "\n"; |
212 | 212 | $attribs = array(); |
213 | 213 | $attribs['ThreadSubject'] = $thread->subject(); |
Index: trunk/extensions/LiquidThreads/classes/Thread.php |
— | — | @@ -396,8 +396,18 @@ |
397 | 397 | function decrementReplyCount( $val = 1 ) { |
398 | 398 | $this->incrementReplyCount( - $val ); |
399 | 399 | } |
| 400 | + |
| 401 | + static function newFromRow( $row ) { |
| 402 | + $id = $row->thread_id; |
| 403 | + |
| 404 | + if ( isset( Threads::$cache_by_id[$id] ) ) { |
| 405 | + return Threads::$cache_by_id[$id]; |
| 406 | + } |
| 407 | + |
| 408 | + return new Thread( $row ); |
| 409 | + } |
400 | 410 | |
401 | | - function __construct( $line, $unused = null ) { |
| 411 | + protected function __construct( $line, $unused = null ) { |
402 | 412 | /* SCHEMA changes must be reflected here. */ |
403 | 413 | |
404 | 414 | if ( is_null( $line ) ) { // For Thread::create(). |
— | — | @@ -550,7 +560,7 @@ |
551 | 561 | // user talk pages to a link batch, cache the relevant user id/name pair, and |
552 | 562 | // populate the reply cache. |
553 | 563 | foreach ( $all_thread_rows as $row ) { |
554 | | - $thread = new Thread( $row, null ); |
| 564 | + $thread = Thread::newFromRow( $row, null ); |
555 | 565 | |
556 | 566 | if ( isset( $articlesById[$thread->rootId] ) ) |
557 | 567 | $thread->root = $articlesById[$thread->rootId]; |
Index: trunk/extensions/LiquidThreads/api/ApiFeedLQTThreads.php |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | |
77 | 77 | private function createFeedItem( $row ) { |
78 | 78 | global $wgOut; |
79 | | - $thread = new Thread( $row ); |
| 79 | + $thread = Thread::newFromRow( $row ); |
80 | 80 | $linker = new Linker; |
81 | 81 | |
82 | 82 | $titleStr = $thread->subject(); |
Index: trunk/extensions/LiquidThreads/api/ApiQueryLQTThreads.php |
— | — | @@ -83,13 +83,18 @@ |
84 | 84 | 'thread_article_title', 'thread_summary_page', 'thread_ancestor', |
85 | 85 | 'thread_parent', 'thread_modified', 'thread_created', 'thread_type', |
86 | 86 | 'thread_editedness', 'thread_subject', 'thread_author_id', |
87 | | - 'thread_author_name' |
| 87 | + 'thread_author_name', |
88 | 88 | ); |
89 | 89 | |
90 | 90 | $this->addFields( $allFields ); |
91 | 91 | } |
92 | 92 | |
93 | 93 | $res = $this->select( __METHOD__ ); |
| 94 | + |
| 95 | + if ( $params['render'] ) { |
| 96 | + $threads = Threads::loadFromResult( $res, $this->getDB() ); |
| 97 | + } |
| 98 | + |
94 | 99 | $count = 0; |
95 | 100 | foreach ( $res as $row ) |
96 | 101 | { |
— | — | @@ -130,7 +135,7 @@ |
131 | 136 | $wgOut->clearHTML(); |
132 | 137 | |
133 | 138 | // Setup |
134 | | - $thread = new Thread( $row ); |
| 139 | + $thread = Thread::newFromRow( $row ); |
135 | 140 | $article = $thread->root(); |
136 | 141 | $title = $article->getTitle(); |
137 | 142 | $view = new LqtView( $wgOut, $article, $title, $wgUser, $wgRequest ); |