mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 01:30:15 +00:00
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:
parent
b3934bfd16
commit
fd72ce7606
17
Hooks.php
17
Hooks.php
|
@ -12,12 +12,21 @@ class EchoHooks {
|
||||||
*/
|
*/
|
||||||
public static function initEchoExtension() {
|
public static function initEchoExtension() {
|
||||||
global $wgEchoBackend, $wgEchoBackendName, $wgEchoNotifications,
|
global $wgEchoBackend, $wgEchoBackendName, $wgEchoNotifications,
|
||||||
$wgEchoNotificationCategories;
|
$wgEchoNotificationCategories, $wgEchoConfig;
|
||||||
|
|
||||||
// allow extensions to define their own event
|
// allow extensions to define their own event
|
||||||
wfRunHooks( 'BeforeCreateEchoEvent', array( &$wgEchoNotifications, &$wgEchoNotificationCategories ) );
|
wfRunHooks( 'BeforeCreateEchoEvent', array( &$wgEchoNotifications, &$wgEchoNotificationCategories ) );
|
||||||
|
|
||||||
$wgEchoBackend = MWEchoBackend::factory( $wgEchoBackendName );
|
$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 ) {
|
public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) {
|
||||||
global $wgResourceModules, $wgEchoConfig;
|
global $wgResourceModules, $wgEchoConfig;
|
||||||
|
|
||||||
$eventLogEnabled = function_exists( 'efLogServerSideEvent' );
|
|
||||||
|
|
||||||
foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) {
|
foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) {
|
||||||
if ( $eventLogEnabled && $property['enabled'] ) {
|
if ( $property['enabled'] ) {
|
||||||
$wgResourceModules[ 'schema.' . $schema ] = array(
|
$wgResourceModules[ 'schema.' . $schema ] = array(
|
||||||
'class' => 'ResourceLoaderSchemaModule',
|
'class' => 'ResourceLoaderSchemaModule',
|
||||||
'schema' => $schema,
|
'schema' => $schema,
|
||||||
'revision' => $property['revision'],
|
'revision' => $property['revision'],
|
||||||
);
|
);
|
||||||
$wgResourceModules['ext.echo.base']['dependencies'][] = 'schema.' . $schema;
|
$wgResourceModules['ext.echo.base']['dependencies'][] = 'schema.' . $schema;
|
||||||
} else {
|
|
||||||
$wgEchoConfig['eventlogging'][$schema]['enabled'] = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue