r25654 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25653‎ | r25654 | r25655 >
Date:04:15, 8 September 2007
Author:david
Status:old
Tags:
Comment:
Save time by being evil and loading the page table data in the same query as the thread table. Coming up next: table-scans begone!
Modified paths:
  • /branches/liquidthreads/extensions/LqtBaseView.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtModel.php
@@ -466,26 +466,16 @@
467467 $this->changeUser = $line->thread_change_user;
468468 $this->changeUserText = $line->thread_change_user_text;
469469
 470+ $root_title = Title::makeTitle( $line->page_namespace, $line->page_title );
 471+ $this->root = new Post($root_title);
 472+ $this->root->loadPageData($line);
 473+ $this->rootRevision = $this->root->mLatest;
470474 }
471475
472476 function initWithReplies( $children ) {
473477
474478 $this->replies = $children;
475479
476 - /*
477 - Root revision is ignored on live threads but will be important when
478 - when we save a historical thread, since by that time an edit will
479 - have already taken place and it will be more difficult to find
480 - the pre-edit revision number. But I hate this.
481 -
482 - (we could do Revision::getPrevious() we just need to know whether or not
483 - there was a new revision saved at save time. make it run then make it right.)
484 -
485 - TODO this is expensive and should be ripped out.
486 - */
487 - $rev = Revision::newFromTitle( $this->root()->getTitle() );
488 - $this->rootRevision = $rev->getId();
489 -
490480 $this->double = clone $this;
491481 }
492482
@@ -839,6 +829,7 @@
840830 $dbr = wfGetDB( DB_SLAVE );
841831 if ( is_array($where) ) $where = $dbr->makeList( $where, LIST_AND );
842832 if ( is_array($options) ) $options = implode(',', $options);
 833+
843834 if( is_array($extra_tables) && count($extra_tables) != 0 ) {
844835 $tables = implode(',', $extra_tables) . ', ';
845836 } else if ( is_string( $extra_tables ) ) {
@@ -857,11 +848,13 @@
858849 $root_test = str_replace( 'thread.', 'children.', $where ); // TODO fragile?
859850
860851 $sql = <<< SQL
861 -SELECT children.*, ($root_test) as is_root FROM $tables thread, thread children
862 -WHERE $where AND
863 -children.thread_path LIKE CONCAT(thread.thread_path, "%")
 852+SELECT children.*, child_page.*, ($root_test) as is_root FROM $tables thread, thread children, page child_page
 853+WHERE $where
 854+AND children.thread_path LIKE CONCAT(thread.thread_path, "%")
 855+AND child_page.page_id = children.thread_root
864856 $options
865857 SQL;
 858+ echo($sql);
866859 $res = $dbr->query($sql);
867860
868861 $threads = array();
Index: branches/liquidthreads/extensions/LqtBaseView.php
@@ -171,9 +171,9 @@
172172 $g->extendQuery('archived', 'recently-archived',
173173 array('( thread.thread_timestamp >=' . $recentstartdate->text() .
174174 ' OR rev_timestamp >= ' . $recentstartdate->text() . ')',
175 - 'page_id = thread.thread_summary_page', 'page_latest = rev_id'),
 175+ 'summary_page.page_id = thread.thread_summary_page', 'summary_page.page_latest = rev_id'),
176176 array(),
177 - array('page', 'revision'));
 177+ array('page summary_page', 'revision'));
178178 return $g;
179179 }
180180

Status & tagging log