mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-28 09:40:41 +00:00
Merge "Split up $wgEchoConfig"
This commit is contained in:
commit
c177fd5ec9
51
Echo.php
51
Echo.php
|
@ -560,30 +560,31 @@ $wgDefaultUserOptions['echo-subscriptions-web-article-linked'] = false;
|
||||||
$wgDefaultUserOptions['echo-subscriptions-web-mention-failure'] = false;
|
$wgDefaultUserOptions['echo-subscriptions-web-mention-failure'] = false;
|
||||||
$wgDefaultUserOptions['echo-subscriptions-web-mention-success'] = false;
|
$wgDefaultUserOptions['echo-subscriptions-web-mention-success'] = false;
|
||||||
|
|
||||||
|
// Echo cache version
|
||||||
|
$wgEchoCacheVersion = '1.12';
|
||||||
|
|
||||||
// Echo Configuration for EventLogging
|
// Echo Configuration for EventLogging
|
||||||
$wgEchoConfig = array(
|
$wgEchoEventLoggingVersion = '1.12';
|
||||||
'version' => '1.12',
|
$wgEchoEventLoggingSchemas = array(
|
||||||
'eventlogging' => array(
|
/**
|
||||||
/**
|
* Properties:
|
||||||
* Properties:
|
* - 'enabled': Whether it should be used
|
||||||
* - 'enabled': Whether it should be used
|
* - 'revision': revision id of the schema
|
||||||
* - 'revision': revision id of the schema
|
* - 'client': whether the schema is needed client-side
|
||||||
* - 'client': whether the schema is needed client-side
|
*/
|
||||||
*/
|
'Echo' => array(
|
||||||
'Echo' => array(
|
'enabled' => false,
|
||||||
'enabled' => false,
|
'revision' => 7731316,
|
||||||
'revision' => 7731316,
|
'client' => false,
|
||||||
'client' => false,
|
),
|
||||||
),
|
'EchoMail' => array(
|
||||||
'EchoMail' => array(
|
'enabled' => false,
|
||||||
'enabled' => false,
|
'revision' => 5467650,
|
||||||
'revision' => 5467650,
|
'client' => false,
|
||||||
'client' => false,
|
),
|
||||||
),
|
'EchoInteraction' => array(
|
||||||
'EchoInteraction' => array(
|
'enabled' => false,
|
||||||
'enabled' => false,
|
'revision' => 15823738,
|
||||||
'revision' => 15823738,
|
'client' => true,
|
||||||
'client' => true,
|
),
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
25
Hooks.php
25
Hooks.php
|
@ -10,7 +10,7 @@ class EchoHooks {
|
||||||
*/
|
*/
|
||||||
public static function initEchoExtension() {
|
public static function initEchoExtension() {
|
||||||
global $wgEchoNotifications, $wgEchoNotificationCategories, $wgEchoNotificationIcons,
|
global $wgEchoNotifications, $wgEchoNotificationCategories, $wgEchoNotificationIcons,
|
||||||
$wgEchoConfig, $wgEchoMentionStatusNotifications;
|
$wgEchoEventLoggingSchemas, $wgEchoMentionStatusNotifications;
|
||||||
|
|
||||||
// allow extensions to define their own event
|
// allow extensions to define their own event
|
||||||
Hooks::run( 'BeforeCreateEchoEvent', array( &$wgEchoNotifications, &$wgEchoNotificationCategories, &$wgEchoNotificationIcons ) );
|
Hooks::run( 'BeforeCreateEchoEvent', array( &$wgEchoNotifications, &$wgEchoNotificationCategories, &$wgEchoNotificationIcons ) );
|
||||||
|
@ -23,9 +23,9 @@ class EchoHooks {
|
||||||
|
|
||||||
// turn schema off if eventLogging is not enabled
|
// turn schema off if eventLogging is not enabled
|
||||||
if ( !class_exists( 'EventLogging' ) ) {
|
if ( !class_exists( 'EventLogging' ) ) {
|
||||||
foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) {
|
foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) {
|
||||||
if ( $property['enabled'] ) {
|
if ( $property['enabled'] ) {
|
||||||
$wgEchoConfig['eventlogging'][$schema]['enabled'] = false;
|
$wgEchoEventLoggingSchemas[$schema]['enabled'] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,8 @@ class EchoHooks {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function onEventLoggingRegisterSchemas( array &$schemas ) {
|
public static function onEventLoggingRegisterSchemas( array &$schemas ) {
|
||||||
global $wgEchoConfig;
|
global $wgEchoEventLoggingSchemas;
|
||||||
foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) {
|
foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) {
|
||||||
if ( $property['enabled'] && $property['client'] ) {
|
if ( $property['enabled'] && $property['client'] ) {
|
||||||
$schemas[$schema] = $property['revision'];
|
$schemas[$schema] = $property['revision'];
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ class EchoHooks {
|
||||||
* Handler for ResourceLoaderRegisterModules hook
|
* Handler for ResourceLoaderRegisterModules hook
|
||||||
*/
|
*/
|
||||||
public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) {
|
public static function onResourceLoaderRegisterModules( ResourceLoader &$resourceLoader ) {
|
||||||
global $wgEchoConfig;
|
global $wgEchoEventLoggingSchemas;
|
||||||
|
|
||||||
// ext.echo.logger is used by mobile notifications as well, so be sure not to add any
|
// ext.echo.logger is used by mobile notifications as well, so be sure not to add any
|
||||||
// dependencies that do not target mobile.
|
// dependencies that do not target mobile.
|
||||||
|
@ -114,7 +114,7 @@ class EchoHooks {
|
||||||
);
|
);
|
||||||
|
|
||||||
$hasSchemas = false;
|
$hasSchemas = false;
|
||||||
foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) {
|
foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) {
|
||||||
if ( $property['enabled'] && $property['client'] ) {
|
if ( $property['enabled'] && $property['client'] ) {
|
||||||
$definition['dependencies'][] = 'schema.' . $schema;
|
$definition['dependencies'][] = 'schema.' . $schema;
|
||||||
$hasSchemas = true;
|
$hasSchemas = true;
|
||||||
|
@ -1022,23 +1022,22 @@ class EchoHooks {
|
||||||
* @return bool true in all cases
|
* @return bool true in all cases
|
||||||
*/
|
*/
|
||||||
public static function makeGlobalVariablesScript( &$vars, OutputPage $outputPage ) {
|
public static function makeGlobalVariablesScript( &$vars, OutputPage $outputPage ) {
|
||||||
global $wgEchoConfig;
|
global $wgEchoEventLoggingSchemas, $wgEchoEventLoggingVersion;
|
||||||
$user = $outputPage->getUser();
|
$user = $outputPage->getUser();
|
||||||
|
|
||||||
// Provide info for the Overlay
|
// Provide info for the Overlay
|
||||||
|
|
||||||
if ( $user->isLoggedIn() ) {
|
if ( $user->isLoggedIn() ) {
|
||||||
$vars['wgEchoConfig'] = $wgEchoConfig;
|
$vars['wgEchoEventLoggingSchemas'] = $wgEchoEventLoggingSchemas;
|
||||||
|
$vars['wgEchoEventLoggingVersion'] = $wgEchoEventLoggingVersion;
|
||||||
} elseif (
|
} elseif (
|
||||||
$outputPage->getTitle()->equals( SpecialPage::getTitleFor( 'JavaScriptTest', 'qunit' ) ) ||
|
$outputPage->getTitle()->equals( SpecialPage::getTitleFor( 'JavaScriptTest', 'qunit' ) ) ||
|
||||||
// Also if running from /plain or /export
|
// Also if running from /plain or /export
|
||||||
$outputPage->getTitle()->isSubpageOf( SpecialPage::getTitleFor( 'JavaScriptTest', 'qunit' ) )
|
$outputPage->getTitle()->isSubpageOf( SpecialPage::getTitleFor( 'JavaScriptTest', 'qunit' ) )
|
||||||
) {
|
) {
|
||||||
// For testing purposes
|
// For testing purposes
|
||||||
$vars['wgEchoConfig'] = array(
|
$vars['wgEchoEventLoggingSchemas'] = array(
|
||||||
'eventlogging' => array(
|
'EchoInteraction' => array(),
|
||||||
'EchoInteraction' => array(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,15 +14,15 @@ class MWEchoEventLogging {
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*/
|
*/
|
||||||
protected static function logEvent( $schema, array $data ) {
|
protected static function logEvent( $schema, array $data ) {
|
||||||
global $wgEchoConfig;
|
global $wgEchoEventLoggingSchemas, $wgEchoEventLoggingVersion;
|
||||||
|
|
||||||
$schemaConfig = $wgEchoConfig['eventlogging'][$schema];
|
$schemaConfig = $wgEchoEventLoggingSchemas[$schema];
|
||||||
if ( !$schemaConfig['enabled'] ) {
|
if ( !$schemaConfig['enabled'] ) {
|
||||||
// If logging for this schema is disabled, it's a no-op.
|
// If logging for this schema is disabled, it's a no-op.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['version'] = $wgEchoConfig['version'];
|
$data['version'] = $wgEchoEventLoggingVersion;
|
||||||
|
|
||||||
EventLogging::logEvent( $schema, $schemaConfig['revision'], $data );
|
EventLogging::logEvent( $schema, $schemaConfig['revision'], $data );
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,8 +147,8 @@ class MWEchoNotifUser {
|
||||||
* Memcache key for talk notification
|
* Memcache key for talk notification
|
||||||
*/
|
*/
|
||||||
public function getTalkNotificationCacheKey() {
|
public function getTalkNotificationCacheKey() {
|
||||||
global $wgEchoConfig;
|
global $wgEchoCacheVersion;
|
||||||
return wfMemcKey( 'echo-new-talk-notification', $this->mUser->getId(), $wgEchoConfig['version'] );
|
return wfMemcKey( 'echo-new-talk-notification', $this->mUser->getId(), $wgEchoCacheVersion );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -654,9 +654,9 @@ class MWEchoNotifUser {
|
||||||
* @return string|false Memcached key, or false if one could not be generated
|
* @return string|false Memcached key, or false if one could not be generated
|
||||||
*/
|
*/
|
||||||
protected function getMemcKey( $key, $global = false ) {
|
protected function getMemcKey( $key, $global = false ) {
|
||||||
global $wgEchoConfig;
|
global $wgEchoCacheVersion;
|
||||||
if ( !$global ) {
|
if ( !$global ) {
|
||||||
return wfMemcKey( $key, $this->mUser->getId(), $wgEchoConfig['version'] );
|
return wfMemcKey( $key, $this->mUser->getId(), $wgEchoCacheVersion );
|
||||||
}
|
}
|
||||||
|
|
||||||
$lookup = CentralIdLookup::factory();
|
$lookup = CentralIdLookup::factory();
|
||||||
|
@ -664,7 +664,7 @@ class MWEchoNotifUser {
|
||||||
if ( !$globalId ) {
|
if ( !$globalId ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return wfGlobalCacheKey( $key, $globalId, $wgEchoConfig['version'] );
|
return wfGlobalCacheKey( $key, $globalId, $wgEchoCacheVersion );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
// This should usually already be loaded, but not always
|
// This should usually already be loaded, but not always
|
||||||
this.deferred = mw.loader.using( 'ext.eventLogging', function () {
|
this.deferred = mw.loader.using( 'ext.eventLogging', function () {
|
||||||
mw.eventLog.setDefaults( 'EchoInteraction', {
|
mw.eventLog.setDefaults( 'EchoInteraction', {
|
||||||
version: mw.config.get( 'wgEchoConfig' ).version,
|
version: mw.config.get( 'wgEchoEventLoggingVersion' ),
|
||||||
userId: +mw.config.get( 'wgUserId' ),
|
userId: +mw.config.get( 'wgUserId' ),
|
||||||
editCount: +mw.config.get( 'wgUserEditCount' )
|
editCount: +mw.config.get( 'wgUserEditCount' )
|
||||||
} );
|
} );
|
||||||
|
@ -41,8 +41,7 @@
|
||||||
* @property {boolean}
|
* @property {boolean}
|
||||||
*/
|
*/
|
||||||
mw.echo.Logger.static.clickThroughEnabled = OO.getProp(
|
mw.echo.Logger.static.clickThroughEnabled = OO.getProp(
|
||||||
mw.config.get( 'wgEchoConfig' ),
|
mw.config.get( 'wgEchoEventLoggingSchemas' ),
|
||||||
'eventlogging',
|
|
||||||
'EchoInteraction',
|
'EchoInteraction',
|
||||||
'enabled'
|
'enabled'
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue