Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -82,6 +82,7 @@ |
83 | 83 | function initializeQueries() { |
84 | 84 | $g = new QueryGroup(); |
85 | 85 | $startdate = Date::now()->nDaysAgo($this->archive_start_days)->midnight(); |
| 86 | + $recentstartdate = $startdate->nDaysAgo($this->archive_recent_days); |
86 | 87 | $g->addQuery('fresh', |
87 | 88 | array('thread_article' => $this->article->getID(), |
88 | 89 | 'thread_subthread_of is null', |
— | — | @@ -95,7 +96,11 @@ |
96 | 97 | 'thread_touched < ' . $startdate->text()), |
97 | 98 | array('ORDER BY' => 'thread_touched DESC')); |
98 | 99 | $g->extendQuery('archived', 'recently-archived', |
99 | | - array('thread_touched >=' . $startdate->nDaysAgo($this->archive_recent_days)->text())); |
| 100 | + array('( thread_touched >=' . $recentstartdate->text() . |
| 101 | + ' OR rev_timestamp >= ' . $recentstartdate->text() . ')', |
| 102 | + 'page_id = thread_summary_page', 'page_latest = rev_id'), |
| 103 | + array(), |
| 104 | + array('page', 'revision')); |
100 | 105 | return $g; |
101 | 106 | } |
102 | 107 | |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -297,10 +297,10 @@ |
298 | 298 | return Thread::threadsWhere( array('thread_root_post' => $post->getID()) ); |
299 | 299 | } |
300 | 300 | |
301 | | - static function threadsWhere( $where_clause, $options = array() ) { |
| 301 | + static function threadsWhere( $where_clause, $options = array(), $extra_tables = array() ) { |
302 | 302 | $dbr =& wfGetDB( DB_SLAVE ); |
303 | | - $res = $dbr->select( array('lqt_thread'), |
304 | | - array('*'), |
| 303 | + $res = $dbr->select( array_merge(array('lqt_thread'), $extra_tables), |
| 304 | + array('lqt_thread.*'), |
305 | 305 | $where_clause, |
306 | 306 | __METHOD__, |
307 | 307 | $options); |
— | — | @@ -330,15 +330,16 @@ |
331 | 331 | $this->queries = array(); |
332 | 332 | } |
333 | 333 | |
334 | | - function addQuery( $name, $where, $options = array() ) { |
335 | | - $this->queries[$name] = array($where, $options); |
| 334 | + function addQuery( $name, $where, $options = array(), $extra_tables = array() ) { |
| 335 | + $this->queries[$name] = array($where, $options, $extra_tables); |
336 | 336 | } |
337 | 337 | |
338 | | - function extendQuery( $original, $newname, $where, $options = array() ) { |
| 338 | + function extendQuery( $original, $newname, $where, $options = array(), $extra_tables=array() ) { |
339 | 339 | if (!array_key_exists($original,$this->queries)) return; |
340 | 340 | $q = $this->queries[$original]; |
341 | 341 | $this->queries[$newname] = array( array_merge($q[0], $where), |
342 | | - array_merge($q[1], $options) ); |
| 342 | + array_merge($q[1], $options), |
| 343 | + array_merge($q[2], $extra_tables) ); |
343 | 344 | } |
344 | 345 | |
345 | 346 | function deleteQuery( $name ) { |
— | — | @@ -347,8 +348,8 @@ |
348 | 349 | |
349 | 350 | function query($name) { |
350 | 351 | if ( !array_key_exists($name,$this->queries) ) return array(); |
351 | | - list($where, $options) = $this->queries[$name]; |
352 | | - return Thread::threadsWhere($where, $options); |
| 352 | + list($where, $options, $extra_tables) = $this->queries[$name]; |
| 353 | + return Thread::threadsWhere($where, $options, $extra_tables); |
353 | 354 | } |
354 | 355 | } |
355 | 356 | |