r25521 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25520‎ | r25521 | r25522 >
Date:07:02, 5 September 2007
Author:david
Status:old
Tags:
Comment:
oops, that was broken. undid last commit.
Modified paths:
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtModel.php
@@ -465,10 +465,6 @@
466466 $this->changeComment = $line->thread_change_comment;
467467 $this->changeUser = $line->thread_change_user;
468468 $this->changeUserText = $line->thread_change_user_text;
469 -
470 - }
471 -
472 - function initWithReplies( $children ) {
473469
474470 $this->replies = $children;
475471
@@ -480,8 +476,6 @@
481477
482478 (we could do Revision::getPrevious() we just need to know whether or not
483479 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.
486480 */
487481 $rev = Revision::newFromTitle( $this->root()->getTitle() );
488482 $this->rootRevision = $rev->getId();
@@ -861,46 +855,21 @@
862856 SQL;
863857 $res = $dbr->query($sql);
864858
 859+ $lines = array();
865860 $threads = array();
866 - $top_level_threads = array();
867861
868862 while ( $line = $dbr->fetchObject($res) ) {
869 - $new_thread = new Thread($line, null);
870 - $threads[] = $new_thread;
871 - if( $line->is_root )
872 - // thread is one of those that was directly queried for.
873 - $top_level_threads[] = $new_thread;
874 - if( strstr( $line->thread_path, '.' ) !== false ) {
875 - // thread has a parent. extract second-to-last path element.
876 - preg_match( '/([^.]+)\.[^.]+$/', $line->thread_path, $path_matches );
877 - $parent_id = $path_matches[1];
878 - if( !array_key_exists( $parent_id, self::$thread_children ) )
879 - self::$thread_children = array();
880 - self::$thread_children[$parent_id][] = $new_thread;
881 - }
 863+ $lines[] = $line;
882864 }
883865
884 - foreach( $threads as $thread ) {
885 - if( array_key_exists( $thread->id(), self::$thread_children ) ) {
886 - $thread->initWithReplies( self::$thread_children[$thread->id()] );
887 - } else {
888 - $thread->initWithReplies( array() );
 866+ foreach( $lines as $key => $l ) {
 867+ if( $l->is_root ) {
 868+// unset($lines[$key]);
 869+ $threads[] = Threads::buildThread( $lines, $l );
889870 }
890871 }
891 - return $top_level_threads;
 872+ return $threads;
892873 }
893 -
894 - /*
895 - private function splitIncrementFromSubject($subject_string) {
896 - preg_match('/^(.*) \((\d+)\)$/', $subject_string, $matches);
897 - if( count($matches) != 3 )
898 - throw new MWException( __METHOD__ . ": thread subject has no increment: " . $subject_string );
899 - else
900 - return $matches;
901 - }
902 - */
903 -
904 - static $thread_children = array();
905874
906875 private static function buildThread( $lines, $l ) {
907876 $children = array();

Status & tagging log