From ed0c23a9cc49f10c741a84dc6c95e1dfef6ee61b Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 2 May 2013 14:36:16 +0200 Subject: [PATCH 1/3] fix bug that would only return error responses for 3rdparty apps --- lib/api.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/api.php b/lib/api.php index 249d7a90350..8e4c3ef29b9 100644 --- a/lib/api.php +++ b/lib/api.php @@ -147,6 +147,7 @@ class OC_API { } } } + // Remove any error responses if there is one shipped response that succeeded if(!empty($shipped['succeeded'])) { $responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']); @@ -157,14 +158,17 @@ class OC_API { // Maybe any that are not OC_API::RESPOND_SERVER_ERROR $response = reset($shipped['failed']); return $response; - } else { + } elseif(!empty($thirdparty['failed'])) { // Return the third party failure result $response = reset($thirdparty['failed']); return $response; + } else { + $responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']); } // Merge the successful responses $meta = array(); $data = array(); + foreach($responses as $app => $response) { if(OC_App::isShipped($app)) { $data = array_merge_recursive($response->getData(), $data); From 0f38e6ec9caa726be646b6e25f7db10c5fa911ea Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 2 May 2013 14:49:05 +0200 Subject: [PATCH 2/3] logout before output to not run into header already sent problems --- lib/api.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/api.php b/lib/api.php index 8e4c3ef29b9..c74ffc1a557 100644 --- a/lib/api.php +++ b/lib/api.php @@ -112,8 +112,9 @@ class OC_API { $response = self::mergeResponses($responses); $formats = array('json', 'xml'); $format = !empty($_GET['format']) && in_array($_GET['format'], $formats) ? $_GET['format'] : 'xml'; - self::respond($response); OC_User::logout(); + + self::respond($response); } /** From 11afb2e5a80bb29a48717b0a9b6a9e034fd55497 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 2 May 2013 14:51:53 +0200 Subject: [PATCH 3/3] respect format output --- lib/api.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/api.php b/lib/api.php index c74ffc1a557..fc76836995b 100644 --- a/lib/api.php +++ b/lib/api.php @@ -111,10 +111,11 @@ class OC_API { } $response = self::mergeResponses($responses); $formats = array('json', 'xml'); + $format = !empty($_GET['format']) && in_array($_GET['format'], $formats) ? $_GET['format'] : 'xml'; OC_User::logout(); - - self::respond($response); + + self::respond($response, $format); } /**