Index: trunk/extensions/LiquidThreads/classes/NewMessagesController.php |
— | — | @@ -108,7 +108,8 @@ |
109 | 109 | } |
110 | 110 | |
111 | 111 | private static function getRowsObject( $t ) { |
112 | | - $tables = array( 'watchlist', 'user_message_state', 'user_properties' ); |
| 112 | + // <= 1.15 compatibility, it kinda sucks having to do all this up here. |
| 113 | + $tables = array( 'watchlist', 'user_message_state' ); |
113 | 114 | $joins = array( |
114 | 115 | 'user_message_state' => |
115 | 116 | array( |
— | — | @@ -117,17 +118,28 @@ |
118 | 119 | 'ums_user=wl_user', |
119 | 120 | 'ums_thread' => $t->id() |
120 | 121 | ) |
121 | | - ), |
122 | | - 'user_properties' => |
123 | | - array( |
| 122 | + ) |
| 123 | + ); |
| 124 | + $fields = array( 'wl_user', 'ums_user', 'ums_read_timestamp' ); |
| 125 | + |
| 126 | + global $wgVersion; |
| 127 | + if ( version_compare( $wgVersion, '1.15.999', '<=' ) ) { |
| 128 | + $oldPrefCompat = true; |
| 129 | + |
| 130 | + $tables[] = 'user'; |
| 131 | + $joins['user'] = array( 'left join', 'user_id=wl_user' ); |
| 132 | + $fields[] = 'user_options'; |
| 133 | + } else { |
| 134 | + $tables[] = 'user_properties'; |
| 135 | + $joins['user_properties'] = array( |
124 | 136 | 'left join', |
125 | 137 | array( |
126 | 138 | 'up_user=wl_user', |
127 | 139 | 'up_property' => 'lqtnotifytalk', |
128 | 140 | ) |
129 | | - ) |
130 | | - ); |
131 | | - $fields = array( 'wl_user', 'ums_user', 'ums_read_timestamp', 'up_value' ); |
| 141 | + ); |
| 142 | + $fields[] = 'up_value'; |
| 143 | + } |
132 | 144 | |
133 | 145 | $dbr = wfGetDB( DB_SLAVE ); |
134 | 146 | return $dbr->select( $tables, $fields, self::getWhereClause( $t ), __METHOD__, array(), $joins ); |
— | — | @@ -256,30 +268,34 @@ |
257 | 269 | $dbr = wfGetDB( DB_SLAVE ); |
258 | 270 | $fields = array( $dbr->tableName( 'user' ) . '.*' ); |
259 | 271 | $join_conds = array(); |
260 | | - |
261 | | - $tableNameUserProperties = $dbr->tableName( 'user_properties' ); |
| 272 | + $oldPreferenceFormat = false; |
| 273 | + if ( version_compare( $wgVersion, '1.16', '<' ) ) { |
| 274 | + $oldPreferenceFormat = true; |
| 275 | + } else { |
| 276 | + $tableNameUserProperties = $dbr->tableName( 'user_properties' ); |
262 | 277 | |
263 | | - $tables[] = $tableNameUserProperties . ' as tc_prop'; |
264 | | - $fields[] = 'tc_prop.up_value as timecorrection'; |
| 278 | + $tables[] = $tableNameUserProperties . ' as tc_prop'; |
| 279 | + $fields[] = 'tc_prop.up_value as timecorrection'; |
265 | 280 | |
266 | | - $join_conds[$tableNameUserProperties . ' as tc_prop'] = array( |
267 | | - 'left join', |
268 | | - array( |
269 | | - 'tc_prop.up_user=user_id', |
270 | | - 'tc_prop.up_property' => 'timecorrection', |
271 | | - ) |
272 | | - ); |
| 281 | + $join_conds[$tableNameUserProperties . ' as tc_prop'] = array( |
| 282 | + 'left join', |
| 283 | + array( |
| 284 | + 'tc_prop.up_user=user_id', |
| 285 | + 'tc_prop.up_property' => 'timecorrection', |
| 286 | + ) |
| 287 | + ); |
273 | 288 | |
274 | | - $tables[] = $tableNameUserProperties . ' as l_prop'; |
275 | | - $fields[] = 'l_prop.up_value as language'; |
| 289 | + $tables[] = $tableNameUserProperties . ' as l_prop'; |
| 290 | + $fields[] = 'l_prop.up_value as language'; |
276 | 291 | |
277 | | - $join_conds[$tableNameUserProperties . ' as l_prop'] = array( |
278 | | - 'left join', |
279 | | - array( |
280 | | - 'l_prop.up_user=user_id', |
281 | | - 'l_prop.up_property' => 'language', |
282 | | - ) |
283 | | - ); |
| 292 | + $join_conds[$tableNameUserProperties . ' as l_prop'] = array( |
| 293 | + 'left join', |
| 294 | + array( |
| 295 | + 'l_prop.up_user=user_id', |
| 296 | + 'l_prop.up_property' => 'language', |
| 297 | + ) |
| 298 | + ); |
| 299 | + } |
284 | 300 | |
285 | 301 | $res = $dbr->select( |
286 | 302 | $tables, $fields, |
— | — | @@ -301,7 +317,9 @@ |
302 | 318 | while ( $row = $dbr->fetchObject( $res ) ) { |
303 | 319 | $u = User::newFromRow( $row ); |
304 | 320 | |
305 | | - if ( $row->language ) { |
| 321 | + if ( $oldPreferenceFormat ) { |
| 322 | + $langCode = $u->getOption( 'language' ); |
| 323 | + } elseif ( $row->language ) { |
306 | 324 | $langCode = $row->language; |
307 | 325 | } else { |
308 | 326 | global $wgLanguageCode; |
— | — | @@ -311,7 +329,11 @@ |
312 | 330 | $lang = Language::factory( $langCode ); |
313 | 331 | |
314 | 332 | // Adjust with time correction |
315 | | - $timeCorrection = $row->timecorrection; |
| 333 | + if ( $oldPreferenceFormat ) { |
| 334 | + $timeCorrection = $u->getOption( 'timecorrection' ); |
| 335 | + } else { |
| 336 | + $timeCorrection = $row->timecorrection; |
| 337 | + } |
316 | 338 | $adjustedTimestamp = $lang->userAdjust( $timestamp, $timeCorrection ); |
317 | 339 | |
318 | 340 | $date = $lang->date( $adjustedTimestamp ); |
— | — | @@ -324,7 +346,7 @@ |
325 | 347 | $msg = wfMsgReal( $msgName, $params, true /* use DB */, $langCode, |
326 | 348 | true /*transform*/ ); |
327 | 349 | |
328 | | - $to = new MailAddress( $u ); |
| 350 | + $to = new MailAddress( $u ); |
329 | 351 | $subject = wfMsgReal( $subjectMsg, array( $threadSubject ), true /* use DB */, |
330 | 352 | $langCode, true /* transform */ ); |
331 | 353 | |
— | — | @@ -370,9 +392,8 @@ |
371 | 393 | |
372 | 394 | $cval = $wgMemc->get( wfMemcKey( 'lqt-new-messages-count', $user->getId() ) ); |
373 | 395 | |
374 | | - if ( $cval ) { |
| 396 | + if ( $cval ) |
375 | 397 | return $cval; |
376 | | - } |
377 | 398 | |
378 | 399 | $dbr = wfGetDB( DB_SLAVE ); |
379 | 400 | |