EtcdConfig: Remove YAML from available 'encoding' options

This appears impossible to use because the request is always made
with `Content-Type: application/json`.

* It seems unreasonable for an Etcd server to not support JSON.
* It seems unreasonable for an Etcd server to respond with YAML
  to a JSON request.
* It seems unlikely that anyone would prefer YAML over JSON for
  the automated encoding and decoding of fully automated inter-service
  communication.

Change-Id: I290e03e17d547c3dc675820bb024c940e02e097a
This commit is contained in:
Timo Tijhof 2022-03-06 01:21:19 +00:00 committed by Reedy
parent aebeccc01b
commit 8a0afc31b1
3 changed files with 6 additions and 12 deletions

View file

@ -266,6 +266,8 @@ because of Phabricator reports.
User::removeWatch()
* ParserOptions::setTidy() that had no effect and was deprecated since 1.35
has been removed.
* The "YAML" encoding option of EtcdConfig, has been removed without
deprecation.
* The constant ApiBase::PARAM_VALUE_LINKS, deprecated since 1.35 has been
removed.
* UserLoadOptions, UserSaveOptions and UserResetAllOptions hooks, deprecated

View file

@ -116,7 +116,6 @@
"ext-readline": "Enable CLI history and autocomplete, e.g. for eval.php and other REPLs.",
"ext-sockets": "Enable CLI concurrent processing, e.g. for rebuildLocalisationCache.php.",
"ext-wikidiff2": "Faster text difference engine.",
"ext-yaml": "Enable YAML type for EtcdConfig backend.",
"ext-zlib": "Enable use of GZIP compression, e.g. for SqlBagOStuff (ParserCache), $wgCompressRevisions, or $wgUseFileCache.",
"monolog/monolog": "Enable use of MonologSpi ($wgMWLoggerDefaultSpi).",
"nmred/kafka-php": "Enable use of KafkaHandler (MonologSpi), or EventRelayerKafka ($wgEventRelayerConfig)."

View file

@ -51,8 +51,6 @@ class EtcdConfig implements Config, LoggerAwareInterface {
private $protocol;
/** @var string */
private $directory;
/** @var string */
private $encoding;
/** @var int */
private $baseCacheTTL;
/** @var int */
@ -67,7 +65,6 @@ class EtcdConfig implements Config, LoggerAwareInterface {
* - service: service name used in SRV discovery. Defaults to 'etcd'. [optional]
* - port: custom host port [optional]
* - protocol: one of ("http", "https"). Defaults to http. [optional]
* - encoding: one of ("JSON", "YAML"). Defaults to JSON. [optional]
* - cache: BagOStuff instance or ObjectFactory spec thereof for a server cache.
* The cache will also be used as a fallback if etcd is down. [optional]
* - cacheTTL: logical cache TTL in seconds [optional]
@ -79,7 +76,6 @@ class EtcdConfig implements Config, LoggerAwareInterface {
'service' => 'etcd',
'port' => null,
'protocol' => 'http',
'encoding' => 'JSON',
'cacheTTL' => 10,
'skewTTL' => 1,
'timeout' => 2
@ -90,7 +86,6 @@ class EtcdConfig implements Config, LoggerAwareInterface {
$this->port = $params['port'];
$this->protocol = $params['protocol'];
$this->directory = trim( $params['directory'], '/' );
$this->encoding = $params['encoding'];
$this->skewCacheTTL = $params['skewTTL'];
$this->baseCacheTTL = max( $params['cacheTTL'] - $this->skewCacheTTL, 0 );
$this->timeout = $params['timeout'];
@ -274,7 +269,9 @@ class EtcdConfig implements Config, LoggerAwareInterface {
list( $rcode, $rdesc, /* $rhdrs */, $rbody, $rerr ) = $this->http->run( [
'method' => 'GET',
'url' => "{$this->protocol}://{$host}/v2/keys/{$this->directory}/?recursive=true",
'headers' => [ 'content-type' => 'application/json' ]
'headers' => [
'content-type' => 'application/json',
]
] );
$response = [ 'config' => null, 'error' => null, 'retry' => false, 'modifiedIndex' => 0 ];
@ -359,10 +356,6 @@ class EtcdConfig implements Config, LoggerAwareInterface {
* @return mixed
*/
private function unserialize( $string ) {
if ( $this->encoding === 'YAML' ) {
return yaml_parse( $string );
} else {
return json_decode( $string, true );
}
return json_decode( $string, true );
}
}