From 63a6926dfd81826975a997ee4c30a88b7cb3b588 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 24 Jul 2017 12:48:38 -0700 Subject: [PATCH] config: Fix invalid EtcdConfig return value after JSON parse error Follows-up 1f2daa913244, 9b459d29e0, 110a21ea18. Bug: T156924 Change-Id: I79b7e11b32e5be46c8ebdfb5c937e38e46301c0e --- includes/config/EtcdConfig.php | 2 +- tests/phpunit/includes/config/EtcdConfigTest.php | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) 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 ], ], ]; -- 2.20.1