summaryrefslogtreecommitdiffstats
path: root/apps/federation
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-03-13 12:13:57 +0100
committerBjoern Schiessle <bjoern@schiessle.org>2017-03-24 11:06:44 +0100
commit4531b4a81da81c8f1b6eb49b2669fa93088e33d9 (patch)
tree264d46d9316e42cb73ec8641198e08f8a9883867 /apps/federation
parentfaf836b0c0f94348380e1b0c965d3ea75fa1482d (diff)
downloadnextcloud-server-4531b4a81da81c8f1b6eb49b2669fa93088e33d9.tar.gz
nextcloud-server-4531b4a81da81c8f1b6eb49b2669fa93088e33d9.zip
only execute code if exception was thrown by the corresponding controller
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/federation')
-rw-r--r--apps/federation/lib/Middleware/AddServerMiddleware.php4
-rw-r--r--apps/federation/tests/Middleware/AddServerMiddlewareTest.php6
2 files changed, 7 insertions, 3 deletions
diff --git a/apps/federation/lib/Middleware/AddServerMiddleware.php b/apps/federation/lib/Middleware/AddServerMiddleware.php
index d920aee3e4e..71e517f6b87 100644
--- a/apps/federation/lib/Middleware/AddServerMiddleware.php
+++ b/apps/federation/lib/Middleware/AddServerMiddleware.php
@@ -25,6 +25,7 @@
namespace OCA\Federation\Middleware;
use OC\HintException;
+use OCA\Federation\Controller\SettingsController;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Middleware;
@@ -57,6 +58,9 @@ class AddServerMiddleware extends Middleware {
* @return JSONResponse
*/
public function afterException($controller, $methodName, \Exception $exception) {
+ if (($controller instanceof SettingsController) === false) {
+ throw $exception;
+ }
$this->logger->error($exception->getMessage(), ['app' => $this->appName]);
if ($exception instanceof HintException) {
$message = $exception->getHint();
diff --git a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
index b2096cb3730..6c502c66f5f 100644
--- a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
+++ b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
@@ -26,8 +26,8 @@ namespace OCA\Federation\Tests\Middleware;
use OC\HintException;
+use OCA\Federation\Controller\SettingsController;
use OCA\Federation\Middleware\AddServerMiddleware;
-use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\IL10N;
use OCP\ILogger;
@@ -44,7 +44,7 @@ class AddServerMiddlewareTest extends TestCase {
/** @var AddServerMiddleware */
private $middleware;
- /** @var \PHPUnit_Framework_MockObject_MockObject | Controller */
+ /** @var \PHPUnit_Framework_MockObject_MockObject | SettingsController */
private $controller;
public function setUp() {
@@ -52,7 +52,7 @@ class AddServerMiddlewareTest extends TestCase {
$this->logger = $this->getMockBuilder(ILogger::class)->getMock();
$this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
- $this->controller = $this->getMockBuilder(Controller::class)
+ $this->controller = $this->getMockBuilder(SettingsController::class)
->disableOriginalConstructor()->getMock();
$this->middleware = new AddServerMiddleware(