Index: branches/liquidthreads/maintenance/lqt-schema-change-1.sql |
— | — | @@ -0,0 +1,5 @@ |
| 2 | +update thread, page set thread_article_title=page_title, thread_article_namespace=page_namespace where page_id=thread_article and thread_article is not null and thread_article != 0; |
| 3 | + |
| 4 | +alter table thread drop column thread_article; |
| 5 | +alter table thread modify thread_article_namespace not null; |
| 6 | +alter table thread modify thread_article_title varchar(255) binary not null; |
Index: branches/liquidthreads/maintenance/lqt.sql |
— | — | @@ -1,16 +1,13 @@ |
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_article int(8) unsigned NOT NULL default 0, |
6 | 5 | thread_path text NOT NULL, |
7 | 6 | thread_summary_page int(8) unsigned NULL, |
8 | 7 | thread_timestamp char(14) binary NOT NULL default '', |
9 | 8 | thread_revision int(8) unsigned NOT NULL default 1, |
10 | 9 | |
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, |
| 10 | + thread_article_namespace int NOT NULL, |
| 11 | + thread_article_title varchar(255) binary NOT NULL, |
15 | 12 | |
16 | 13 | -- Special thread types such as schrodinger's thread: |
17 | 14 | thread_type int(4) unsigned NOT NULL default 0, |
— | — | @@ -23,7 +20,6 @@ |
24 | 21 | |
25 | 22 | PRIMARY KEY thread_id (thread_id), |
26 | 23 | UNIQUE INDEX thread_id (thread_id), |
27 | | - INDEX thread_article (thread_article), |
28 | 24 | INDEX thread_article_title (thread_article_namespace, thread_article_title), |
29 | 25 | INDEX( thread_path(255) ), |
30 | 26 | INDEX thread_timestamp (thread_timestamp) |
Index: branches/liquidthreads/skins/monobook/main.css |
— | — | @@ -31,6 +31,17 @@ |
32 | 32 | margin-bottom: .1em; |
33 | 33 | }*/ |
34 | 34 | |
| 35 | +.lqt_watchlist_messages_notice { |
| 36 | + background-color: #eee; |
| 37 | + border: 1px solid #ddd; |
| 38 | + margin: 1em 0; |
| 39 | + margin-right: 0; |
| 40 | + padding: .5em 1em; |
| 41 | + |
| 42 | + display: table; |
| 43 | + width: auto; |
| 44 | +} |
| 45 | + |
35 | 46 | .lqt_newmessages_section { |
36 | 47 | border-bottom: 0px; |
37 | 48 | } |
Index: branches/liquidthreads/extensions/LqtPages.php |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | function loadQueryFromRequest() { |
165 | 165 | // Begin with with the requirements for being *in* the archive. |
166 | 166 | $startdate = Date::now()->nDaysAgo($this->archive_start_days)->midnight(); |
167 | | - $where = array('thread.thread_article' => $this->article->getID(), |
| 167 | + $where = array(Threads::articleClause($this->article), |
168 | 168 | 'instr(thread.thread_path, ".")' => '0', |
169 | 169 | '(thread.thread_summary_page is not null' . |
170 | 170 | ' OR thread.thread_type = '.Threads::TYPE_MOVED.')', |
— | — | @@ -1008,19 +1008,28 @@ |
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | |
1012 | | -function wfLqtBeforeWatchlistHook( $options, $user ) { |
| 1012 | +function wfLqtBeforeWatchlistHook( $options, $user, &$hook_sql ) { |
1013 | 1013 | global $wgOut; |
1014 | 1014 | |
| 1015 | + $hook_sql = "AND page_namespace != " . NS_LQT_THREAD; |
| 1016 | + |
1015 | 1017 | $user_messages = NewMessages::newUserMessages($user); |
1016 | 1018 | $n = count($user_messages); |
1017 | 1019 | |
| 1020 | + if( $n == 0 ) |
| 1021 | + return true; |
| 1022 | + |
| 1023 | + if ( $n == 1 ) $phrase = "is 1 message"; |
| 1024 | + else $phrase = "are $n messages"; |
| 1025 | + |
| 1026 | + $messages_url = SpecialPage::getPage('Newmessages')->getTitle()->getFullURL(); |
1018 | 1027 | $wgOut->addHTML(<<< HTML |
1019 | | - <div class="lqt_watchlist_messages_notice"> |
1020 | | - There are $n messages for you. |
1021 | | - </div> |
| 1028 | + <a href="$messages_url" class="lqt_watchlist_messages_notice"> |
| 1029 | + ✒ There $phrase for you. |
| 1030 | + </a> |
1022 | 1031 | HTML |
1023 | 1032 | ); |
1024 | | - |
| 1033 | + |
1025 | 1034 | return true; |
1026 | 1035 | } |
1027 | 1036 | |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -338,7 +338,6 @@ |
339 | 339 | $dbr =& wfGetDB( DB_MASTER ); |
340 | 340 | $res = $dbr->update( 'thread', |
341 | 341 | /* SET */array( 'thread_root' => $this->rootId, |
342 | | - 'thread_article' => $this->articleId, |
343 | 342 | 'thread_path' => $this->path, |
344 | 343 | 'thread_type' => $this->type, |
345 | 344 | 'thread_summary_page' => $this->summaryId, |
— | — | @@ -354,6 +353,9 @@ |
355 | 354 | ), |
356 | 355 | /* WHERE */ array( 'thread_id' => $this->id, ), |
357 | 356 | __METHOD__); |
| 357 | + |
| 358 | + NewMessages::checkWatchlistsForThread($this); |
| 359 | + |
358 | 360 | |
359 | 361 | // RecentChange::notifyEdit( wfTimestampNow(), $this->root(), /*minor*/false, $wgUser, $summary, |
360 | 362 | // $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize, |
— | — | @@ -388,7 +390,6 @@ |
389 | 391 | $res = $dbr->update( 'thread', |
390 | 392 | /* SET */array( |
391 | 393 | 'thread_revision' => $r->revisionNumber() + 1, |
392 | | - 'thread_article' => $new_articleId, |
393 | 394 | 'thread_article_namespace' => $new_articleNamespace, |
394 | 395 | 'thread_article_title' => $new_articleTitle), |
395 | 396 | /* WHERE */ array( 'thread_id' => $r->id(), ), |
— | — | @@ -452,7 +453,6 @@ |
453 | 454 | |
454 | 455 | $this->id = $line->thread_id; |
455 | 456 | $this->rootId = $line->thread_root; |
456 | | - $this->articleId = $line->thread_article; |
457 | 457 | $this->articleNamespace = $line->thread_article_namespace; |
458 | 458 | $this->articleTitle = $line->thread_article_title; |
459 | 459 | $this->summaryId = $line->thread_summary_page; |
— | — | @@ -777,13 +777,6 @@ |
778 | 778 | throw new MWException(__METHOD__ . ": invalid type $type."); |
779 | 779 | } |
780 | 780 | |
781 | | - if( $article->exists() ) { |
782 | | - $aclause = array("thread_article" => $article->getID()); |
783 | | - } else { |
784 | | - $aclause = array("thread_article_namespace" => $article->getTitle()->getNamespace(), |
785 | | - "thread_article_title" => $article->getTitle()->getDBkey()); |
786 | | - } |
787 | | - |
788 | 781 | if ($superthread) { |
789 | 782 | $change_type = self::CHANGE_REPLY_CREATED; |
790 | 783 | } else { |
— | — | @@ -794,6 +787,8 @@ |
795 | 788 | |
796 | 789 | $res = $dbr->insert('thread', |
797 | 790 | array('thread_root' => $root->getID(), |
| 791 | + 'thread_article_namespace' => $article->getTitle()->getNamespace(), |
| 792 | + 'thread_article_title' => $article->getTitle()->getDBkey(), |
798 | 793 | 'thread_timestamp' => wfTimestampNow(), |
799 | 794 | 'thread_change_type' => $change_type, |
800 | 795 | 'thread_change_comment' => "", // TODO |
— | — | @@ -822,6 +817,9 @@ |
823 | 818 | if($superthread) { |
824 | 819 | $superthread->addReply( $newthread ); |
825 | 820 | } |
| 821 | + |
| 822 | + NewMessages::checkWatchlistsForThread($newthread); |
| 823 | + |
826 | 824 | return $newthread; |
827 | 825 | } |
828 | 826 | |
— | — | @@ -929,7 +927,7 @@ |
930 | 928 | * Horrible, horrible! |
931 | 929 | * List of months in which there are >0 threads, suitable for threadsOfArticleInMonth. */ |
932 | 930 | static function monthsWhereArticleHasThreads( $article ) { |
933 | | - $threads = Threads::where( array('thread.thread_article' => $article->getID()) ); |
| 931 | + $threads = Threads::where( Threads::articleClause($article) ); |
934 | 932 | $months = array(); |
935 | 933 | foreach( $threads as $t ) { |
936 | 934 | $m = substr( $t->timestamp(), 0, 6 ); |
— | — | @@ -942,10 +940,8 @@ |
943 | 941 | |
944 | 942 | static function articleClause($article) { |
945 | 943 | return <<<SQL |
946 | | - IF(thread.thread_article = 0, |
947 | | - thread.thread_article_title = "{$article->getTitle()->getDBkey()}" |
948 | | - AND thread.thread_article_namespace = {$article->getTitle()->getNamespace()} |
949 | | - , thread.thread_article = {$article->getID()}) |
| 944 | +(thread.thread_article_title = "{$article->getTitle()->getDBkey()}" |
| 945 | + AND thread.thread_article_namespace = {$article->getTitle()->getNamespace()}) |
950 | 946 | SQL; |
951 | 947 | } |
952 | 948 | |
— | — | @@ -1021,6 +1017,10 @@ |
1022 | 1018 | } |
1023 | 1019 | } |
1024 | 1020 | |
| 1021 | + static function checkWatchlistsForThread($t) { |
| 1022 | + |
| 1023 | + } |
| 1024 | + |
1025 | 1025 | static function newUserMessages($user) { |
1026 | 1026 | |
1027 | 1027 | $ts = Threads::where( array('ums_read_timestamp is null', |
Index: branches/liquidthreads/includes/SpecialWatchlist.php |
— | — | @@ -122,7 +122,8 @@ |
123 | 123 | wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor, $defaults, $nondefaults ); |
124 | 124 | wfAppendToArrayIfNotDefault('namespace', $nameSpace , $defaults, $nondefaults); |
125 | 125 | |
126 | | - if( ! wfRunHooks('BeforeWatchlist', array($nondefaults, $wgUser)) ) { |
| 126 | + $hookSql = ""; |
| 127 | + if( ! wfRunHooks('BeforeWatchlist', array($nondefaults, $wgUser, &$hookSql)) ) { |
127 | 128 | return; |
128 | 129 | } |
129 | 130 | |
— | — | @@ -197,6 +198,7 @@ |
198 | 199 | $andHideBots |
199 | 200 | $andHideMinor |
200 | 201 | $nameSpaceClause |
| 202 | + $hookSql |
201 | 203 | ORDER BY rc_timestamp DESC |
202 | 204 | $limitWatchlist"; |
203 | 205 | |