mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +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-success'] = false;
|
||||
|
||||
// Echo cache version
|
||||
$wgEchoCacheVersion = '1.12';
|
||||
|
||||
// Echo Configuration for EventLogging
|
||||
$wgEchoConfig = array(
|
||||
'version' => '1.12',
|
||||
'eventlogging' => array(
|
||||
/**
|
||||
* Properties:
|
||||
* - 'enabled': Whether it should be used
|
||||
* - 'revision': revision id of the schema
|
||||
* - 'client': whether the schema is needed client-side
|
||||
*/
|
||||
'Echo' => array(
|
||||
'enabled' => false,
|
||||
'revision' => 7731316,
|
||||
'client' => false,
|
||||
),
|
||||
'EchoMail' => array(
|
||||
'enabled' => false,
|
||||
'revision' => 5467650,
|
||||
'client' => false,
|
||||
),
|
||||
'EchoInteraction' => array(
|
||||
'enabled' => false,
|
||||
'revision' => 15823738,
|
||||
'client' => true,
|
||||
),
|
||||
)
|
||||
$wgEchoEventLoggingVersion = '1.12';
|
||||
$wgEchoEventLoggingSchemas = array(
|
||||
/**
|
||||
* Properties:
|
||||
* - 'enabled': Whether it should be used
|
||||
* - 'revision': revision id of the schema
|
||||
* - 'client': whether the schema is needed client-side
|
||||
*/
|
||||
'Echo' => array(
|
||||
'enabled' => false,
|
||||
'revision' => 7731316,
|
||||
'client' => false,
|
||||
),
|
||||
'EchoMail' => array(
|
||||
'enabled' => false,
|
||||
'revision' => 5467650,
|
||||
'client' => false,
|
||||
),
|
||||
'EchoInteraction' => array(
|
||||
'enabled' => false,
|
||||
'revision' => 15823738,
|
||||
'client' => true,
|
||||
),
|
||||
);
|
||||
|
|
25
Hooks.php
25
Hooks.php
|
@ -10,7 +10,7 @@ class EchoHooks {
|
|||
*/
|
||||
public static function initEchoExtension() {
|
||||
global $wgEchoNotifications, $wgEchoNotificationCategories, $wgEchoNotificationIcons,
|
||||
$wgEchoConfig, $wgEchoMentionStatusNotifications;
|
||||
$wgEchoEventLoggingSchemas, $wgEchoMentionStatusNotifications;
|
||||
|
||||
// allow extensions to define their own event
|
||||
Hooks::run( 'BeforeCreateEchoEvent', array( &$wgEchoNotifications, &$wgEchoNotificationCategories, &$wgEchoNotificationIcons ) );
|
||||
|
@ -23,9 +23,9 @@ class EchoHooks {
|
|||
|
||||
// turn schema off if eventLogging is not enabled
|
||||
if ( !class_exists( 'EventLogging' ) ) {
|
||||
foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) {
|
||||
foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) {
|
||||
if ( $property['enabled'] ) {
|
||||
$wgEchoConfig['eventlogging'][$schema]['enabled'] = false;
|
||||
$wgEchoEventLoggingSchemas[$schema]['enabled'] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ class EchoHooks {
|
|||
}
|
||||
|
||||
public static function onEventLoggingRegisterSchemas( array &$schemas ) {
|
||||
global $wgEchoConfig;
|
||||
foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) {
|
||||
global $wgEchoEventLoggingSchemas;
|
||||
foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) {
|
||||
if ( $property['enabled'] && $property['client'] ) {
|
||||
$schemas[$schema] = $property['revision'];
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ class EchoHooks {
|
|||
* Handler for ResourceLoaderRegisterModules hook
|
||||
*/
|
||||
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
|
||||
// dependencies that do not target mobile.
|
||||
|
@ -114,7 +114,7 @@ class EchoHooks {
|
|||
);
|
||||
|
||||
$hasSchemas = false;
|
||||
foreach ( $wgEchoConfig['eventlogging'] as $schema => $property ) {
|
||||
foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) {
|
||||
if ( $property['enabled'] && $property['client'] ) {
|
||||
$definition['dependencies'][] = 'schema.' . $schema;
|
||||
$hasSchemas = true;
|
||||
|
@ -1022,23 +1022,22 @@ class EchoHooks {
|
|||
* @return bool true in all cases
|
||||
*/
|
||||
public static function makeGlobalVariablesScript( &$vars, OutputPage $outputPage ) {
|
||||
global $wgEchoConfig;
|
||||
global $wgEchoEventLoggingSchemas, $wgEchoEventLoggingVersion;
|
||||
$user = $outputPage->getUser();
|
||||
|
||||
// Provide info for the Overlay
|
||||
|
||||
if ( $user->isLoggedIn() ) {
|
||||
$vars['wgEchoConfig'] = $wgEchoConfig;
|
||||
$vars['wgEchoEventLoggingSchemas'] = $wgEchoEventLoggingSchemas;
|
||||
$vars['wgEchoEventLoggingVersion'] = $wgEchoEventLoggingVersion;
|
||||
} elseif (
|
||||
$outputPage->getTitle()->equals( SpecialPage::getTitleFor( 'JavaScriptTest', 'qunit' ) ) ||
|
||||
// Also if running from /plain or /export
|
||||
$outputPage->getTitle()->isSubpageOf( SpecialPage::getTitleFor( 'JavaScriptTest', 'qunit' ) )
|
||||
) {
|
||||
// For testing purposes
|
||||
$vars['wgEchoConfig'] = array(
|
||||
'eventlogging' => array(
|
||||
'EchoInteraction' => array(),
|
||||
),
|
||||
$vars['wgEchoEventLoggingSchemas'] = array(
|
||||
'EchoInteraction' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,15 +14,15 @@ class MWEchoEventLogging {
|
|||
* @param 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 logging for this schema is disabled, it's a no-op.
|
||||
return;
|
||||
}
|
||||
|
||||
$data['version'] = $wgEchoConfig['version'];
|
||||
$data['version'] = $wgEchoEventLoggingVersion;
|
||||
|
||||
EventLogging::logEvent( $schema, $schemaConfig['revision'], $data );
|
||||
}
|
||||
|
|
|
@ -147,8 +147,8 @@ class MWEchoNotifUser {
|
|||
* Memcache key for talk notification
|
||||
*/
|
||||
public function getTalkNotificationCacheKey() {
|
||||
global $wgEchoConfig;
|
||||
return wfMemcKey( 'echo-new-talk-notification', $this->mUser->getId(), $wgEchoConfig['version'] );
|
||||
global $wgEchoCacheVersion;
|
||||
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
|
||||
*/
|
||||
protected function getMemcKey( $key, $global = false ) {
|
||||
global $wgEchoConfig;
|
||||
global $wgEchoCacheVersion;
|
||||
if ( !$global ) {
|
||||
return wfMemcKey( $key, $this->mUser->getId(), $wgEchoConfig['version'] );
|
||||
return wfMemcKey( $key, $this->mUser->getId(), $wgEchoCacheVersion );
|
||||
}
|
||||
|
||||
$lookup = CentralIdLookup::factory();
|
||||
|
@ -664,7 +664,7 @@ class MWEchoNotifUser {
|
|||
if ( !$globalId ) {
|
||||
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.deferred = mw.loader.using( 'ext.eventLogging', function () {
|
||||
mw.eventLog.setDefaults( 'EchoInteraction', {
|
||||
version: mw.config.get( 'wgEchoConfig' ).version,
|
||||
version: mw.config.get( 'wgEchoEventLoggingVersion' ),
|
||||
userId: +mw.config.get( 'wgUserId' ),
|
||||
editCount: +mw.config.get( 'wgUserEditCount' )
|
||||
} );
|
||||
|
@ -41,8 +41,7 @@
|
|||
* @property {boolean}
|
||||
*/
|
||||
mw.echo.Logger.static.clickThroughEnabled = OO.getProp(
|
||||
mw.config.get( 'wgEchoConfig' ),
|
||||
'eventlogging',
|
||||
mw.config.get( 'wgEchoEventLoggingSchemas' ),
|
||||
'EchoInteraction',
|
||||
'enabled'
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue