MediaWiki r41476 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r41475‎ | r41476 (on ViewVC)‎ | r41477 >
Date:13:23, 1 October 2008
Author:demon
Status:old
Tags:
Comment:
Make this fail a bit more gracefully on 1.11-1.12. Logging out isn't logged because the $oldUser param didn't exist yet, so we just skip it. Updated docs to reflect this.
Modified paths:

Diff [purge]

Index: trunk/extensions/StalkerLog/README
===================================================================
--- trunk/extensions/StalkerLog/README	(revision 41475)
+++ trunk/extensions/StalkerLog/README	(revision 41476)
@@ -14,3 +14,10 @@
 to a user via $wgGroupPermissions allows them to view the log. For
 example, if managers in an office need to see the log but employees
 shouldn't.
+
+== Notes ==
+The UserLogout hook was only modified to include the logging-out user
+as of MediaWiki v1.13. As such, the logout hook won't work properly
+on versions prior to that. The code fails gracefully and just doesn't
+record user logouts. Should work on 1.11 and 1.12 with only this
+problem. Before 1.11 isn't tested (and probably wont't work...)
\ No newline at end of file
Index: trunk/extensions/StalkerLog/StalkerLog.php
===================================================================
--- trunk/extensions/StalkerLog/StalkerLog.php	(revision 41475)
+++ trunk/extensions/StalkerLog/StalkerLog.php	(revision 41476)
@@ -26,18 +26,22 @@
 $wgAdditionalRights[] = 'stalkerlog-view-log';
 $wgGroupPermissions['*']['stalkerlog-view-log'] = true;
 $wgHooks['UserLoginComplete'][] = 'wfStalkerLogin';
-$wgHooks['UserLogoutComplete'][] = 'wfStalkerLogout';
 
 # Log setup
 $wgLogTypes[] = 'stalkerlog';
 $wgLogHeaders['stalkerlog'] = 'stalkerlog-log-text';
 $wgLogNames['stalkerlog'] = 'stalkerlog-log-type';
 $wgLogRestrictions['stalkerlog'] = 'stalkerlog-view-log';
-$wgLogActions['stalkerlog/login'] = 'stalkerlog-log-login'; 
-$wgLogActions['stalkerlog/logout'] = 'stalkerlog-log-logout';
+$wgLogActions['stalkerlog/login'] = 'stalkerlog-log-login';
 
+# 1.13+ setup only
+if ( version_compare( $wgVersion, '1.13', '>=' ) ) {
+	$wgHooks['UserLogoutComplete'][] = 'wfStalkerLogout';
+	$wgLogActions['stalkerlog/logout'] = 'stalkerlog-log-logout';
+}
+
 # Login hook function
-function wfStalkerLogin( &$user, &$inject_html ) {
+function wfStalkerLogin( &$user ) {
 	wfLoadExtensionMessages('stalkerlog');
 	$log = new LogPage( 'stalkerlog', false);
 	$log->addEntry( 'login', $user->getUserPage(), '', null, $user );

Status & tagging log

  • 15:32, 12 September 2011 Meno25 (Talk | contribs) changed the status of r41476 [removed: ok added: old]
  • 18:52, 2 April 2011 Happy-melon (Talk | contribs) changed the tags for r41476 [removed: stalkerlog]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox