Index: trunk/extensions/LiquidThreads/classes/LqtNewMessages.php |
— | — | @@ -12,28 +12,28 @@ |
13 | 13 | } |
14 | 14 | |
15 | 15 | private static function writeUserMessageState( $thread, $user, $timestamp ) { |
16 | | - global $wgDBprefix; |
17 | | - if ( is_object( $thread ) ) $thread_id = $thread->id(); |
18 | | - else if ( is_integer( $thread ) ) $thread_id = $thread; |
19 | | - else throw new MWException( "writeUserMessageState expected Thread or integer but got $thread" ); |
| 16 | + if ( is_object( $thread ) ) { |
| 17 | + $thread_id = $thread->id(); |
| 18 | + } else if ( is_integer( $thread ) ) { |
| 19 | + $thread_id = $thread; |
| 20 | + } else { |
| 21 | + throw new MWException( "writeUserMessageState expected Thread or integer but got $thread" ); |
| 22 | + } |
20 | 23 | |
21 | | - if ( is_object( $user ) ) $user_id = $user->getID(); |
22 | | - else if ( is_integer( $user ) ) $user_id = $user; |
23 | | - else throw new MWException( "writeUserMessageState expected User or integer but got $user" ); |
| 24 | + if ( is_object( $user ) ) { |
| 25 | + $user_id = $user->getID(); |
| 26 | + } else if ( is_integer( $user ) ) { |
| 27 | + $user_id = $user; |
| 28 | + } else { |
| 29 | + throw new MWException( "writeUserMessageState expected User or integer but got $user" ); |
| 30 | + } |
24 | 31 | |
25 | | - if ( $timestamp === null ) $timestamp = "NULL"; |
26 | | - |
27 | 32 | // use query() directly to pass in 'true' for don't-die-on-errors. |
28 | | - $dbr =& wfGetDB( DB_MASTER ); |
29 | | - $success = $dbr->query( "insert into {$wgDBprefix}user_message_state values ($user_id, $thread_id, $timestamp)", |
30 | | - __METHOD__, true ); |
31 | | - |
32 | | - if ( !$success ) { |
33 | | - // duplicate key; update. |
34 | | - $dbr->query( "update {$wgDBprefix}user_message_state set ums_read_timestamp = $timestamp" . |
35 | | - " where ums_thread = $thread_id and ums_user = $user_id", |
36 | | - __METHOD__ ); |
37 | | - } |
| 33 | + $dbw = wfGetDB( DB_MASTER ); |
| 34 | + |
| 35 | + $dbw->replace( 'user_message_state', array( array( 'ums_user', 'ums_thread' ) ), |
| 36 | + array( 'ums_user' => $user_id, 'ums_thread' => $thread_id, |
| 37 | + 'ums_read_timestamp' => $timestamp ), __METHOD__ ); |
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | * If the thread is on a user's talkpage, set that user's newtalk. |
43 | 43 | */ |
44 | 44 | static function writeMessageStateForUpdatedThread( $t, $type, $changeUser ) { |
45 | | - global $wgDBprefix, $wgUser; |
| 45 | + global $wgUser; |
46 | 46 | |
47 | 47 | wfDebugLog( 'LiquidThreads', 'Doing notifications' ); |
48 | 48 | |