octobercms / october

Self-hosted CMS platform based on the Laravel PHP Framework.
https://octobercms.com/
Other
11.03k stars 2.21k forks source link

Database connection lost after running command php artisan october:env if mysql password has quotes in database.php file #4979

Closed najbo closed 4 years ago

najbo commented 4 years ago

Description:

Hello,

I get a mysql connection error after running command php artisan october:env ; everything worked fine before. I realized it was because I used a quote caracter (" or ') in the password. Password was correctly written in file config/database.php but quote caracter was removed in .env after running command artisan october:env.

The password was generated by ISP and I can't change it. Of course, I just could change the password in the new generated .env file ; but there is a risk that some people spend a lot of time looking for the solution.

I installed OctoberCMS via command line and composer. Password for mysql database was entered during normal CLI installation.

Steps To Reproduce:

  1. Install OctoberCMS via composer command composer create-project october/october myoctober
  2. Enter a password for mysql database during normal database questions. Enter for example 3$Zvt?2dF.~"fZ*
  3. Finalize installation and check that everything works fine (frontend and backend)
  4. Execute command php artisan october:env for creating dot env configuration file
  5. Refresh backend end and confirm that there is now a mysql error (missing database)
  6. Open the new created .env file and check that quote caracter is missing for mysql password : 3$Zvt?2dF.~fZ*

Issue is something similar to #3054 and #2361.

Something else ?

Yes ! Thanks a lot for your work and this amazing CMS !

bugzbrown commented 4 years ago

I've confirmed that this is in fact a bug and created a pull request that addresses this issue:

https://github.com/octobercms/october/pull/4983

Hope it gets accepted :)

LukeTowers commented 4 years ago

@bennothommo we also need to make sure that the october:env command is surrounding all env values with quotes, or at the very least any with a # character in it.

bennothommo commented 4 years ago

@LukeTowers I'll have to run some tests, because I believe a quote in the middle of a string is invalid as well if it's not escaped - I presume this is why it was opted to just remove them completely.

najbo commented 4 years ago

I've confirmed that this is in fact a bug and created a pull request that addresses this issue:

4983

Hope it gets accepted :)

Thanks a lot !

bennothommo commented 4 years ago

@najbo I'm going to re-open this as it is a confirmed bug and I'm working on a unit test and possible fix (if @bugzbrown is unable to complete their fix).

najbo commented 4 years ago

Okay perfect, thanks a lot