Index: branches/liquidthreads/extensions/LqtPages.php |
— | — | @@ -1027,19 +1027,19 @@ |
1028 | 1028 | |
1029 | 1029 | $hook_sql = "AND page_namespace != " . NS_LQT_THREAD; |
1030 | 1030 | |
1031 | | - $user_messages = NewMessages::newUserMessages($user); |
1032 | | - $n = count($user_messages); |
| 1031 | + $talkpage_messages = NewMessages::newUserMessages($user); |
| 1032 | + $tn = count($talkpage_messages); |
1033 | 1033 | |
1034 | | - if( $n == 0 ) |
| 1034 | + $watch_messages = NewMessages::watchedThreadsForUser($user); |
| 1035 | + $wn = count($watch_messages); |
| 1036 | + |
| 1037 | + if( $tn == 0 && $wn == 0 ) |
1035 | 1038 | return true; |
1036 | 1039 | |
1037 | | - if ( $n == 1 ) $phrase = "is 1 message"; |
1038 | | - else $phrase = "are $n messages"; |
1039 | | - |
1040 | 1040 | $messages_url = SpecialPage::getPage('Newmessages')->getTitle()->getFullURL(); |
1041 | 1041 | $wgOut->addHTML(<<< HTML |
1042 | 1042 | <a href="$messages_url" class="lqt_watchlist_messages_notice"> |
1043 | | - ✒ There $phrase for you. |
| 1043 | + ✒ There are new messages for you. |
1044 | 1044 | </a> |
1045 | 1045 | HTML |
1046 | 1046 | ); |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -1035,8 +1035,10 @@ |
1036 | 1036 | |
1037 | 1037 | // it sucks to not have 'on duplicate key update'. first update users who already have a ums for this thread |
1038 | 1038 | // and who have already read it, by setting their state to unread. |
1039 | | - $dbw->query("update user_message_state, thread, watchlist set ums_read_timestamp = null where ums_user = wl_user and ums_thread = thread_id and $where_clause"); |
1040 | 1039 | |
| 1040 | + // this is touching all ums rows instead of just the ones for the thread in question. |
| 1041 | + $dbw->query("update user_message_state, watchlist set ums_read_timestamp = null where ums_user = wl_user and ums_thread = {$t->id()} and $where_clause"); |
| 1042 | + |
1041 | 1043 | $dbw->query("insert ignore into user_message_state (ums_user, ums_thread) select user_id, {$t->id()} from user, watchlist where user_id = wl_user and $where_clause;"); |
1042 | 1044 | } |
1043 | 1045 | |
— | — | @@ -1048,6 +1050,7 @@ |
1049 | 1051 | |
1050 | 1052 | static function watchedThreadsForUser($user) { |
1051 | 1053 | return Threads::where( array('ums_read_timestamp is null', |
| 1054 | + 'ums_user' => $user->getID(), |
1052 | 1055 | 'ums_thread = thread.thread_id', |
1053 | 1056 | 'NOT (' . Threads::articleClause(new Article($user->getUserPage())) . ')' ), |
1054 | 1057 | array(), array('user_message_state') ); |