Fix eventlogging schema check logic

ResourceLoaderRegisterModules Hook is triggerd on HTML generation, which happens after POST action.  We should move the logic of checking if a schema is enabled out of this hook.

Change-Id: Ic5696aeca378d13d04ce901ce56a2d0e8a9ab802
This commit is contained in:
bsitu 2013-03-06 13:22:17 -08:00
parent b3934bfd16
commit fd72ce7606

View file

@ -12,12 +12,21 @@ class EchoHooks {
*/
public static function initEchoExtension() {
global $wgEchoBackend, $wgEchoBackendName, $wgEchoNotifications,
$wgEchoNotificationCategories;
$wgEchoNotificationCategories, $wgEchoConfig;
// allow extensions to define their own event
wfRunHooks( 'BeforeCreateEchoEvent', array( &$wgEchoNotifications, &$wgEchoNotificationCategories ) );
$wgEchoBackend = MWEchoBackend::factory( $wgEchoBackendName );
// turn schema off if eventLogging is not enabled
if ( !function_exists( 'efLogServerSideEvent' ) ) {
foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) {
if ( $property['enabled'] ) {
$wgEchoConfig['eventlogging'][$schema]['enabled'] = false;
}
}
}
}
/**
@ -26,18 +35,14 @@ class EchoHooks {
public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) {
global $wgResourceModules, $wgEchoConfig;
$eventLogEnabled = function_exists( 'efLogServerSideEvent' );
foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) {
if ( $eventLogEnabled && $property['enabled'] ) {
if ( $property['enabled'] ) {
$wgResourceModules[ 'schema.' . $schema ] = array(
'class' => 'ResourceLoaderSchemaModule',
'schema' => $schema,
'revision' => $property['revision'],
);
$wgResourceModules['ext.echo.base']['dependencies'][] = 'schema.' . $schema;
} else {
$wgEchoConfig['eventlogging'][$schema]['enabled'] = false;
}
}