From b263537f8099dd4888366771ea5192dce3a86347 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Sat, 18 Jan 2025 21:05:04 -0300 Subject: [PATCH 1/2] chore: prevent generate unecessary temp file Signed-off-by: Vitor Mattos --- lib/Handler/FooterHandler.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/Handler/FooterHandler.php b/lib/Handler/FooterHandler.php index 0a59730f80..78b93d1e07 100644 --- a/lib/Handler/FooterHandler.php +++ b/lib/Handler/FooterHandler.php @@ -96,10 +96,10 @@ private function getMetadata(): array { } private function getRenderedHtmlFooter(): string { - $tempFile = $this->tempManager->getTemporaryFile('footerTemplate.php'); - file_put_contents($tempFile, $this->getTemplate()); - $templates = new Engine($this->tempManager->getTempBaseDir()); - return $templates->render(pathinfo($tempFile, PATHINFO_FILENAME), $this->getTemplateVars()); + $templateFile = $this->getTemplateFile(); + $pathInfo = pathinfo($templateFile); + $templates = new Engine($pathInfo['dirname']); + return $templates->render($pathInfo['filename'], $this->getTemplateVars()); } public function setTemplateVar(string $name, mixed $value): self { @@ -137,8 +137,14 @@ private function getTemplateVars(): array { return $this->templateVars; } - private function getTemplate(): string { - return $this->appConfig->getValueString(Application::APP_ID, 'footer_template', file_get_contents(__DIR__ . '/Templates/footer.php')); + private function getTemplateFile(): string { + $footerTemplate = $this->appConfig->getValueString(Application::APP_ID, 'footer_template', ''); + if ($footerTemplate) { + $tempFile = $this->tempManager->getTemporaryFile('footerTemplate.php'); + file_put_contents($tempFile, $footerTemplate); + return $tempFile; + } + return __DIR__ . '/Templates/footer.php'; } private function getQrCodeImageBase64(string $text): string { From 246883e073b8ccdc5d109b33c7f52000dd39f517 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Sat, 18 Jan 2025 21:15:52 -0300 Subject: [PATCH 2/2] chore: reduce template Signed-off-by: Vitor Mattos --- lib/Handler/Templates/footer.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/Handler/Templates/footer.php b/lib/Handler/Templates/footer.php index 3986c75298..05c197c38e 100644 --- a/lib/Handler/Templates/footer.php +++ b/lib/Handler/Templates/footer.php @@ -16,10 +16,7 @@
- - - +