Fix ApiQueryLogEvents::addLogParams for unknown types using the new format
authorMarius Hoch <hoo@online.de>
Tue, 18 Dec 2012 18:02:08 +0000 (19:02 +0100)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 20 Dec 2012 13:04:33 +0000 (13:04 +0000)
Fixed ApiQueryLogEvents::addLogParams for unknown (probably extension)
log types which use the new log format (with keys like 4:foo:paramname).
Until now such keys we're directly put into the XML output resulting
in invalid XML (see bug 43221, which will be fixed by this). To prevent
this we just remove everything except the plain parameter name and use that
as key for the output.

Change-Id: I1a3c7ac624eb575b879d068d47d3a13c9972b1a1

includes/api/ApiQueryLogEvents.php

index 1b65168..9ef2c22 100644 (file)
@@ -267,9 +267,19 @@ class ApiQueryLogEvents extends ApiQueryBase {
                                break;
                }
                if ( !is_null( $params ) ) {
-                       $result->setIndexedTagName( $params, 'param' );
-                       $result->setIndexedTagName_recursive( $params, 'param' );
-                       $vals = array_merge( $vals, $params );
+                       $logParams = array();
+                       // Keys like "4::paramname" can't be used for output so we change them to "paramname"
+                       foreach ( $params as $key => $value ) {
+                               if ( strpos( $key, ':' ) === false ) {
+                                       $logParams[$key] = $value;
+                                       continue;
+                               }
+                               $logParam = explode( ':', $key, 3 );
+                               $logParams[$logParam[2]] = $value;
+                       }
+                       $result->setIndexedTagName( $logParams, 'param' );
+                       $result->setIndexedTagName_recursive( $logParams, 'param' );
+                       $vals = array_merge( $vals, $logParams );
                }
                return $vals;
        }