r23093 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23092‎ | r23093 | r23094 >
Date:10:03, 19 June 2007
Author:david
Status:old
Tags:
Comment:
correct hasSuperthreads(); optimization in tree builder that I haven't yet confirmed the correctness of. Up next: support loading of related threads on demand with caching (e.g. superthread, topmostthread).
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -207,7 +207,7 @@
208208 $this->perpetuate('lqt_method', 'hidden') .
209209 $this->perpetuate('lqt_operand', 'hidden');
210210
211 - if ( /*$thread == null*/ $edit_type=='new' || ($thread && $thread->superthread() == null) ) {
 211+ if ( /*$thread == null*/ $edit_type=='new' || ($thread && !$thread->hasSuperthread()) ) {
212212 // This is a top-level post; show the subject line.
213213 $sbjtxt = $thread ? $thread->subjectWithoutIncrement() : '';
214214 $subject = $this->request->getVal('lqt_subject_field', $sbjtxt);
@@ -255,7 +255,7 @@
256256 /* $subject = $this->request->getVal('lqt_subject_field', '');
257257 if ( $e->didSave && $subject != '' ) {
258258 $thread->setSubject( Sanitizer::stripAllTags($subject) );
259 - } else if ( $e->didSave && $edit_type !='summarize' && $subject == '' && !$thread->superthread() ) {
 259+ } else if ( $e->didSave && $edit_type !='summarize' && $subject == '' && !$thread->hasSuperthread() ) {
260260 $thread->setSubject( '«no subject»' );
261261 } */
262262 }
@@ -433,7 +433,7 @@
434434 if( $thread->summary() ) {
435435 $this->showSummary($thread);
436436 } else if ( $timestamp->isBefore(Date::now()->nDaysAgo($this->archive_start_days))
437 - && !$thread->summary() && !$thread->superthread() ) {
 437+ && !$thread->summary() && !$thread->hasSuperthread() ) {
438438 $this->output->addHTML("<p class=\"lqt_summary_notice\">If this discussion seems to be concluded, you are encouraged to <a href=\"{$this->permalinkUrl($thread, 'summarize')}\">write a summary</a>. There have been no changes here for at least $this->archive_start_days days.</p>");
439439 }
440440
@@ -855,7 +855,7 @@
856856 $talkpage = $t->article()->getTitle()->getTalkpage();
857857 $talkpage_link = $this->user->getSkin()->makeKnownLinkObj($talkpage, '', $query);
858858
859 - if ( $t->superthread() ) {
 859+ if ( $t->hasSuperthread() ) {
860860 $this->output->setSubtitle( "a fragment of <a href=\"{$this->permalinkUrl($t->topmostThread())}\">a discussion</a> from " . $talkpage_link );
861861 } else {
862862
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -106,7 +106,6 @@
107107 protected $rootId;
108108 protected $articleId;
109109 protected $summaryId;
110 - protected $superthreadId;
111110
112111 /* Actual objects loaded on demand from the above when accessors are called: */
113112 protected $root;
@@ -117,6 +116,7 @@
118117 /* Simple strings: */
119118 protected $subject;
120119 protected $timestamp;
 120+ protected $path;
121121
122122 /* Identity */
123123 protected $id;
@@ -132,15 +132,24 @@
133133 }
134134
135135 function setSuperthread($thread) {
136 - $this->superthreadId = $thread->id();
137 - $this->touch();
 136+ var_dump("warning setSuperthread unimplemented");
138137 }
139138
140139 function superthread() {
141 - if ( !$this->superthreadId ) return null;
142 - if ( !$this->superthread ) $this->superthread = Thread::newFromId($this->superthreadId);
143 - return $this->superthread;
 140+ var_dump("warning superthread unimplemented"); return;
 141+ // TODO we have to find threads that may not be looked up yet
 142+ // and look them up if needed.
 143+ if( false === strpos($this->path,'.') ) {
 144+ return null;
 145+ } else {
 146+ return array_slice( $this->path, strpos($this->path, '.') );
 147+ }
144148 }
 149+
 150+ function hasSuperthread() {
 151+ if( false === strpos($this->path,'.') ) return false;
 152+ else return true;
 153+ }
145154
146155 function topmostThread() {
147156 if ( !$this->superthread() ) return $this;
@@ -274,8 +283,9 @@
275284 $lines[] = $line;
276285 }
277286
278 - foreach( $lines as $l ) {
 287+ foreach( $lines as $key => $l ) {
279288 if( $l->is_root ) {
 289+ unset($lines[$key]);
280290 $threads[] = Threads::buildLiveThread( &$lines, $l );
281291 }
282292 }
@@ -285,10 +295,11 @@
286296
287297 private static function buildLiveThread( $lines, $l ) {
288298 $children = array();
289 - foreach( $lines as $m ) {
 299+ foreach( $lines as $key => $m ) {
290300 if ( $m->thread_path != $l->thread_path &&
291301 strpos( $m->thread_path, $l->thread_path ) === 0 ) {
292302 // $m->path begins with $l->path; this is a child.
 303+ unset($lines[$key]);
293304 $children[] = Threads::buildLiveThread( &$lines, $m );
294305 }
295306 }

Status & tagging log