Skip to content

Commit

Permalink
Merge pull request #364 from UN-OCHA/cafuego/ops-9090-annoying-print-…
Browse files Browse the repository at this point in the history
…pdf-errors

fix: This is the only controller we invoke, so make it return a response object.
  • Loading branch information
cafuego authored Oct 30, 2023
2 parents 83b94fd + ba62380 commit e50a93e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
19 changes: 19 additions & 0 deletions docker/99-elastic-apm-custom.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; This file contains the various settings for the Elastic APM PHP agent. For
; further details refers to the following URL:
; https://www.elastic.co/guide/en/apm/agent/php/current/configuration-reference.html
;

[elastic]
elastic_apm.enabled = ${PHP_ELASTIC_APM_ENABLED}
;elastic_apm.api_key = "REPLACE_WITH_API_KEY"
elastic_apm.environment = "${PHP_ELASTIC_APM_ENVIRONMENT}"
elastic_apm.log_level = "INFO"
elastic_apm.log_level_stderr = "INFO"
elastic_apm.secret_token = "${PHP_ELASTIC_APM_TOKEN}"
;elastic_apm.server_timeout = "30s"
elastic_apm.server_url = "${PHP_ELASTIC_APM_SERVER}"
elastic_apm.service_name = "${PHP_ELASTIC_APM_SERVICE}"
elastic_apm.service_version = ${GIT_SHA}
;elastic_apm.transaction_max_spans = 500
;elastic_apm.transaction_sample_rate = 1.0
;elastic_apm.verify_server_cert = true
6 changes: 6 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ COPY --from=builder /srv/www/composer.patches.json /srv/www/composer.patches.jso
COPY --from=builder /srv/www/composer.lock /srv/www/composer.lock
COPY --from=builder /srv/www/symfony.lock /srv/www/symfony.lock
COPY --from=builder /srv/www/PATCHES /srv/www/PATCHES
COPY --from=builder /srv/www/docker/99-elastic-apm-custom.ini /tmp/99-elastic-apm-custom.ini

RUN curl -L -o /tmp/apm-agent-php_all.apk https://github.com/elastic/apm-agent-php/releases/download/v1.10.0/apm-agent-php_1.10.0_all.apk && \
apk add --allow-untrusted /tmp/apm-agent-php_all.apk && \
rm -f /tmp/apm-agent-php_all.apk && \
mv -f /tmp/99-elastic-apm-custom.ini /etc/php82/conf.d/99-elastic-apm-custom.ini
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public function viewPrint($export_type, $entity_type, $entity_id) {
$response = new RedirectResponse($base_url, 301);
$response->send();
}
return $response;

}

Expand Down Expand Up @@ -208,16 +209,24 @@ public function downloadPdf($entity_type, $entity_id) {
</style>
</head>
<body>' . $content . '</body>
</html>';
echo $html;
die;
</html>';

// This could *possibly* be an HtmlResponse but things seem to work as-is.
$response = new Response();
$response->headers->set('Pragma', 'no-cache');
$response->headers->set('Content-type', 'text/html; charset=utf-8');
$response->headers->set('Cache-control', 'private');
$response->headers->set('Content-length', strlen($html));
$response->setContent($html);
$response->send();
}
else {
global $base_url;
$this->messenger()->addMessage($this->t('Access denied.'), 'error');
$response = new RedirectResponse($base_url, 301);
$response->send();
}
return $response;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public function viewPrint($export_type, $entity_type, $entity_id) {
$response = new RedirectResponse($base_url, 301);
$response->send();
}
return $response;
}

}

0 comments on commit e50a93e

Please sign in to comment.