r22877 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22876‎ | r22877 | r22878 >
Date:23:53, 9 June 2007
Author:david
Status:old
Tags:
Comment:
Updated thread access methods to allow for joins; this is ugly, better solution sought. Corrected the recently-archived query so that it pays attention to dates of summary creation, not just thread touch dates. Thus, if a thread goes for more than 19 days without being touched, and then is summarized, it will still show up in recently-archived, because the summary is new.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -82,6 +82,7 @@
8383 function initializeQueries() {
8484 $g = new QueryGroup();
8585 $startdate = Date::now()->nDaysAgo($this->archive_start_days)->midnight();
 86+ $recentstartdate = $startdate->nDaysAgo($this->archive_recent_days);
8687 $g->addQuery('fresh',
8788 array('thread_article' => $this->article->getID(),
8889 'thread_subthread_of is null',
@@ -95,7 +96,11 @@
9697 'thread_touched < ' . $startdate->text()),
9798 array('ORDER BY' => 'thread_touched DESC'));
9899 $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'));
100105 return $g;
101106 }
102107
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -297,10 +297,10 @@
298298 return Thread::threadsWhere( array('thread_root_post' => $post->getID()) );
299299 }
300300
301 - static function threadsWhere( $where_clause, $options = array() ) {
 301+ static function threadsWhere( $where_clause, $options = array(), $extra_tables = array() ) {
302302 $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.*'),
305305 $where_clause,
306306 __METHOD__,
307307 $options);
@@ -330,15 +330,16 @@
331331 $this->queries = array();
332332 }
333333
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);
336336 }
337337
338 - function extendQuery( $original, $newname, $where, $options = array() ) {
 338+ function extendQuery( $original, $newname, $where, $options = array(), $extra_tables=array() ) {
339339 if (!array_key_exists($original,$this->queries)) return;
340340 $q = $this->queries[$original];
341341 $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) );
343344 }
344345
345346 function deleteQuery( $name ) {
@@ -347,8 +348,8 @@
348349
349350 function query($name) {
350351 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);
353354 }
354355 }
355356

Status & tagging log