r24868 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24867‎ | r24868 | r24869 >
Date:05:11, 17 August 2007
Author:david
Status:old
Tags:
Comment:
support reasons, users, timestamps in history
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)
  • /branches/liquidthreads/maintenance/lqt.sql (modified) (history)

Diff [purge]

Index: branches/liquidthreads/maintenance/lqt.sql
@@ -17,6 +17,9 @@
1818
1919 thread_change_type int(4) unsigned NOT NULL,
2020 thread_change_object int(8) unsigned NULL,
 21+ thread_change_comment tinyblob NOT NULL,
 22+ thread_change_user int unsigned NOT NULL default '0',
 23+ thread_change_user_text varchar(255) binary NOT NULL default '',
2124
2225 PRIMARY KEY thread_id (thread_id),
2326 UNIQUE INDEX thread_id (thread_id),
Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -284,8 +284,8 @@
285285 }
286286
287287 $e = new EditPage($article);
 288+
288289 $e->suppressIntro = true;
289 -
290290 $e->editFormTextBeforeContent .=
291291 $this->perpetuate('lqt_method', 'hidden') .
292292 $this->perpetuate('lqt_operand', 'hidden');
@@ -316,28 +316,28 @@
317317 // For replies and new posts, insert the associated thread object into the DB.
318318 if ($edit_type != 'editExisting' && $edit_type != 'summarize' && $e->didSave) {
319319 if ( $edit_type == 'reply' ) {
320 - $thread = Threads::newThread( $article, $this->article, $edit_applies_to );
321 - $edit_applies_to->commitRevision(Threads::CHANGE_REPLY_CREATED, $thread);
 320+ $thread = Threads::newThread( $article, $this->article, $edit_applies_to, $e->summary );
 321+ $edit_applies_to->commitRevision(Threads::CHANGE_REPLY_CREATED, $thread, $e->summary);
322322 } else {
323 - $thread = Threads::newThread( $article, $this->article );
 323+ $thread = Threads::newThread( $article, $this->article, $e->summary );
324324 }
325325 }
326326
327327 if ($edit_type == 'summarize' && $e->didSave) {
328328 $edit_applies_to->setSummary( $article );
329 - $edit_applies_to->commitRevision(Threads::CHANGE_EDITED_SUMMARY, $edit_applies_to);
 329+ $edit_applies_to->commitRevision(Threads::CHANGE_EDITED_SUMMARY, $edit_applies_to, $e->summary);
330330 }
331331
332332 // Move the thread and replies if subject changed.
333333 if( $edit_type == 'editExisting' && $e->didSave ) {
334334 $subject = $this->request->getVal('lqt_subject_field', '');
335335 if ( $subject && $subject != $thread->subjectWithoutIncrement() ) {
336 - $reason = $this->request->getVal("wpSummary", "");
337 - $this->renameThread($thread, $subject, $reason);
 336+// $reason = $this->request->getVal("wpSummary", "");
 337+ $this->renameThread($thread, $subject, $e->summary);
338338 }
339339 // this is unrelated to the subject change and is for all edits:
340340 $thread->setRootRevision( Revision::newFromTitle($thread->root()->getTitle()) );
341 - $thread->commitRevision( Threads::CHANGE_EDITED_ROOT, $thread );
 341+ $thread->commitRevision( Threads::CHANGE_EDITED_ROOT, $thread, $e->summary );
342342 }
343343 }
344344
@@ -991,16 +991,27 @@
992992 * @return string HTML output for the row
993993 */
994994 function historyLine( $row, $next, $counter = '', $notificationtimestamp = false, $latest = false, $firstInList = false ) {
 995+ global $wgLang, $wgOut; // TODO global.
 996+
 997+ $hthread = HistoricalThread::fromTextRepresentation($row->hthread_contents);
 998+
995999 /* TODO: best not to refer to LqtView class directly. */
9961000 /* We don't use oldid because that has side-effects. */
9971001 $result = array();
998 - $change_names = array(Threads::CHANGE_EDITED_ROOT => "Comment text edited",
999 - Threads::CHANGE_EDITED_SUMMARY => "Summary changed",
1000 - Threads::CHANGE_REPLY_CREATED => "New reply created",
1001 - Threads::CHANGE_NEW_THREAD => "New thread created");
 1002+ $change_names = array(Threads::CHANGE_EDITED_ROOT => "Comment text edited:",
 1003+ Threads::CHANGE_EDITED_SUMMARY => "Summary changed:",
 1004+ Threads::CHANGE_REPLY_CREATED => "New reply created:",
 1005+ Threads::CHANGE_NEW_THREAD => "New thread created:");
10021006 $url = LqtView::permalinkUrlWithQuery( $this->thread, 'lqt_oldid=' . $row->hthread_revision );
1003 - $result[] = "<tr><td><a href=\"$url\">" . $row->hthread_revision . '</a></td>';
1004 - $result[] = "<td>Revision type: {$change_names[$row->hthread_change_type]}.</td></tr>";
 1007+
 1008+ $p = new Parser(); $sig = $wgOut->parse( $p->getUserSig( $hthread->changeUser() ), false );
 1009+
 1010+ $result[] = "<tr>";
 1011+ $result[] = "<td><a href=\"$url\">" . $wgLang->timeanddate($this->thread->timestamp()) . "</a></td>";
 1012+ $result[] = "<td>" . $sig . "</td>";
 1013+ $result[] = "<td>{$change_names[$row->hthread_change_type]}</td>";
 1014+ $result[] = "<td>" . $hthread->changeComment() . "</td>";
 1015+ $result[] = "</tr>";
10051016 return implode('', $result);
10061017 }
10071018 function getNotificationTimestamp() {
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -100,6 +100,7 @@
101101
102102 class HistoricalThread extends Thread {
103103 function __construct($t) {
 104+ /* SCHEMA changes must be reflected here. */
104105 $this->rootId = $t->rootId;
105106 $this->rootRevision = $t->rootRevision;
106107 $this->articleId = $t->articleId;
@@ -112,6 +113,9 @@
113114 $this->revisionNumber = $t->revisionNumber;
114115 $this->changeType = $t->changeType;
115116 $this->changeObject = $t->changeObject;
 117+ $this->changeComment = $t->changeComment;
 118+ $this->changeUser = $t->changeUser;
 119+ $this->changeUserText = $t->changeUserText;
116120
117121 $this->replies = array();
118122 foreach ($t->replies as $r) {
@@ -154,6 +158,8 @@
155159 }
156160
157161 class Thread {
 162+ /* SCHEMA changes must be reflected here. */
 163+
158164 /* ID references to other objects that are loaded on demand: */
159165 protected $rootId;
160166 protected $articleId;
@@ -180,6 +186,9 @@
181187
182188 protected $changeType;
183189 protected $changeObject;
 190+ protected $changeComment;
 191+ protected $changeUser;
 192+ protected $changeUserText;
184193
185194 /* Only used by $double to be saved into a historical thread. */
186195 protected $rootRevision;
@@ -232,14 +241,20 @@
233242 __METHOD__);
234243 }
235244
236 - function commitRevision($change_type, $change_object = null) {
 245+ function commitRevision($change_type, $change_object = null, $reason = "") {
237246 global $wgUser; // TODO global.
238247
 248+ $this->changeComment = $reason;
 249+ $this->changeUser = $wgUser->getID();
 250+ $this->changeUserText = $wgUser->getName();
 251+
239252 // TODO open a transaction.
240253 HistoricalThread::create( $this->double );
241254
242255 $this->bumpRevisionsOnAncestors($change_type, $change_object);
243256
 257+ /* SCHEMA changes must be reflected here. */
 258+
244259 $dbr =& wfGetDB( DB_MASTER );
245260 $res = $dbr->update( 'thread',
246261 /* SET */array( 'thread_root' => $this->rootId,
@@ -251,7 +266,11 @@
252267 'thread_article_namespace' => $this->articleNamespace,
253268 'thread_article_title' => $this->articleTitle,
254269 'thread_change_type' => $this->changeType,
255 - 'thread_change_object' => $this->changeObject),
 270+ 'thread_change_object' => $this->changeObject,
 271+ 'thread_change_comment' => $this->changeComment,
 272+ 'thread_change_user' => $this->changeUser,
 273+ 'thread_change_user_text' => $this->changeUserText,
 274+ ),
256275 /* WHERE */ array( 'thread_id' => $this->id, ),
257276 __METHOD__);
258277
@@ -337,6 +356,8 @@
338357
339358
340359 function __construct($line, $children) {
 360+ /* SCHEMA changes must be reflected here. */
 361+
341362 $this->id = $line->thread_id;
342363 $this->rootId = $line->thread_root;
343364 $this->articleId = $line->thread_article;
@@ -349,6 +370,9 @@
350371 $this->type = $line->thread_type;
351372 $this->changeType = $line->thread_change_type;
352373 $this->changeObject = $line->thread_change_object;
 374+ $this->changeComment = $line->thread_change_comment;
 375+ $this->changeUser = $line->thread_change_user;
 376+ $this->changeUserText = $line->thread_change_user_text;
353377
354378 $this->replies = $children;
355379
@@ -567,6 +591,18 @@
568592 $this->changeObject = $o->id();
569593 }
570594 }
 595+
 596+ function changeUser() {
 597+ if( $this->changeUser == 0 ) {
 598+ return User::newFromName($this->changeUserText);
 599+ } else {
 600+ return User::newFromId($this->changeUser);
 601+ }
 602+ }
 603+
 604+ function changeComment() {
 605+ return $this->changeComment;
 606+ }
571607 }
572608
573609

Status & tagging log