r23925 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23924‎ | r23925 | r23926 >
Date:21:40, 9 July 2007
Author:david
Status:old
Tags:
Comment:
commit on reply, summarize, etc.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -241,7 +241,7 @@
242242 $this->perpetuate('lqt_method', 'hidden') .
243243 $this->perpetuate('lqt_operand', 'hidden');
244244
245 - if ( /*$thread == null*/ $edit_type=='new' || ($thread && !$thread->hasSuperthread()) ) {
 245+ if ( $edit_type=='new' || ($thread && !$thread->hasSuperthread()) ) {
246246 // This is a top-level post; show the subject line.
247247 $sbjtxt = $thread ? $thread->subjectWithoutIncrement() : '';
248248 $subject = $this->request->getVal('lqt_subject_field', $sbjtxt);
@@ -268,6 +268,7 @@
269269 if ($edit_type != 'editExisting' && $edit_type != 'summarize' && $e->didSave) {
270270 if ( $edit_type == 'reply' ) {
271271 $thread = Threads::newThread( $article, $this->article, $edit_applies_to );
 272+ $edit_applies_to->commitRevision();
272273 } else {
273274 $thread = Threads::newThread( $article, $this->article );
274275 }
@@ -275,6 +276,7 @@
276277
277278 if ($edit_type == 'summarize' && $e->didSave) {
278279 $edit_applies_to->setSummary( $article );
 280+ $edit_applies_to->commitRevision();
279281 }
280282
281283 // Move the thread and replies if subject changed.
@@ -287,13 +289,6 @@
288290 $thread->setRootRevision( Revision::newFromTitle($thread->root()->getTitle()) );
289291 $thread->commitRevision();
290292 }
291 -
292 -/* $subject = $this->request->getVal('lqt_subject_field', '');
293 - if ( $e->didSave && $subject != '' ) {
294 - $thread->setSubject( Sanitizer::stripAllTags($subject) );
295 - } else if ( $e->didSave && $edit_type !='summarize' && $subject == '' && !$thread->hasSuperthread() ) {
296 - $thread->setSubject( '«no subject»' );
297 - } */
298293 }
299294
300295 function renameThread($t,$s) {
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -208,7 +208,7 @@
209209 'thread_article' => $this->articleId,
210210 'thread_path' => $this->path,
211211 'thread_summary_page' => $this->summaryId,
212 - 'thread_timestamp' => $this->timestamp,
 212+ 'thread_timestamp' => wfTimestampNow(),
213213 'thread_revision' => $this->revisionNumber,
214214 'thread_article_namespace' => $this->articleNamespace,
215215 'thread_article_title' => $this->articleTitle),
@@ -243,6 +243,29 @@
244244 $this->double->rootRevision = $rev->getId();
245245 }
246246
 247+ /*
 248+ More evidence that the way I'm doing history is totally screwed.
 249+ These methods do not alter the childrens' superthread field. All they do
 250+ is make sure the latest info gets into any historicalthreads we commit.
 251+ */
 252+ function addReply($thread) {
 253+ $this->replies[] = $thread;
 254+ }
 255+ function removeReplyWithId($id) {
 256+ $target = null;
 257+ foreach($this->replies as $k=>$r) {
 258+ if ($r->id() == $id) {
 259+ $target = $k; break;
 260+ }
 261+ }
 262+ if ($target) {
 263+ unset($this->replies[$target]);
 264+ return true;
 265+ } else {
 266+ return false;
 267+ }
 268+ }
 269+
247270 function setSuperthread($thread) {
248271 $this->path = $thread->path . '.' . $this->id;
249272 }
@@ -393,8 +416,7 @@
394417
395418 if( $superthread ) {
396419 $newpath = $superthread->path() . '.' . $newid;
397 - } else
398 - {
 420+ } else {
399421 $newpath = $newid;
400422 }
401423 $res = $dbr->update( 'thread',
@@ -403,7 +425,11 @@
404426 __METHOD__);
405427
406428 // TODO we could avoid a query here.
407 - return Threads::withId($newid);
 429+ $newthread = Threads::withId($newid);
 430+ if($superthread) {
 431+ $superthread->addReply( $newthread );
 432+ }
 433+ return $newthread;
408434 }
409435
410436 static function where( $where, $options = array(), $extra_tables = array() ) {

Status & tagging log