Merge pull request #4044 from Icinga/fix/pdf-export-error-handling

Fix pdf export error handling
This commit is contained in:
Johannes Meyer 2020-01-14 11:13:01 +01:00 committed by GitHub
commit 8da37e5ca2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View File

@ -51,14 +51,19 @@ class Pdf
Environment::raiseExecutionTime(300);
$viewRenderer = $controller->getHelper('viewRenderer');
$controller->render(
$viewRenderer->getScriptAction(),
$viewRenderer->getResponseSegment(),
$viewRenderer->getNoController()
);
$layout = $controller->getHelper('layout')->setLayout('pdf');
$viewRenderer->postDispatch();
$layoutHelper = $controller->getHelper('layout');
$oldLayout = $layoutHelper->getLayout();
$layout = $layoutHelper->setLayout('pdf');
$layout->content = $controller->getResponse();
$html = $layout->render();
// Restore previous layout and reset content, to properly show errors
$controller->getResponse()->clearBody($viewRenderer->getResponseSegment());
$layoutHelper->setLayout($oldLayout);
$imgDir = Url::fromPath('img');
$html = preg_replace(
'~src="' . $imgDir . '/~',

View File

@ -483,9 +483,9 @@ class ActionController extends Zend_Controller_Action
}
}
if ($req->getParam('format') === 'pdf') {
$this->shutdownSession();
if ($req->getParam('error_handler') === null && $req->getParam('format') === 'pdf') {
$this->sendAsPdf();
$this->shutdownSession();
exit;
}