r23202 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23201‎ | r23202 | r23203 >
Date:08:52, 22 June 2007
Author:david
Status:old
Tags:
Comment:
towards history. more stumbling-blocks. zzz.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)
  • /branches/liquidthreads/includes/Article.php (modified) (history)
  • /branches/liquidthreads/maintenance/lqt.sql (modified) (history)

Diff [purge]

Index: branches/liquidthreads/maintenance/lqt.sql
@@ -1,6 +1,7 @@
22 CREATE TABLE /*$wgDBprefix*/thread (
33 thread_id int(8) unsigned NOT NULL auto_increment,
44 thread_root int(8) unsigned UNIQUE NOT NULL,
 5+ thread_root_rev int(8) unsigned NOT NULL default 0,
56 thread_article int(8) unsigned NOT NULL default 0,
67 thread_path text NOT NULL,
78 thread_summary_page int(8) unsigned NULL,
Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -255,6 +255,9 @@
256256 if ( $subject && $subject != $thread->subjectWithoutIncrement() ) {
257257 //$this->renameThread($thread, $subject);
258258 }
 259+ // this is unrelated to the subject change and is for all edits:
 260+// $thread->setRootRevision( );
 261+ $thread->commitRevision();
259262 }
260263
261264 /* $subject = $this->request->getVal('lqt_subject_field', '');
@@ -281,7 +284,7 @@
282285 return $this->incrementedTitle( $subject?$subject:"«no subject»", NS_LQT_THREAD );
283286 }
284287 function newSummaryTitle($t) {
285 - return $this->incrementedTitle( "Summary of " . $t->subject(), NS_LQT_SUMMARY );
 288+ return $this->incrementedTitle( $t->subject(), NS_LQT_SUMMARY );
286289 }
287290 function newReplyTitle($s, $t) {
288291 return $this->incrementedTitle( $t->subjectWithoutIncrement(), NS_LQT_THREAD );
@@ -602,12 +605,11 @@
603606 $this->output->setPageTitle( "Talk:" . $this->title->getText() ); // TODO non-main namespaces.
604607 $this->addJSandCSS();
605608
606 - // lqtCheapTest( );
607 - // return;
608 -
609609 $this->showHeader();
610610
611611 $this->showArchiveWidget();
 612+
 613+ var_dump(HistoricalThread::withIdAtRevision(3,3));
612614
613615 if( $this->methodApplies('talkpage_new_thread') ) {
614616 $this->showNewThreadForm();
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -99,9 +99,30 @@
100100 }
101101
102102 class HistoricalThread {
103 - static function create( $livethread ) {
104 - echo ("pretended to create new historical thread.");
 103+ static function textRepresentation($t) {
 104+ return serialize($t);
105105 }
 106+ static function create( $t ) {
 107+ $tmt = $t->topmostThread();
 108+ $contents = HistoricalThread::textRepresentation($tmt);
 109+ $dbr =& wfGetDB( DB_MASTER );
 110+ $res = $dbr->insert( 'historical_thread', array(
 111+ 'hthread_id'=>$tmt->id(),
 112+ 'hthread_revision'=>$tmt->revisionNumber(),
 113+ 'hthread_contents'=>$contents), __METHOD__ );
 114+ }
 115+ static function withIdAtRevision( $id, $rev ) {
 116+ $dbr =& wfGetDB( DB_SLAVE );
 117+ $line = $dbr->selectRow(
 118+ 'historical_thread',
 119+ 'hthread_contents',
 120+ array('hthread_id' => $id, 'hthread_revision' => $rev),
 121+ __METHOD__);
 122+ if ( $line )
 123+ return unserialize($line->hthread_contents);
 124+ else
 125+ return null;
 126+ }
106127 }
107128
108129 class LiveThread {
@@ -127,11 +148,16 @@
128149
129150 protected $id;
130151 protected $revisionNumber;
 152+ protected $rootRevision;
131153
132154 /* Copy of $this made when first loaded from database, to store the data
133155 we will write to the history if a new revision is commited. */
134156 protected $double;
135157
 158+ function revisionNumber() {
 159+ return $this->revisionNumber;
 160+ }
 161+
136162 function commitRevision() {
137163 // TODO open a transaction.
138164 HistoricalThread::create( $this->double );
@@ -141,11 +167,14 @@
142168 $dbr =& wfGetDB( DB_MASTER );
143169 $res = $dbr->update( 'thread',
144170 /* SET */array( 'thread_root' => $this->rootId,
 171+ 'thread_root_rev' => $this->rootRevision,
145172 'thread_article' => $this->articleId,
146173 'thread_path' => $this->path,
147174 'thread_summary_page' => $this->summaryId,
148175 'thread_timestamp' => $this->timestamp,
149 - 'thread_revision' => $this->revisionNumber ),
 176+ 'thread_revision' => $this->revisionNumber,
 177+ 'thread_article_namespace' => $this->articleNamespace,
 178+ 'thread_article_title' => $this->articleTitle),
150179 /* WHERE */ array( 'thread_id' => $this->id, ),
151180 __METHOD__);
152181 }
@@ -156,6 +185,7 @@
157186 $this->articleId = $line->thread_article;
158187 $this->articleNamespace = $line->thread_article_namespace;
159188 $this->articleTitle = $line->thread_article_title;
 189+ $this->rootRevision = $line->thread_root_rev;
160190 $this->summaryId = $line->thread_summary_page;
161191 $this->path = $line->thread_path;
162192 $this->timestamp = $line->thread_timestamp;
@@ -220,7 +250,7 @@
221251
222252 function root() {
223253 if ( !$this->rootId ) return null;
224 - if ( !$this->root ) $this->root = new Post( Title::newFromID( $this->rootId ) );
 254+ if ( !$this->root ) $this->root = new Post( Title::newFromID( $this->rootId ), $this->rootRevision );
225255 return $this->root;
226256 }
227257
@@ -369,7 +399,6 @@
370400 $l_path = preg_quote($l->thread_path);
371401 foreach( $lines as $key => $m ) {
372402 if ( preg_match( "/^{$l_path}\.\d+$/", $m->thread_path ) ) {
373 - // $m->path begins with $l->path; this is a child.
374403 // unset($lines[$key]);
375404 $children[] = Threads::buildLiveThread( &$lines, $m );
376405 }
Index: branches/liquidthreads/includes/Article.php
@@ -44,6 +44,7 @@
4545 function __construct( &$title, $oldId = null ) {
4646 $this->mTitle =& $title;
4747 $this->mOldId = $oldId;
 48+ var_dump($oldId);
4849 $this->clear();
4950 }
5051

Status & tagging log