From: Timo Tijhof Date: Mon, 24 Jul 2017 19:48:38 +0000 (-0700) Subject: config: Fix invalid EtcdConfig return value after JSON parse error X-Git-Tag: 1.31.0-rc.0~2614^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=63a6926dfd81826975a997ee4c30a88b7cb3b588;p=lhc%2Fweb%2Fwiklou.git config: Fix invalid EtcdConfig return value after JSON parse error Follows-up 1f2daa913244, 9b459d29e0, 110a21ea18. Bug: T156924 Change-Id: I79b7e11b32e5be46c8ebdfb5c937e38e46301c0e --- diff --git a/includes/config/EtcdConfig.php b/includes/config/EtcdConfig.php index c57eba7ceb..6605c38d5a 100644 --- a/includes/config/EtcdConfig.php +++ b/includes/config/EtcdConfig.php @@ -243,7 +243,7 @@ class EtcdConfig implements Config, LoggerAwareInterface { $info = json_decode( $rbody, true ); if ( $info === null || !isset( $info['node']['nodes'] ) ) { - return [ null, $rcode, "Unexpected JSON response; missing 'nodes' list.", false ]; + return [ null, "Unexpected JSON response; missing 'nodes' list.", false ]; } $config = []; diff --git a/tests/phpunit/includes/config/EtcdConfigTest.php b/tests/phpunit/includes/config/EtcdConfigTest.php index 8e57a01700..e0694dbf7e 100644 --- a/tests/phpunit/includes/config/EtcdConfigTest.php +++ b/tests/phpunit/includes/config/EtcdConfigTest.php @@ -364,22 +364,18 @@ class EtcConfigTest extends PHPUnit_Framework_TestCase { public static function provideFetchFromServer() { return [ - [ + '200 OK - Empty' => [ 'http' => [ 'code' => 200, 'reason' => 'OK', - 'headers' => [ - 'content-length' => 0, - ], + 'headers' => [ 'content-length' => 0 ], 'body' => '', 'error' => '(curl error: no status set)', ], 'expect' => [ - // FIXME: Returning 4 values instead of 3 - null, - 200, + null, // data "Unexpected JSON response; missing 'nodes' list.", - false + false // retry ], ], ];