Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -465,10 +465,6 @@ |
466 | 466 | $this->changeComment = $line->thread_change_comment; |
467 | 467 | $this->changeUser = $line->thread_change_user; |
468 | 468 | $this->changeUserText = $line->thread_change_user_text; |
469 | | - |
470 | | - } |
471 | | - |
472 | | - function initWithReplies( $children ) { |
473 | 469 | |
474 | 470 | $this->replies = $children; |
475 | 471 | |
— | — | @@ -480,8 +476,6 @@ |
481 | 477 | |
482 | 478 | (we could do Revision::getPrevious() we just need to know whether or not |
483 | 479 | 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 | 480 | */ |
487 | 481 | $rev = Revision::newFromTitle( $this->root()->getTitle() ); |
488 | 482 | $this->rootRevision = $rev->getId(); |
— | — | @@ -861,46 +855,21 @@ |
862 | 856 | SQL; |
863 | 857 | $res = $dbr->query($sql); |
864 | 858 | |
| 859 | + $lines = array(); |
865 | 860 | $threads = array(); |
866 | | - $top_level_threads = array(); |
867 | 861 | |
868 | 862 | 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; |
882 | 864 | } |
883 | 865 | |
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 ); |
889 | 870 | } |
890 | 871 | } |
891 | | - return $top_level_threads; |
| 872 | + return $threads; |
892 | 873 | } |
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(); |
905 | 874 | |
906 | 875 | private static function buildThread( $lines, $l ) { |
907 | 876 | $children = array(); |