r101385 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101384‎ | r101385 | r101386 >
Date:19:03, 31 October 2011
Author:petrb
Status:deferred
Tags:
Comment:
fixes to update of status, purging of pages doesn't work for some reason
Modified paths:
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php (modified) (history)
  • /trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OnlineStatusBar/OnlineStatusBar.body.php
@@ -128,6 +128,33 @@
129129 }
130130
131131 /**
 132+ * Purge page
 133+ * @return bool
 134+ *
 135+ */
 136+ public static function purge( $userName, $user ) {
 137+ if ( $user === null && $userName != null ) {
 138+ $old_user = User::newFromName( $userName );
 139+ }
 140+ else {
 141+ $old_user = $user;
 142+ }
 143+ // check if something weird didn't happen
 144+ if ( $old_user === false || $old_user == null ) {
 145+ return true;
 146+ }
 147+ if ( $old_user->getOption('OnlineStatusBar_active') ) {
 148+ if ( $old_user->getOption('OnlineStatusBar_autoupdate') == true ) {
 149+ $update = SquidUpdate::newSimplePurge( $user->getTalkPage() );
 150+ $update->doUpdate();
 151+ $update = SquidUpdate::newSimplePurge( $user->getUserPage() );
 152+ $update->doUpdate();
 153+ }
 154+ }
 155+ return true;
 156+ }
 157+
 158+ /**
132159 * Insert to the database
133160 * @return bool
134161 */
@@ -160,7 +187,7 @@
161188 }
162189 }
163190 // if user doesn't want to be tracked leave him aswel for privacy reasons
164 - if ( !$wgUser->getOption ( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled ) ) {
 191+ if ( $wgUser->isLoggedIn() && !$wgUser->getOption ( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled ) ) {
165192 return false;
166193 }
167194 if ( OnlineStatusBar::GetStatus( $wgUser, true ) == $wgOnlineStatusBarDefaultOffline ) {
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php
@@ -28,16 +28,20 @@
2929 * @return bool
3030 */
3131 public static function logout( &$user, &$inject_html, $old_name ) {
 32+ // this doesn't work yet
 33+ //OnlineStatusBar::purge( $old_name, null );
3234 OnlineStatusBar::DeleteStatus( $old_name );
3335 return true;
3436 }
3537
3638 /**
37 - * Called everytime when it's needed to update db
 39+ * Called everytime on login
3840 * @return bool
3941 */
4042 public static function updateStatus() {
41 - OnlineStatusBar::UpdateDb();
 43+ global $wgUser;
 44+ OnlineStatusBar::purge( "", $wgUser );
 45+ OnlineStatusBar::UpdateStatus();
4246 return true;
4347 }
4448

Status & tagging log