contao / installation-bundle

[READ-ONLY] Contao Installation Bundle
GNU Lesser General Public License v3.0
8 stars 9 forks source link

4.4.0: Install tool fails without functioning MySQL connection #58

Closed arechsteiner closed 7 years ago

arechsteiner commented 7 years ago

I ran into trouble when trying to move a minimal Contao 4.4.0 "Hello World" website that I created through the .zip file (manual installation) to a remote host. The install tool under (contao/install) would throw an error related to MySQL, which makes little sense because obviously I need to use that very tool in order to fix the MySQL connection and point it to the new database.

The problem can be reproduced locally by creating a simple website (with website root and article) and turning off the MySQL server. The install tool then fails with this error:

[2017-06-21 12:55:06] app.CRITICAL: An exception occurred. {"exception":"[object] (Doctrine\\DBAL\\Exception\\ConnectionException(code: 0): An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory at /home/alex/lampp/nucontao/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:103, Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /home/alex/lampp/nucontao/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /home/alex/lampp/nucontao/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} []

This breaks the migration process described in the manual.

Forum Thread (in German): https://community.contao.org/de/showthread.php?67128-Contao-Install-Tool-scheitert-ohne-MySQL-Verbindung&p=443236#post443236

fritzmg commented 7 years ago

As mentioned on the forum, I think this is expected. In Contao 3 you are unable to use the Install Tool as well, if the given database information is incorrect.

Of course it would be nice if the Install Tool still worked without a database connection as well.

fritzmg commented 7 years ago

This breaks the migration process described in the manual.

What exactly do you mean by that?

arechsteiner commented 7 years ago

The installation guide describes how to move an installation using the Installtool, here:

https://docs.contao.org/books/manual/4.3/en/01-installation/moving-an-installation.html

It instructs me to 1) upload the files 2) export/import the database and finally 3) to use the Installtool to actually configure the new database connection.

Step number 3 is impossible if the Installtool requires an already working MySQL connection.

fritzmg commented 7 years ago

Indeed. Since that part of the manual is taken from Contao 3, it should probably be fixed in Contao 3 as well.

arechsteiner commented 7 years ago

I've tried manually updating parameters.yml before, however that did not work.

The error in the log file still shows the old credentials. I've found this forum post instructing me to use php app/console cache:clear --env=prod to clear the cache, but the .zip version of Contao doesn't include any folder or file called 'app/console' and I get the error Could not open input file: app/console

What are the correct steps to adjust parameters.yml on a remote host to configure a new MySQL database?

fritzmg commented 7 years ago

After changing the parameters.yml you need to clear the cache.

In the managed-edition you can do that via

php vendor/bin/contao-console cache:clear

or use the Contao Manager.

In the standard-edition you can do that via

php bin/console cache:clear

Or simply delete the folder var/cache/prod manually.

arechsteiner commented 7 years ago

Correct me if I'm wrong but I think the .zip version does not include this php bin/console cache:clear command at all. In my local installation there is no bin folder and the command returns Could not open input file: bin/console.

Deleting the folder manually did the trick

fritzmg commented 7 years ago

Correct me if I'm wrong but I think the .zip version does not include this php bin/console cache:clear command at all.

Read my post again ;). bin/console is for the standard-edition (or any Symfony standard application). Since you are talking about the ".zip version" you are refering to the managed-edition.

arechsteiner commented 7 years ago

Ah. I did not realize that the .zip version was also know as the managed-edition. Thanks it all works now.

I still think this should be fixed either in the documentation or in the install tool itself.

fritzmg commented 7 years ago

I still think this should be fixed either in the documentation or in the install tool itself.

Agreed.

leofeyer commented 7 years ago

I don't think we can fix this in the install tool, because the only possible fix is to purge the Symfony cache as soon as the install tool is opened. However, we are only purging the cache after the install tool password has been entered to prevent random people from deleting your cache by simply opening the install tool (which is not a protected route).

So I guess we should update the manual, shouldn't we @contao/developers?

fritzmg commented 7 years ago

But couldn't a fallback be implemented, when the database connection is not valid? Similar to https://github.com/contao/core-bundle/pull/889

arechsteiner commented 7 years ago

@leofeyer: I'm not too familiar with the Contao code base but there has to be a better way than this, no?

What about a two step process? If the MySQL connection fails after logging in to the install tool, display a prompt "MySQL connection failed, would you like to reconfigure your MySQL settings?". If the user clicks yes, then reset parameters.yml and reconfigure those settings. Or do that automatically (which is what I expected originally).

Is that not technically possible?

I feel like this is such a common use case that it should be handled via the user interface if possible to increase the user experience.

leofeyer commented 7 years ago

Does the issue still occur in Contao 4.4.1?

fritzmg commented 7 years ago

Nope, as far as I tested it, it is fixed now :)

  1. Installed Contao 4.4.1 with a valid database connection.
  2. Changed the database user credentials on the database server.
  3. Opened the Install Tool again - it simply shows the "Database connection" form after entering the password.
  4. After updating the credentials via the Install Tool, everything works as expected.
leofeyer commented 7 years ago

🎉