r101498 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101497‎ | r101498 | r101499 >
Date:16:36, 1 November 2011
Author:petrb
Status:deferred
Tags:
Comment:
clean up
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
@@ -32,7 +32,7 @@
3333 * @return string
3434 */
3535 public static function GetImageHtml( $mode ) {
36 - global $wgExtensionAssetsPath, $wgOnlineStatusBarIcon, $wgOnlineStatusBarModes;
 36+ global $wgExtensionAssetsPath, $wgOnlineStatusBarIcon;
3737 $icon = "$wgExtensionAssetsPath/OnlineStatusBar/{$wgOnlineStatusBarIcon[$mode]}";
3838 return Html::element( 'img', array( 'src' => $icon ) );
3939 }
@@ -46,19 +46,22 @@
4747 */
4848 public static function getAnonFromTitle( Title $title ) {
4949 global $wgOnlineStatusBarTrackIpUsers;
 50+ // if user is anon and we don't track them stop
5051 if ( $wgOnlineStatusBarTrackIpUsers == false ) {
5152 return false;
5253 }
5354
 55+ // checks ns
5456 if ( $title->getNamespace() != NS_USER && $title->getNamespace() != NS_USER_TALK ) {
5557 return false;
5658 }
5759
 60+ // we need to create temporary user object
5861 $user = User::newFromId( 0 );
5962 $user->setName( $title->getBaseText() );
6063
6164 // Check if something wrong didn't happen
62 - if ( $user === false ) {
 65+ if ( !($user instanceof User) ) {
6366 return false;
6467 }
6568
@@ -102,7 +105,7 @@
103106 // remove old entries
104107 if ( $update )
105108 {
106 - self::DeleteOld();
 109+ self::deleteOld();
107110 }
108111
109112 // instead of delete every time just select the records which are not that old
@@ -161,10 +164,10 @@
162165 * Insert to the database
163166 * @return bool
164167 */
165 - public static function UpdateDb() {
166 - global $wgUser, $wgOnlineStatusBarDefaultOnline;
 168+ public static function updateDb() {
 169+ global $wgUser;
167170 // Skip users we don't track
168 - if ( self::IsValid ( $wgUser ) != true ) {
 171+ if ( self::isValid ( $wgUser ) != true ) {
169172 return false;
170173 }
171174 // If we track them, let's insert it to the table
@@ -181,7 +184,7 @@
182185 * Update status of user
183186 * @return bool
184187 */
185 - public static function UpdateStatus() {
 188+ public static function updateStatus() {
186189 global $wgUser, $wgOnlineStatusBarDefaultOffline, $wgOnlineStatusBarTrackIpUsers, $wgOnlineStatusBarDefaultEnabled;
187190 // if anon users are not tracked and user is anon leave it
188191 if ( !$wgOnlineStatusBarTrackIpUsers ) {
@@ -193,8 +196,8 @@
194197 if ( $wgUser->isLoggedIn() && !$wgUser->getOption ( "OnlineStatusBar_active", $wgOnlineStatusBarDefaultEnabled ) ) {
195198 return false;
196199 }
197 - if ( OnlineStatusBar::GetStatus( $wgUser ) == $wgOnlineStatusBarDefaultOffline ) {
198 - OnlineStatusBar::UpdateDb();
 200+ if ( OnlineStatusBar::getStatus( $wgUser ) == $wgOnlineStatusBarDefaultOffline ) {
 201+ OnlineStatusBar::updateDb();
199202 return true;
200203 }
201204
@@ -221,7 +224,7 @@
222225 * Delete old records from the table, this function is called frequently too keep it as small as possible
223226 * @return int
224227 */
225 - public static function DeleteOld() {
 228+ public static function deleteOld() {
226229 $dbw = wfGetDB( DB_MASTER );
227230 // calculate time and convert it back to mediawiki format
228231 $time = self::getTimeoutDate();
@@ -253,7 +256,7 @@
254257 * @param $userName string
255258 * @return bool
256259 */
257 - static function DeleteStatus( $userName ) {
 260+ static function deleteStatus( $userName ) {
258261 $dbw = wfGetDB( DB_MASTER );
259262 $dbw->delete( 'online_status', array( 'username' => $userName ), __METHOD__ ); // delete user
260263 return true;
Index: trunk/extensions/OnlineStatusBar/OnlineStatusBarHooks.php
@@ -29,7 +29,7 @@
3030 */
3131 public static function logout( &$user, &$inject_html, $old_name ) {
3232 OnlineStatusBar::purge( $old_name );
33 - OnlineStatusBar::DeleteStatus( $old_name );
 33+ OnlineStatusBar::deleteStatus( $old_name );
3434 return true;
3535 }
3636
@@ -40,7 +40,7 @@
4141 public static function updateStatus() {
4242 global $wgUser;
4343 OnlineStatusBar::purge( $wgUser );
44 - OnlineStatusBar::UpdateStatus();
 44+ OnlineStatusBar::updateStatus();
4545 return true;
4646 }
4747
@@ -54,7 +54,7 @@
5555 public static function renderBar( &$article, &$outputDone, &$pcache ) {
5656 $context = $article->getContext();
5757
58 - OnlineStatusBar::UpdateStatus();
 58+ OnlineStatusBar::updateStatus();
5959 $result = OnlineStatusBar::getUserInfoFromTitle( $article->getTitle() );
6060 if ( $result === false && User::isIP ( $article->getTitle()->getBaseText() ) ) {
6161 $result = OnlineStatusBar::getAnonFromTitle( $article->getTitle() );

Status & tagging log