summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php9
-rw-r--r--tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php10
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php b/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php
index de1a02026bf..8e5391b4365 100644
--- a/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php
+++ b/lib/private/AppFramework/Middleware/AdditionalScriptsMiddleware.php
@@ -27,6 +27,7 @@ namespace OC\AppFramework\Middleware;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Middleware;
+use OCP\AppFramework\PublicShareController;
use OCP\IUserSession;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -42,6 +43,14 @@ class AdditionalScriptsMiddleware extends Middleware {
}
public function afterController($controller, $methodName, Response $response): Response {
+ /*
+ * There is no need to emit these signals on a public share page
+ * There is a separate event for that already
+ */
+ if ($controller instanceof PublicShareController) {
+ return $response;
+ }
+
if ($response instanceof TemplateResponse) {
$this->dispatcher->dispatch(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS);
diff --git a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
index 27a6e70c641..2a789a848a3 100644
--- a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
@@ -28,6 +28,7 @@ use OC\AppFramework\Middleware\AdditionalScriptsMiddleware;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\PublicShareController;
use OCP\IUserSession;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -67,6 +68,15 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase {
$this->middleWare->afterController($this->controller, 'myMethod', $this->createMock(Response::class));
}
+ public function testPublicShareController() {
+ $this->dispatcher->expects($this->never())
+ ->method($this->anything());
+ $this->userSession->expects($this->never())
+ ->method($this->anything());
+
+ $this->middleWare->afterController($this->createMock(PublicShareController::class), 'myMethod', $this->createMock(Response::class));
+ }
+
public function testTemplateResponseNotLoggedIn() {
$this->dispatcher->expects($this->once())
->method('dispatch')