Last modified: 2014-02-26 12:55:14 UTC
mw.eventLog.logEvent( 'CommunityPortal', { } ); will log with _ok: true despite obvious schema violations and the console warning (if ?debug=1): Missing "token" property This happens because the $.each( properties, ...) iterator in validate() in modules/ext.eventLogging.core.js does not propagate a return false from a property test; it halts iteration but the validate() function continues on and returns true. I'm puzzled that the qunit tests of validate in <http://localhost/wiki/index.php/Special:JavaScriptTest/qunit?module=ext.EventLogging> all pass. They, e.g. assert.throws(... /Missing/), and even though validate() doesn't throw errors any more, they all pass. BTW, it would be nice if the mw.eventLog.schemas.<Name>.logged included the system fields such as _ok.
Gerrit change #41826 helps. I think the self.warn() warnings in validate() must trigger an exception in qunit testing, so the tests pass even though in normal operation validate() doesn't cause an exception. Seems like a qunit misfeature.
Ori wrote some custom test setup code (https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/EventLogging.git;a=blob;f=tests/ext.eventLogging.tests.js;h=87ac1406cd1592a8351bcb22250fee338a2d8b83;hb=HEAD#l26) to convert warn to Errors. Like most monkey patching, it's pretty confusing until you find the code.
[moving from MediaWiki extensions to Analytics product - see bug 61946]