Skip to content

Commit de3345e

Browse files
Remove logging and simplify error response in renderAction methods
Address review feedback to remove logging calls and simplify error responses while still preventing information exposure. Co-authored-by: dpfaffenbauer <5981845+dpfaffenbauer@users.noreply.github.com>
1 parent ac3b8a8 commit de3345e

File tree

2 files changed

+2
-28
lines changed

2 files changed

+2
-28
lines changed

src/CoreShop/Bundle/OrderBundle/Controller/OrderInvoiceController.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
use CoreShop\Component\Pimcore\DataObject\NoteServiceInterface;
3737
use CoreShop\Component\Resource\Factory\FactoryInterface;
3838
use CoreShop\Component\Resource\Factory\PimcoreFactoryInterface;
39-
use Psr\Log\LoggerInterface;
4039
use Symfony\Component\DependencyInjection\Attribute\Autowire;
4140
use Symfony\Component\EventDispatcher\GenericEvent;
4241
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -188,18 +187,7 @@ public function renderAction(Request $request): Response
188187
'Content-Disposition' => 'inline; filename="invoice-' . $invoice->getId() . '.pdf"',
189188
];
190189
} catch (\Exception $e) {
191-
$this->container->get(LoggerInterface::class)->error(
192-
'Failed to render invoice PDF',
193-
[
194-
'invoiceId' => $invoice->getId(),
195-
'exception' => $e->getMessage(),
196-
'trace' => $e->getTraceAsString(),
197-
],
198-
);
199-
$responseData = 'An error occurred while rendering the invoice. Please try again later.';
200-
$header = ['Content-Type' => 'text/html'];
201-
202-
return new Response($responseData, 500, $header);
190+
return new Response('An error occurred while rendering the invoice.', 500, ['Content-Type' => 'text/html']);
203191
}
204192

205193
return new Response($responseData, 200, $header);
@@ -255,7 +243,6 @@ public static function getSubscribedServices(): array
255243
new SubscribedService('coreshop.order.transformer.order_to_invoice', OrderDocumentTransformerInterface::class, attributes: new Autowire('@CoreShop\Component\Order\Transformer\OrderToInvoiceTransformer')),
256244
new SubscribedService('coreshop.repository.order_invoice', OrderInvoiceRepositoryInterface::class, attributes: new Autowire(service:'coreshop.repository.order_invoice')),
257245
new SubscribedService(StateMachineManagerInterface::class, StateMachineManagerInterface::class),
258-
new SubscribedService(LoggerInterface::class, LoggerInterface::class),
259246
]);
260247
}
261248
}

src/CoreShop/Bundle/OrderBundle/Controller/OrderShipmentController.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
use CoreShop\Component\Order\Transformer\OrderToShipmentTransformer;
3737
use CoreShop\Component\Resource\Factory\FactoryInterface;
3838
use CoreShop\Component\Resource\Repository\PimcoreRepositoryInterface;
39-
use Psr\Log\LoggerInterface;
4039
use Symfony\Component\DependencyInjection\Attribute\Autowire;
4140
use Symfony\Component\EventDispatcher\GenericEvent;
4241
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -184,18 +183,7 @@ public function renderAction(Request $request): Response
184183
'Content-Disposition' => 'inline; filename="shipment-' . $shipment->getId() . '.pdf"',
185184
];
186185
} catch (\Exception $e) {
187-
$this->container->get(LoggerInterface::class)->error(
188-
'Failed to render shipment PDF',
189-
[
190-
'shipmentId' => $shipment->getId(),
191-
'exception' => $e->getMessage(),
192-
'trace' => $e->getTraceAsString(),
193-
],
194-
);
195-
$responseData = 'An error occurred while rendering the shipment. Please try again later.';
196-
$header = ['Content-Type' => 'text/html'];
197-
198-
return new Response($responseData, 500, $header);
186+
return new Response('An error occurred while rendering the shipment.', 500, ['Content-Type' => 'text/html']);
199187
}
200188

201189
return new Response($responseData, 200, $header);
@@ -251,7 +239,6 @@ public static function getSubscribedServices(): array
251239
new SubscribedService('event_dispatcher', EventDispatcherInterface::class),
252240
new SubscribedService(OrderToShipmentTransformer::class, OrderToShipmentTransformer::class),
253241
new SubscribedService(ErrorSerializer::class, ErrorSerializer::class),
254-
new SubscribedService(LoggerInterface::class, LoggerInterface::class),
255242
]);
256243
}
257244
}

0 commit comments

Comments
 (0)