From ae605d54c3a44642abbb4fb3a23255469a114484 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Thu, 16 Nov 2023 09:08:27 +0100 Subject: [PATCH] Don't use extra updates for http requests --- application/controllers/ReportController.php | 27 ++++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/application/controllers/ReportController.php b/application/controllers/ReportController.php index f45c65d..0a694f2 100644 --- a/application/controllers/ReportController.php +++ b/application/controllers/ReportController.php @@ -53,14 +53,25 @@ public function indexAction() $this->controls->getAttributes()->add('class', 'default-layout'); $this->addControl($this->assembleActions()); - /** @var string $contentId */ - $contentId = $this->content->getAttributes()->get('id')->getValue(); - $this->sendExtraUpdates([ - $contentId => Url::fromPath('reporting/report/content', ['id' => $this->report->getId()]) - ]); - - // Will be replaced once the report content is rendered - $this->addContent(new HtmlElement('div')); + if ($this->isXhr()) { + /** @var string $contentId */ + $contentId = $this->content->getAttributes()->get('id')->getValue(); + $this->sendExtraUpdates([ + $contentId => Url::fromPath('reporting/report/content', ['id' => $this->report->getId()]) + ]); + + // Will be replaced once the report content is rendered + $this->addContent(new HtmlElement('div')); + } else { + Environment::raiseExecutionTime(); + Environment::raiseMemoryLimit(); + + try { + $this->addContent($this->report->toHtml()); + } catch (Exception $e) { + $this->addContent(Error::show($e)); + } + } } public function contentAction(): void