mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-30 19:16:39 +00:00
2f1e2f80e0
For logged out users we store their test state and an anonymous identifier in local storage. So long as the test is enabled, we include these in any logging that occurs. This is done entirely client-side, to avoid any cache issues caused by state depending on cookies from PHP for logged out users. Bug: T291307 Change-Id: Ib39e2f2146cdfdac9df5690ee3de75718f0f2731
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* DiscussionTools resource loader hooks
|
|
*
|
|
* @file
|
|
* @ingroup Extensions
|
|
* @license MIT
|
|
*/
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Hooks;
|
|
|
|
use Config;
|
|
use ConfigFactory;
|
|
use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
|
|
|
|
class ResourceLoaderHooks implements
|
|
ResourceLoaderGetConfigVarsHook
|
|
{
|
|
/** @var ConfigFactory */
|
|
private $configFactory;
|
|
|
|
/**
|
|
* @param ConfigFactory $configFactory
|
|
*/
|
|
public function __construct(
|
|
ConfigFactory $configFactory
|
|
) {
|
|
$this->configFactory = $configFactory;
|
|
}
|
|
|
|
/**
|
|
* Set static (not request-specific) JS configuration variables
|
|
*
|
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
|
|
* @param array &$vars Array of variables to be added into the output of the startup module
|
|
* @param string $skin Current skin name to restrict config variables to a certain skin
|
|
* @param Config $config
|
|
*/
|
|
public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
|
|
$dtConfig = $this->configFactory->makeConfig( 'discussiontools' );
|
|
|
|
$vars['wgDTSchemaEditAttemptStepSamplingRate'] =
|
|
$dtConfig->get( 'DTSchemaEditAttemptStepSamplingRate' );
|
|
$vars['wgDTSchemaEditAttemptStepOversample'] =
|
|
$dtConfig->get( 'DTSchemaEditAttemptStepOversample' );
|
|
|
|
$abtest = $dtConfig->get( 'DiscussionToolsABTest' );
|
|
if ( $abtest ) {
|
|
$vars['wgDiscussionToolsABTest'] = $abtest;
|
|
}
|
|
}
|
|
|
|
}
|