Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php |
— | — | @@ -68,11 +68,11 @@ |
69 | 69 | global $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarDefaultOnline; |
70 | 70 | // instead of delete every time just select the records which are not that old |
71 | 71 | if ( !$delayed_check ) { |
72 | | - $t_time = OnlineStatusBar::getTimeoutDate(); |
73 | 72 | // first try to use cache |
74 | 73 | $result = self::getCache( $user->getName(), ONLINESTATUSBAR_NORMAL_CACHE ); |
75 | 74 | |
76 | 75 | if ( $result == '' ) { |
| 76 | + $t_time = OnlineStatusBar::getTimeoutDate(); |
77 | 77 | $dbr = wfGetDB( DB_SLAVE ); |
78 | 78 | $result = $dbr->selectField( 'online_status', 'timestamp', array( 'username' => $user->getName(), |
79 | 79 | 'timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $t_time ) ) ), |
— | — | @@ -81,6 +81,7 @@ |
82 | 82 | self::setCache( $user->getName(), $result, ONLINESTATUSBAR_NORMAL_CACHE ); |
83 | 83 | } |
84 | 84 | } else { |
| 85 | + // checking only if we need to do write or not |
85 | 86 | $result = self::getCache( $user->getName(), ONLINESTATUSBAR_DELAYED_CACHE ); |
86 | 87 | if ( $result == '' ) { |
87 | 88 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -99,6 +100,7 @@ |
100 | 101 | if ( $user->isLoggedIn() ) { |
101 | 102 | $status = $user->getOption( 'OnlineStatusBar_status', $wgOnlineStatusBarDefaultOnline ); |
102 | 103 | if ( $delayed_check ) { |
| 104 | + // check if it's old or not |
103 | 105 | if ( $result < wfTimestamp( TS_MW, $w_time ) ) { |
104 | 106 | $status = 'write'; |
105 | 107 | } |
— | — | @@ -109,6 +111,11 @@ |
110 | 112 | } |
111 | 113 | } else { |
112 | 114 | $status = $wgOnlineStatusBarDefaultOnline; |
| 115 | + if ( $delayed_check ) { |
| 116 | + if ( $result < wfTimestamp( TS_MW, $w_time ) ) { |
| 117 | + $status = 'write'; |
| 118 | + } |
| 119 | + } |
113 | 120 | } |
114 | 121 | } |
115 | 122 | |