r52622 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52621‎ | r52622 | r52623 >
Date:12:18, 1 July 2009
Author:werdna
Status:deferred
Tags:
Comment:
Break out post-edit updates to their own method, in preparation for AJAX commenting
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/LqtView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/LqtView.php
@@ -377,43 +377,12 @@
378378 // Override what happens in EditPage::showEditForm, called from $e->edit():
379379
380380 $this->output->setArticleFlag( false );
381 -
382 - // For replies and new posts, insert the associated thread object into the DB.
383 - if ( $edit_type != 'editExisting' && $edit_type != 'summarize' && $e->didSave ) {
384 - if ( $edit_type == 'reply' ) {
385 - $subject = $edit_applies_to->subject();
386 -
387 - $thread = Threads::newThread( $article, $this->article, $edit_applies_to,
388 - Threads::TYPE_NORMAL, $subject );
389 -
390 - $edit_applies_to->commitRevision( Threads::CHANGE_REPLY_CREATED, $thread,
391 - $e->summary );
392 - } else {
393 - $thread = Threads::newThread( $article, $this->article, null,
394 - Threads::TYPE_NORMAL, $subject);
395 - }
 381+
 382+ if ( $e->didSave ) {
 383+ self::postEditUpdates( $edit_type, $edit_applies_to, $article, $this->article,
 384+ $subject, $e->summary, $thread );
396385 }
397386
398 - if ( $edit_type == 'summarize' && $e->didSave ) {
399 - $edit_applies_to->setSummary( $article );
400 - $edit_applies_to->commitRevision( Threads::CHANGE_EDITED_SUMMARY,
401 - $edit_applies_to, $e->summary );
402 - }
403 -
404 - // Move the thread and replies if subject changed.
405 - if ( $edit_type == 'editExisting' && $e->didSave ) {
406 - $subject = $this->request->getVal( 'lqt_subject_field', '' );
407 - if ( $subject && $subject != $thread->subjectWithoutIncrement() ) {
408 - $thread->setSubject( $subject );
409 -
410 - // Disabled page-moving for now.
411 - // $this->renameThread( $thread, $subject, $e->summary );
412 - }
413 - // this is unrelated to the subject change and is for all edits:
414 - $thread->setRootRevision( Revision::newFromTitle( $thread->root()->getTitle() ) );
415 - $thread->commitRevision( Threads::CHANGE_EDITED_ROOT, $thread, $e->summary );
416 - }
417 -
418387 // A redirect without $e->didSave will happen if the new text is blank (EditPage::attemptSave).
419388 // This results in a new Thread object not being created for replies and new discussions,
420389 // so $thread is null. In that case, just allow editpage to redirect back to the talk page.
@@ -428,6 +397,45 @@
429398 $this->output->redirect( $redirectTitle->getFullURL() );
430399 }
431400 }
 401+
 402+ static function postEditUpdates($edit_type, $edit_applies_to, $edit_page, $article,
 403+ $subject, $edit_summary, $thread ) {
 404+ // For replies and new posts, insert the associated thread object into the DB.
 405+ if ( $edit_type == 'reply' ) {
 406+ $subject = $edit_applies_to->subject();
 407+
 408+ $thread = Threads::newThread( $edit_page, $article, $edit_applies_to,
 409+ Threads::TYPE_NORMAL, $subject );
 410+
 411+ $edit_applies_to->commitRevision( Threads::CHANGE_REPLY_CREATED, $thread,
 412+ $edit_summary );
 413+ } elseif ( $edit_type == 'summarize' ) {
 414+ $edit_applies_to->setSummary( $article );
 415+ $edit_applies_to->commitRevision( Threads::CHANGE_EDITED_SUMMARY,
 416+ $edit_applies_to, $edit_summary );
 417+ } elseif ( $edit_type == 'editExisting' ) {
 418+ // Move the thread and replies if subject changed.
 419+ if ( $subject && $subject != $thread->subjectWithoutIncrement() ) {
 420+ $thread->setSubject( $subject );
 421+
 422+ // Disabled page-moving for now.
 423+ // $this->renameThread( $thread, $subject, $e->summary );
 424+ }
 425+
 426+ // For all edits, bump the version number.
 427+ $thread->setRootRevision( Revision::newFromTitle( $thread->root()->getTitle() ) );
 428+ $thread->commitRevision( Threads::CHANGE_EDITED_ROOT, $thread, $edit_summary );
 429+ } else {
 430+ $thread = Threads::newThread( $edit_page, $article, null,
 431+ Threads::TYPE_NORMAL, $subject );
 432+ // Commented-out for now. History needs fixing.
 433+// // Commit the first revision
 434+// $thread->commitRevision( Threads::CHANGE_NEW_THREAD, $thread,
 435+// $edit_summary );
 436+ }
 437+
 438+ return $thread;
 439+ }
432440
433441 function renameThread( $t, $s, $reason ) {
434442 $this->simplePageMove( $t->root()->getTitle(), $s, $reason );

Status & tagging log