MediaWiki r55632 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r55631‎ | r55632 (on ViewVC)‎ | r55633 >
Date:17:07, 27 August 2009
Author:catrope
Status:resolved (Comments)
Tags:
Comment:
API: Add optional API request logging to a file or UDP; intending to use this on the cluster to get some data about API usage and things like which queries are expensive
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 55631)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 55632)
@@ -3823,6 +3823,12 @@
 $wgAPIMaxUncachedDiffs = 1;
 
 /**
+ * Log file or URL (TCP or UDP) to log API requests to, or false to disable
+ * API request logging
+ */
+$wgAPIRequestLog = false;
+
+/**
  * Parser test suite files to be run by parserTests.php when no specific
  * filename is passed to it.
  *
Index: trunk/phase3/api.php
===================================================================
--- trunk/phase3/api.php	(revision 55631)
+++ trunk/phase3/api.php	(revision 55632)
@@ -38,6 +38,7 @@
 require (dirname(__FILE__) . '/includes/WebStart.php');
 
 wfProfileIn('api.php');
+$starttime = microtime( true );
 
 // URL safety checks
 //
@@ -118,9 +119,21 @@
 wfDoUpdates();
 
 // Log what the user did, for book-keeping purposes.
+$endtime = microtime( true );
 wfProfileOut('api.php');
 wfLogProfilingData();
 
+// Log the request
+if ( $wgAPIRequestLog ) {
+	wfErrorLog( implode( ',', array(
+			wfTimestamp( TS_MW ),
+			$endtime - $starttime,
+			wfGetIP(),
+			wfArrayToCGI( $wgRequest->getValues() )
+	) ) . "\n", $wgAPIRequestLog );
+	wfDebug( "Logged API request to $wgAPIRequestLog\n" );
+}
+
 // Shut down the database
 wfGetLBFactory()->shutdown();
 

Comments

#Comment by Brion VIBBER (Talk | contribs)   20:15, 27 August 2009

This'll include all GET and POST parameters including username and password for API logins, and edit tokens. Serious privacy breech. :)

#Comment by Werdna (Talk | contribs)   13:33, 28 August 2009

Does not block deployment, as it will be deactivated on Wikimedia.

#Comment by Catrope (Talk | contribs)   13:34, 28 August 2009

Fixed in r55643

Status & tagging log

  • 13:34, 28 August 2009 Catrope (Talk | contribs) changed the status of r55632 [removed: fixme added: resolved]
  • 20:15, 27 August 2009 Brion VIBBER (Talk | contribs) changed the status of r55632 [removed: new added: fixme]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox