From 81ab066c016ded44dc679b394bf8294a034848c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Rie=C3=9F?= Date: Wed, 8 Apr 2026 10:58:36 +0200 Subject: [PATCH 1/4] Switch back to using syncronous pdf export The reason we initially switched to asyncHtmlToPdf was because the headless chrome backend tried to create its own event loop, which caused problems with ipl-scheduler. The new pdfexport module no longer has this behaviour. Therefore asyncHtmlToPdf is no longer required. The method was never actually part of the hook and therefore relied on the fact that pdfexport was the only implementation of PdfexportHook. --- library/Reporting/Actions/SendMail.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/library/Reporting/Actions/SendMail.php b/library/Reporting/Actions/SendMail.php index 73138a64..444e1e44 100644 --- a/library/Reporting/Actions/SendMail.php +++ b/library/Reporting/Actions/SendMail.php @@ -49,17 +49,15 @@ public function execute(Report $report, array $config) switch ($config['type']) { case 'pdf': - /** @var Pdfexport $exporter */ $exporter = Pdfexport::first(); - $exporter->asyncHtmlToPdf($report->toPdf())->then( - function ($pdf) use ($mail, $name, $recipients) { - $mail->attachPdf($pdf, $name); - $mail->send(null, $recipients); - } - )->catch(function (Throwable $e) { + try { + $pdf = $exporter->htmlToPdf($report->toPdf()); + $mail->attachPdf($pdf, $name); + $mail->send(null, $recipients); + } catch (Throwable $e) { Logger::error($e); Logger::debug($e->getTraceAsString()); - }); + } return; case 'csv': From e3becd65be81a6d551a32c041622a55aaba082a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Rie=C3=9F?= Date: Fri, 10 Apr 2026 08:39:31 +0200 Subject: [PATCH 2/4] Remove try catch --- library/Reporting/Actions/SendMail.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/library/Reporting/Actions/SendMail.php b/library/Reporting/Actions/SendMail.php index 444e1e44..2f5f9f8e 100644 --- a/library/Reporting/Actions/SendMail.php +++ b/library/Reporting/Actions/SendMail.php @@ -49,17 +49,9 @@ public function execute(Report $report, array $config) switch ($config['type']) { case 'pdf': - $exporter = Pdfexport::first(); - try { - $pdf = $exporter->htmlToPdf($report->toPdf()); - $mail->attachPdf($pdf, $name); - $mail->send(null, $recipients); - } catch (Throwable $e) { - Logger::error($e); - Logger::debug($e->getTraceAsString()); - } - - return; + $mail->attachPdf(Pdfexport::first()->htmlToPdf($report->toPdf()), $name); + + break; case 'csv': $mail->attachCsv($report->toCsv(), $name); From 0e31bdb96a5f12bf71651952ea910d3566f60d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Rie=C3=9F?= Date: Thu, 16 Apr 2026 09:19:42 +0200 Subject: [PATCH 3/4] Check if the first method exists on the Hook abstract class This is a temporary solution until we break support with older pdfexport module versions. --- application/clicommands/DownloadCommand.php | 7 ++++++- application/controllers/ReportController.php | 9 ++++++--- library/Reporting/Actions/SendMail.php | 9 ++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/application/clicommands/DownloadCommand.php b/application/clicommands/DownloadCommand.php index dda234e3..f5297044 100644 --- a/application/clicommands/DownloadCommand.php +++ b/application/clicommands/DownloadCommand.php @@ -5,6 +5,7 @@ namespace Icinga\Module\Reporting\Clicommands; +use Icinga\Application\Hook\PdfexportHook; use Icinga\Exception\NotFoundError; use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport; use Icinga\Module\Reporting\Cli\Command; @@ -70,7 +71,11 @@ public function defaultAction() $format = strtolower($format); switch ($format) { case 'pdf': - $content = Pdfexport::first()->htmlToPdf($report->toPdf()); + // TODO: Remove this once the dependency on the Pdfexport module is removed + $exporter = method_exists(PdfexportHook::class, 'first') + ? PdfexportHook::first() + : Pdfexport::first(); + $content = $exporter->htmlToPdf($report->toPdf()); break; case 'csv': $content = $report->toCsv(); diff --git a/application/controllers/ReportController.php b/application/controllers/ReportController.php index ed843387..c05aef6c 100644 --- a/application/controllers/ReportController.php +++ b/application/controllers/ReportController.php @@ -7,6 +7,7 @@ use Exception; use Icinga\Application\Hook; +use Icinga\Application\Hook\PdfexportHook; use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport; use Icinga\Module\Reporting\Database; use Icinga\Module\Reporting\Model; @@ -244,9 +245,11 @@ public function downloadAction(): void switch ($type) { case 'pdf': - /** @var Hook\PdfexportHook $exports */ - $exports = Pdfexport::first(); - $exports->streamPdfFromHtml($this->report->toPdf(), $name); + // TODO: Remove this once the dependency on the Pdfexport module is removed + $exporter = method_exists(PdfexportHook::class, 'first') + ? PdfexportHook::first() + : Pdfexport::first(); + $exporter->streamPdfFromHtml($this->report->toPdf(), $name); exit; case 'csv': $response = $this->getResponse(); diff --git a/library/Reporting/Actions/SendMail.php b/library/Reporting/Actions/SendMail.php index 2f5f9f8e..355d1303 100644 --- a/library/Reporting/Actions/SendMail.php +++ b/library/Reporting/Actions/SendMail.php @@ -6,7 +6,7 @@ namespace Icinga\Module\Reporting\Actions; use Icinga\Application\Config; -use Icinga\Application\Logger; +use Icinga\Application\Hook\PdfexportHook; use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport; use Icinga\Module\Reporting\Hook\ActionHook; use Icinga\Module\Reporting\Mail; @@ -15,7 +15,6 @@ use ipl\Stdlib\Str; use ipl\Validator\CallbackValidator; use ipl\Validator\EmailAddressValidator; -use Throwable; class SendMail extends ActionHook { @@ -49,7 +48,11 @@ public function execute(Report $report, array $config) switch ($config['type']) { case 'pdf': - $mail->attachPdf(Pdfexport::first()->htmlToPdf($report->toPdf()), $name); + // TODO: Remove this once the dependency on the Pdfexport module is removed + $exporter = method_exists(PdfexportHook::class, 'first') + ? PdfexportHook::first() + : Pdfexport::first(); + $mail->attachPdf($exporter->htmlToPdf($report->toPdf()), $name); break; case 'csv': From b3d16a2e5e11f8f6a08850217e09027c632c0f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Rie=C3=9F?= Date: Wed, 20 May 2026 13:54:36 +0200 Subject: [PATCH 4/4] Explicit check for pdfexport --- application/controllers/ReportController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/application/controllers/ReportController.php b/application/controllers/ReportController.php index c05aef6c..6132d19f 100644 --- a/application/controllers/ReportController.php +++ b/application/controllers/ReportController.php @@ -8,6 +8,7 @@ use Exception; use Icinga\Application\Hook; use Icinga\Application\Hook\PdfexportHook; +use Icinga\Application\Modules\Module; use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport; use Icinga\Module\Reporting\Database; use Icinga\Module\Reporting\Model; @@ -246,6 +247,9 @@ public function downloadAction(): void switch ($type) { case 'pdf': // TODO: Remove this once the dependency on the Pdfexport module is removed + if (Module::exists('pdfexport')) { + throw new Exception('The pdfexport module is not installed'); + } $exporter = method_exists(PdfexportHook::class, 'first') ? PdfexportHook::first() : Pdfexport::first();