r23152 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23151‎ | r23152 | r23153 >
Date:04:40, 21 June 2007
Author:david
Status:old
Tags:
Comment:
Posting to non-existant articles now works. Should update threads to use articleid if they are edited after the article is created, but I'll do that _after_ saving threads works properly at all again.
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
@@ -1,14 +1,21 @@
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_article int(8) unsigned NOT NULL,
 5+ thread_article int(8) unsigned NOT NULL default 0,
66 thread_path text NOT NULL,
77 thread_summary_page int(8) unsigned NULL,
88 thread_timestamp char(14) binary NOT NULL default '',
99 thread_revision int(8) unsigned NOT NULL default 1,
1010
 11+ -- The following are used only for non-existant article where
 12+ -- thread_article = 0. They should be ignored if thread_article != 0.
 13+ thread_article_namespace int NULL,
 14+ thread_article_title varchar(255) binary NULL,
 15+
1116 PRIMARY KEY thread_id (thread_id),
1217 UNIQUE INDEX thread_id (thread_id),
 18+ INDEX thread_article (thread_article),
 19+ INDEX thread_article_title (thread_article_namespace, thread_article_title),
1320 INDEX( thread_path(255) ),
1421 INDEX thread_timestamp (thread_timestamp)
1522 ) TYPE=InnoDB;
@@ -24,13 +31,12 @@
2532
2633 -- Because hthreads are only stored one per root, this lists
2734 -- the subthreads that can be found within each one.
28 -CREATE TABLE /*$wgDBprefix*/hthread_contents {
 35+CREATE TABLE /*$wgDBprefix*/hthread_contents (
2936 htcontents_child int(8) unsigned NOT NULL,
3037 htcontents_hthread int(8) unsigned NOT NULL,
3138 htcontents_rev_start int(8) unsigned NOT NULL,
32 - htcontents_rev_end int(8) unsigned NULL,
33 - PRIMARY KEY
34 -}
 39+ htcontents_rev_end int(8) unsigned NULL
 40+) TYPE=InnoDB;
3541
3642 /*
3743 old_superthread and old_article are mutually exclusive.
Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -83,14 +83,20 @@
8484 $g = new QueryGroup();
8585 $startdate = Date::now()->nDaysAgo($this->archive_start_days)->midnight();
8686 $recentstartdate = $startdate->nDaysAgo($this->archive_recent_days);
 87+ $article_clause = <<<SQL
 88+ IF(thread.thread_article = 0,
 89+ thread.thread_article_title = "{$this->article->getTitle()->getDBkey()}"
 90+ AND thread.thread_article_namespace = {$this->article->getTitle()->getNamespace()}
 91+ , thread.thread_article = {$this->article->getID()})
 92+SQL;
8793 $g->addQuery('fresh',
88 - array('thread.thread_article' => $this->article->getID(),
 94+ array($article_clause,
8995 'instr(thread.thread_path, ".")' => '0',
9096 '(thread.thread_timestamp >= ' . $startdate->text() .
9197 ' OR thread.thread_summary_page is NULL)'),
9298 array('ORDER BY thread.thread_timestamp DESC'));
9399 $g->addQuery('archived',
94 - array('thread.thread_article' => $this->article->getID(),
 100+ array($article_clause,
95101 'instr(thread.thread_path, ".")' => '0',
96102 'thread.thread_summary_page is not null',
97103 'thread.thread_timestamp < ' . $startdate->text()),
@@ -844,6 +850,7 @@
845851 $this->article = $t->article(); # for creating reply threads.
846852
847853 // Make a link back to the talk page, including the correct archive month.
 854+ // TODO this is obsolete.
848855 if (Date::now()->nDaysAgo(30)->midnight()->isBefore( new Date($t->timestamp()) ))
849856 $query = '';
850857 else
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -109,6 +109,10 @@
110110 protected $rootId;
111111 protected $articleId;
112112 protected $summaryId;
 113+
 114+ /* These are only used in the case of a non-existant article. */
 115+ protected $articleNamespace;
 116+ protected $articleTitle;
113117
114118 /* Actual objects loaded on demand from the above when accessors are called: */
115119 protected $root;
@@ -150,12 +154,14 @@
151155 $this->id = $line->thread_id;
152156 $this->rootId = $line->thread_root;
153157 $this->articleId = $line->thread_article;
 158+ $this->articleNamespace = $line->thread_article_namespace;
 159+ $this->articleTitle = $line->thread_article_title;
154160 $this->summaryId = $line->thread_summary_page;
155161 $this->path = $line->thread_path;
156162 $this->timestamp = $line->thread_timestamp;
157163 $this->revisionNumber = $line->thread_revision;
158164 $this->replies = $children;
159 - //$this->double = clone $this;
 165+ $this->double = clone $this;
160166 }
161167
162168 function setSuperthread($thread) {
@@ -189,13 +195,19 @@
190196
191197 function setArticle($a) {
192198 $this->articleId = $a->getID();
 199+ $this->articleNamespace = $a->getTitle()->getNamespace();
 200+ $this->articleTitle = $a->getTitle()->getDBkey();
193201 $this->touch();
194202 }
195203
196204 function article() {
197 - if ( !$this->articleId ) return null;
198 - if ( !$this->article ) $this->article = new Article(Title::newFromID($this->articleId));
199 - return $this->article;
 205+ if ( $this->article ) return $this->article;
 206+ $a = new Article(Title::newFromID($this->articleId));
 207+ if ($a->exists()) {
 208+ return $a;
 209+ } else {
 210+ return new Article( Title::makeTitle($this->articleNamespace, $this->articleTitle) );
 211+ }
200212 }
201213
202214 function id() {
@@ -268,19 +280,6 @@
269281 function timestamp() {
270282 return $this->timestamp;
271283 }
272 -
273 - protected function updateRecord() {
274 - $dbr =& wfGetDB( DB_MASTER );
275 - $res = $dbr->update( 'lqt_thread',
276 - /* SET */ array( 'thread_root_post' => $this->rootId,
277 - 'thread_article' => $this->articleId,
278 - 'thread_subthread_of' => $this->superthreadId,
279 - 'thread_summary_page' => $this->summaryId,
280 - 'thread_subject' => $this->subject,
281 - 'thread_timestamp' => $this->timestamp ),
282 - /* WHERE */ array( 'thread_id' => $this->id, ),
283 - __METHOD__);
284 - }
285284 }
286285
287286 /** Module of factory methods. */
@@ -290,10 +289,17 @@
291290
292291 static function newThread( $root, $article, $superthread = null ) {
293292 $dbr =& wfGetDB( DB_MASTER );
 293+
 294+ if( $article->exists() ) {
 295+ $aclause = array("thread_article" => $article->getID());
 296+ } else {
 297+ $aclause = array("thread_article_namespace" => $article->getTitle()->getNamespace(),
 298+ "thread_article_title" => $article->getTitle()->getDBkey());
 299+ }
 300+
294301 $res = $dbr->insert('thread',
295 - array('thread_article' => $article->getID(),
296 - 'thread_root' => $root->getID(),
297 - 'thread_timestamp' => wfTimestampNow()),
 302+ array('thread_root' => $root->getID(),
 303+ 'thread_timestamp' => wfTimestampNow()) + $aclause,
298304 __METHOD__);
299305
300306 $newid = $dbr->insertId();

Status & tagging log