Why is this fatal error printed on "production" mode for this Symfony 3.4.37 application?

This question is not about why and how to fix this error, but why I’m getting it in production mode for Symfony 3.4.37 ( error is imitated by me via changing MySQL host to wrong one )

Recently we updated from symfony 3.1 to 3.4.37 and today we noticed that our project throwing error on production environment

Fatal error: Uncaught PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: No such host is known. in pathprojectvendordoctrinedballibDoctrineDBALDriverPDOConnection.php:27
Stack trace:

#0 pathprojectvendordoctrinedballibDoctrineDBALDriverPDOConnection.php(27): PDO->__construct(‘mysql:host=loca…’, ‘user’, ‘pass’, Array)

#1 pathprojectvendordoctrinedballibDoctrineDBALDriverPDOMySqlDriver.php(25): DoctrineDBALDriverPDOConnection->__construct(‘mysql:host=loca…’, ‘user’, ‘pass’, Array)

#2 pathprojectvendordoctrinedballibDoctrineDBALConnection.php(356): DoctrineDBALDriverPDOMySqlDriver->connect(Array, ‘user’, ‘pass’, Array)

#3 pathprojectvendordoctrinedoctrine-bundleConnectionFactory.php on line 79

Weird is as you can see in screenshot it as no symfony error page design but just pure error message

enter image description here

but we are using app.php where AppKernel(‘prod’, false);

$loader = require __DIR__.'/../app/autoload.php';
include_once __DIR__.'/../var/bootstrap.php.cache';
$kernel = new AppKernel('prod', false);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$kernel->terminate($request, $response);

So logically we have to see 500 error on symfony page instead and not fetal error …

Question: Can it be some bug of symfony 3.4.37 ? or we are missing something in production configuration ?

As a tmp workaround ( not a solution ) i found only standard error hiding option by adding this 2 lines at the top in app.php

ini_set('display_errors', 0);

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *