Index: branches/liquidthreads/maintenance/lqt.sql |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | CREATE TABLE /*$wgDBprefix*/thread ( |
3 | 3 | thread_id int(8) unsigned NOT NULL auto_increment, |
4 | 4 | thread_root int(8) unsigned UNIQUE NOT NULL, |
| 5 | + thread_root_rev int(8) unsigned NOT NULL default 0, |
5 | 6 | thread_article int(8) unsigned NOT NULL default 0, |
6 | 7 | thread_path text NOT NULL, |
7 | 8 | thread_summary_page int(8) unsigned NULL, |
Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -255,6 +255,9 @@ |
256 | 256 | if ( $subject && $subject != $thread->subjectWithoutIncrement() ) { |
257 | 257 | //$this->renameThread($thread, $subject); |
258 | 258 | } |
| 259 | + // this is unrelated to the subject change and is for all edits: |
| 260 | +// $thread->setRootRevision( ); |
| 261 | + $thread->commitRevision(); |
259 | 262 | } |
260 | 263 | |
261 | 264 | /* $subject = $this->request->getVal('lqt_subject_field', ''); |
— | — | @@ -281,7 +284,7 @@ |
282 | 285 | return $this->incrementedTitle( $subject?$subject:"«no subject»", NS_LQT_THREAD ); |
283 | 286 | } |
284 | 287 | function newSummaryTitle($t) { |
285 | | - return $this->incrementedTitle( "Summary of " . $t->subject(), NS_LQT_SUMMARY ); |
| 288 | + return $this->incrementedTitle( $t->subject(), NS_LQT_SUMMARY ); |
286 | 289 | } |
287 | 290 | function newReplyTitle($s, $t) { |
288 | 291 | return $this->incrementedTitle( $t->subjectWithoutIncrement(), NS_LQT_THREAD ); |
— | — | @@ -602,12 +605,11 @@ |
603 | 606 | $this->output->setPageTitle( "Talk:" . $this->title->getText() ); // TODO non-main namespaces. |
604 | 607 | $this->addJSandCSS(); |
605 | 608 | |
606 | | - // lqtCheapTest( ); |
607 | | - // return; |
608 | | - |
609 | 609 | $this->showHeader(); |
610 | 610 | |
611 | 611 | $this->showArchiveWidget(); |
| 612 | + |
| 613 | + var_dump(HistoricalThread::withIdAtRevision(3,3)); |
612 | 614 | |
613 | 615 | if( $this->methodApplies('talkpage_new_thread') ) { |
614 | 616 | $this->showNewThreadForm(); |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -99,9 +99,30 @@ |
100 | 100 | } |
101 | 101 | |
102 | 102 | class HistoricalThread { |
103 | | - static function create( $livethread ) { |
104 | | - echo ("pretended to create new historical thread."); |
| 103 | + static function textRepresentation($t) { |
| 104 | + return serialize($t); |
105 | 105 | } |
| 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 | + } |
106 | 127 | } |
107 | 128 | |
108 | 129 | class LiveThread { |
— | — | @@ -127,11 +148,16 @@ |
128 | 149 | |
129 | 150 | protected $id; |
130 | 151 | protected $revisionNumber; |
| 152 | + protected $rootRevision; |
131 | 153 | |
132 | 154 | /* Copy of $this made when first loaded from database, to store the data |
133 | 155 | we will write to the history if a new revision is commited. */ |
134 | 156 | protected $double; |
135 | 157 | |
| 158 | + function revisionNumber() { |
| 159 | + return $this->revisionNumber; |
| 160 | + } |
| 161 | + |
136 | 162 | function commitRevision() { |
137 | 163 | // TODO open a transaction. |
138 | 164 | HistoricalThread::create( $this->double ); |
— | — | @@ -141,11 +167,14 @@ |
142 | 168 | $dbr =& wfGetDB( DB_MASTER ); |
143 | 169 | $res = $dbr->update( 'thread', |
144 | 170 | /* SET */array( 'thread_root' => $this->rootId, |
| 171 | + 'thread_root_rev' => $this->rootRevision, |
145 | 172 | 'thread_article' => $this->articleId, |
146 | 173 | 'thread_path' => $this->path, |
147 | 174 | 'thread_summary_page' => $this->summaryId, |
148 | 175 | '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), |
150 | 179 | /* WHERE */ array( 'thread_id' => $this->id, ), |
151 | 180 | __METHOD__); |
152 | 181 | } |
— | — | @@ -156,6 +185,7 @@ |
157 | 186 | $this->articleId = $line->thread_article; |
158 | 187 | $this->articleNamespace = $line->thread_article_namespace; |
159 | 188 | $this->articleTitle = $line->thread_article_title; |
| 189 | + $this->rootRevision = $line->thread_root_rev; |
160 | 190 | $this->summaryId = $line->thread_summary_page; |
161 | 191 | $this->path = $line->thread_path; |
162 | 192 | $this->timestamp = $line->thread_timestamp; |
— | — | @@ -220,7 +250,7 @@ |
221 | 251 | |
222 | 252 | function root() { |
223 | 253 | 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 ); |
225 | 255 | return $this->root; |
226 | 256 | } |
227 | 257 | |
— | — | @@ -369,7 +399,6 @@ |
370 | 400 | $l_path = preg_quote($l->thread_path); |
371 | 401 | foreach( $lines as $key => $m ) { |
372 | 402 | if ( preg_match( "/^{$l_path}\.\d+$/", $m->thread_path ) ) { |
373 | | - // $m->path begins with $l->path; this is a child. |
374 | 403 | // unset($lines[$key]); |
375 | 404 | $children[] = Threads::buildLiveThread( &$lines, $m ); |
376 | 405 | } |
Index: branches/liquidthreads/includes/Article.php |
— | — | @@ -44,6 +44,7 @@ |
45 | 45 | function __construct( &$title, $oldId = null ) { |
46 | 46 | $this->mTitle =& $title; |
47 | 47 | $this->mOldId = $oldId; |
| 48 | + var_dump($oldId); |
48 | 49 | $this->clear(); |
49 | 50 | } |
50 | 51 | |