r104554 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104553‎ | r104554 | r104555 >
Date:12:18, 29 November 2011
Author:petrb
Status:deferred
Tags:
Comment:
simplified, improved security and performance
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.status.php
@@ -123,7 +123,7 @@
124124 * Insert to the database
125125 * @return bool
126126 */
127 - public static function updateDb() {
 127+ public static function updateDB() {
128128 global $wgUser;
129129 // Skip users we don't track
130130 if ( OnlineStatusBar::isValid ( $wgUser ) != true ) {
@@ -160,18 +160,12 @@
161161 public static function updateStatus() {
162162 global $wgUser, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarTrackIpUsers, $wgOnlineStatusBarDefaultEnabled;
163163 // if anon users are not tracked and user is anon leave it
164 - if ( !$wgOnlineStatusBarTrackIpUsers ) {
165 - if ( !$wgUser->isLoggedIn() ) {
166 - return false;
167 - }
168 - }
169 - // if user doesn't want to be tracked leave it as well for privacy reasons
170 - if ( $wgUser->isLoggedIn() && !$wgUser->getOption ( 'OnlineStatusBar_active', $wgOnlineStatusBarDefaultEnabled ) ) {
 164+ if (!OnlineStatusBar::isValid( $wgUser )) {
171165 return false;
172166 }
173167 $user_status = self::getStatus( $wgUser, true );
174168 if ( $user_status == $wgOnlineStatusBarDefaultOffline ) {
175 - self::updateDb();
 169+ self::updateDB();
176170 return true;
177171 }
178172
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php
@@ -1,4 +1,8 @@
22 <?php
 3+if ( !defined( 'MEDIAWIKI' ) ) {
 4+ echo "This is a part of mediawiki and can't be started separately";
 5+ die();
 6+}
37
48 /**
59 * Hooks for OnlineStatusBar
@@ -43,10 +47,12 @@
4448 */
4549 public static function updateStatus() {
4650 global $wgUser;
47 - // Purge user page (optional)
48 - OnlineStatusBar::purge( $wgUser );
49 - // Update status
50 - OnlineStatusBar_StatusCheck::updateStatus();
 51+ if ( OnlineStatusBar::isValid( $wgUser ) {
 52+ // Purge user page (optional)
 53+ OnlineStatusBar::purge( $wgUser );
 54+ // Update status
 55+ OnlineStatusBar_StatusCheck::updateStatus();
 56+ }
5157 return true;
5258 }
5359
@@ -58,8 +64,6 @@
5965 * @return bool
6066 */
6167 public static function renderBar( &$article, &$outputDone, &$pcache ) {
62 - $context = $article->getContext();
63 -
6468 // Update status of all users who wants to be tracked
6569 OnlineStatusBar_StatusCheck::updateStatus();
6670
@@ -93,6 +97,7 @@
9498 $image = OnlineStatusBar::getImageHtml( $status, $modetext );
9599 $text = wfMessage( 'onlinestatusbar-line', $user->getName() )
96100 ->rawParams( $image )->params( $modetext )->escaped();
 101+ $context = $article->getContext();
97102 $context->getOutput()->addHtml( OnlineStatusBar::getStatusBarHtml( $text ) );
98103
99104 return true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r104555r104554 missing bracketpetrb12:20, 29 November 2011

Status & tagging log