Forum

Thread tagged as: Error, Installation

Fix for Local Installation Bug (bug report)

It appears if you want to setup Perch locally with a MySQL database that uses the default blank password, local installation fails.

On the first screen where you enter the username and blank password and click the test button, everything appears fine. Then you setup the admin user and perch complains it "could not connect to the database". If you view config.php, PERCH_DB_PASSWORD constant is set to db_pass, which seems like a bug to me. If you manually edit that constant to be:

define("PERCH_DB_PASSWORD", '');

you are then allowed to proceed to the login screen. However, the users table is empty from the failed setup, so there is no possible way to login.

The workaround is to make a manual fix BEFORE the config.php file is rendered if you want the possibility to login at all. So whenever I install perch locally for testing, and want to use the default blank MySQL password, I do this:

First make sure you have deleted the database tables if you've had a failed installation already, and cleared your config.php file. Then, edit file: (perch directory)/setup/PerchSetup_Installation.class.php

Temporarily change Line 116:

            'db_password'    => $data['db']['db_pass'],

To:

            'db_password'    => '',

Then go through the normal setup process. The admin user will be created successfully.

Once you're setup, you can go back in and change line 116 back to what it was before and everything will work fine.

There's probably a better place in the perch code to check for a blank password and actually fix this bug, but this works for me for now. Of course you can also just set a password for your local MySQL database before you run setup, but I prefer to make perch work with my chosen setup for my environment, rather than modify my environment just to suit this installation bug.

Hope this helps someone.

Dominic Tocci

Dominic Tocci 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It's not actually a bug - we don't support installing without a password due to the number of people who (regrettably) don't use a local development environment and install directly on a server.

Thanks for the info. But you can differentiate between the two installation types based on the license key, no? So why not allow blank passwords as long as the license key has "LOCAL" in it?

Incidentally, I almost didn't give Perch a chance because I couldn't get past that hurdle when setting things up to test it. Luckily I was uncharacteristically persistent that day. There's a good chance you're losing some would-be customers because of this bug/not-bug. Anyway, maybe a few of those people will search up this thread and install with a bit less frustration.

Thank you so so much for this fix Dominic!

Being a young and inexperienced developer, this problem is not so easy to spot/fix.

For anyone using your CMS for a website which is still underdevelopment: I think they should at least be able to make it past the installation stage without having to manually change perch code.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

As Drew explained, this is a security measure.

I think the ideal solution to this would NOT be making Perch less secure (I wouldn't pay for that), but rather adding more context to the error message to notify the user they need to set a password.

Also, it is a good practice to emulate your production environment as closely as possible. If your production environment requires a password to access the database (it should), so should your development environment.