-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error Massage showes DB Connection Parameter (host, user, password) in the frontend #1422
Comments
|
Are you sure you're not using the app_dev environment? Because the production environment should not display error messages at all.
|
|
I didn't call the page via app_dev. php. So I didn't worked in debug mode. |
|
If you didn't call the page via app_dev.php maybe you changed the |
|
Did no changes on app.php |
|
I cannot reproduce the issue. The manager bundle has a workaround for this case, therefore I see the pretty error screen if I manually stop the MySQL service. |
|
I have tried it with Contao 4.4.16 and 4.5.6 and I never saw the error message, neither with wrong DB credentials nor with the MySQL service being stopped manually. |
|
I can reproduce it in Contao 4.4.16 in the front end and the login page: |
|
That's great, but how? |
|
I only disabled the MySQL server, nothing more. In Contao 4.5.6 I only see the following after disabling the MySQL server: <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>An Error Occurred: Not Found</title>
</head>
<body>
<h1>Oops! An Error Occurred</h1>
<h2>The server returned a "404 Not Found".</h2>
<div>
Something is broken. Please let us know what you were doing when this error occurred.
We will fix it as soon as possible. Sorry for any inconvenience caused.
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>An Error Occurred: Internal Server Error</title>
</head>
<body>
<h1>Oops! An Error Occurred</h1>
<h2>The server returned a "500 Internal Server Error".</h2>
<div>
Something is broken. Please let us know what you were doing when this error occurred.
We will fix it as soon as possible. Sorry for any inconvenience caused.
</div>
</body>
</html> |
|
Really? I cannot reproduce this either. You should probably delete the cache folders. |
|
// nvm, suddenly I see the regular error page in Contao 4.5.6... weird. My guess is that it also makes a difference if the target machine actively refuses the connection or if a timeout happens. |
|
My System runs on allinkl server. Now try to find out what the problem was there. |
|
Support von Allinkl beschreibt den Vorfall wie folgt:
So it`s a common situation that can happen at any time. |
|
Ok, I finally figured out how to reliably reproduce this.
They problem is that our workaround is only applied if the DB connection fails upon container build. If the container is built successfully and the DB connections goes away later, the error message is shown. Possible solution: Permanently add the |
|
I don’t think the error itself is the problem. It is expected that the website breaks if the database goes away. Instead of fixing the error, I think we should check why the error message gets printed instead of the pretty error screen. |
|
Here is another possible solution in the $server_version = '5.1';
try {
$connection = DriverManager::getConnection($params);
if ($connection->getDatabasePlatform() instanceof MySQL57Platform) {
$server_version = '5.7';
}
} catch (DriverException $e) {
// ignore
}
$extensionConfigs[] = [
'dbal' => [
'connections' => [
'default' => [
'server_version' => $server_version,
],
],
],
];Instead of only setting the server version if the connection fails, it is now always stored in the container. |
That's a point for sure. But I think we failed to do so last time, which is why we have implemented the workaround in the |
|
I had to adjust the fix to be forward compatible with the upcoming /** @var ServerInfoAwareConnection $connection */
$connection = DriverManager::getConnection($params)->getWrappedConnection();
$extensionConfigs[] = [
'dbal' => [
'connections' => [
'default' => [
'server_version' => $connection->getServerVersion(),
],
],
],
];This will always store the server version so the error message is never shown if the MySQL server goes away. And if the DB connection fails at container build time, the exception will be thrown. |
|
I totally agree with @ausi. The error screen must be displayed, and it will solved this problem. The problem is not that the connection fails (which is a possible case), but that the error screen is not rendered.
I'm pretty sure this is actually a Symfony issue as the error appears on container boot where the kernel exception handler does not catch it.
|
|
I also agree with @ausi and I also think that this is a Symfony issue. Still we should keep working around it in the |
|
From symfony/symfony#15581:
I’m not sure if it is wrong that Doctrine throws an exception before the kernel is booted. But if it connects to the database that early it is probably correct to do so. As we seem to all agree that in the
So it seems to be a configuration error that IMO the best solution for us is to add the following line to the top of our ini_set('display_errors', 0); |
|
See also symfony/symfony#22736 |
|
Many thanks to everyone for the quick reconnaissance. I wrote my hoster and pointed out the facts to him. |
|
Thank you for doing the research @ausi. Adding |
|
Fixed in contao/manager-bundle@bebef40. |
|
I will have to revert the changes from contao/manager-bundle@bebef40 as the entry point cannot determine whether Contao is installed on a production or development system. If I e.g. access Contao through the |
But why would you choose that entry point to see the error messages? Though, granted, there are sometimes errors that only happen in |

Contao 4.4.16
Following Error Massage was shown in the frontend:
Luckily in a password-protected environment. On a live page, this would be a disaster.
Error Messages log file:
[2018-03-12 17:11:44] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\DBALException: "An exception occured while establishing a connection to figure out your platform version. You can circumvent this by setting a 'server_version' configuration value For further information have a look at: https://github.com/doctrine/DoctrineBundle/issues/673" at /www/XXX/vendor/doctrine/doctrine-bundle/ConnectionFactory.php line 96 {"exception":"[object] (Doctrine\\DBAL\\DBALException(code: 0): An exception occured while establishing a connection to figure out your platform version.\nYou can circumvent this by setting a 'server_version' configuration value\n\nFor further information have a look at:\nhttps://github.com/doctrine/DoctrineBundle/issues/673 at /www/XXX/vendor/doctrine/doctrine-bundle/ConnectionFactory.php:96, Doctrine\\DBAL\\Exception\\ConnectionException(code: 0): An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory at /www/XXX/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:108, Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /www/XXX/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /www/XXX/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} [][2018-03-12 17:11:44] request.CRITICAL: Exception thrown when handling an exception (Doctrine\DBAL\DBALException: An exception occured while establishing a connection to figure out your platform version. You can circumvent this by setting a 'server_version' configuration value For further information have a look at: https://github.com/doctrine/DoctrineBundle/issues/673 at /www/XXX/vendor/doctrine/doctrine-bundle/ConnectionFactory.php line 96) {"exception":"[object] (Doctrine\\DBAL\\DBALException(code: 0): An exception occured while establishing a connection to figure out your platform version.\nYou can circumvent this by setting a 'server_version' configuration value\n\nFor further information have a look at:\nhttps://github.com/doctrine/DoctrineBundle/issues/673 at /www/XXX/vendor/doctrine/doctrine-bundle/ConnectionFactory.php:96, Doctrine\\DBAL\\Exception\\ConnectionException(code: 0): An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory at /www/XXX/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:108, Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /www/XXX/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /www/XXX/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} []The text was updated successfully, but these errors were encountered: