-
Notifications
You must be signed in to change notification settings - Fork 40
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
[DX] Switch to a simplified array syntax for database connection information in settings.php #2231
Comments
I experienced a similar issue with a password that included special characters, the only difference was that I did not see an error message, just a blank page during install. Not sure what would be the best way to address this. |
Today I got the same, or very similar, issue again. Installation of Backdrop failed, displaying the general message "The website encountered an unexpected error. Please try again later." When I went back to the site URL without the installer related query strings, I got a more specific notice:
As in the first post above, it looks again like a database driver related issue. (Maybe sort of misleading, because the driver is the first element of So I ask again: are particular special characters not supported in the database password string? |
I just ran into this on a test installation of 1.6.3, where the password contained a semicolon (;) and a hash (#) character on two different/adjacent locations in the password. I replaced those two with underscores (so that at least it had 1 special character in it)(using the cPanel tool to update/change existing dbuser passwords), reloaded the error page, and the installation continued without any further problems. |
Documenting for testing purposes: characters mentioned in the posts above that might be problematic:
Feel free to add more. |
This is because the bootstrap is using parse_url() to load this string into an array, so anything that is part of the url schema is problematic. Edit: Found documentation related to using the array format in settings.php. Tested and it works. This should allow special characters without issue. Edit 2: Deleting all my custom code non-sense. I think we should instruct people to use the array syntax in settings.php. |
@daggerhart Do you suggest to change |
I just hit this using an autogenerated password. It was a big pain to sort out as things had already been partially installed and I had to:
|
@olafgrabienski sorry, i missed your message to me. Yes, if we change to using the array format during settings.php generation, we'll avoid users running into issues like @laryn just experienced. I don't know of any great reason to using the single string/url format. As a user, I think it is much harder to understand because you have to be somewhat familiar with authentication based url syntax and avoid its special characters. Whereas the array syntax is very clear about what each value is, and (as far as i know) doesn't have any limitations concerning special characters. |
@quicksketch @jenlampton To fix errors during installation due to special characters in the database password: Do you think it's possible to change the database configuration in |
@olafgrabienski backdrop does not need to use the single string format, the array format from Drupal 7 will work as well. |
Thanks @jenlampton ! To change |
There's no need for a PR, backdrop already works this way.
On your site: copy the array syntax from a D7 settings.php file and see if that fixes the problem. If so we can close this issue.
|
@jenlampton If we want it to use the array syntax by default on new installs (to avoid the special characters in the MySQL password causing a problem) we'd at least need a PR to change the default |
We don't want to use the ugly array syntax by default.
The simper syntax was chosen because all people will understand it
instantly. It's a universal syntax, and will benefit 100% of backdrop
users. For the minority of sites that still need to use the array syntax
for any of the various edge-cases, that Is an option too.
…On Jun 7, 2017 10:18 AM, "Laryn - CEDC.org" ***@***.***> wrote:
@jenlampton <https://github.com/jenlampton> If we want it to use the
array syntax by default on new installs (to avoid the special characters in
the MySQL password causing a problem) we'd at least need a PR to change the
default settings.php file, wouldn't we? And maybe some fixes where
Backdrop saves settings during installation?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2231 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAYSRxL2J6SSgrEuKRqzx8MiETXrlS2Jks5sBttsgaJpZM4KFxLV>
.
|
@jenlampton Can you think of another solution to the special character issue caused by the single line syntax? (ie. what this thread is about) I don't think I'd call that an 'edge case' and expect new users who run into this to be able to figure out why they can't even install Backdrop in the first place. For example, using the cPanel "generate password" functionality on a new MySQL database user will almost always include a special character like this. |
It's important that we avoid using a crazy backdrop-specific database connection syntax (by default) because that's the first thing people will see in settings.php. New users will see that first when setting up Backdrop, and that creates a poor first impression too. Another thing we should do is make the installer UI be smarter about special characters in the database password. If a user enters one into the UI during installation, the installer should switch to using the crazy syntax when it writes to settings.php, or escape special characters when necessary. At the very least, it could throw an error or warning message letting people know what's up rather than just crashing the site. :( Since what we're using now is a universal syntax, maybe we could look at what other all the other systems are doing about it, for reference? |
I'm not sure what's so bad about the array format (I actually think it's clearer). How often will the 80% need to open That said, I don't really have strong opinions as long as the issue gets solved. |
Sorry @jenlampton, but I'm with the rest of the people on this one...
Now, if we can find an easy way to make the password field smart enough to detect and escape problematic characters before writing to the settings.php file, then I'm equally OK with that. |
...to sum things up:
I agree.
These people will most likely be developers. Site builders do not mess with the settings.php file. At least beginner site builders that expect things to work from the UI.
Not poorer impression than a "broken" installer that "doesn't work" and that leads you to have to fiddle with code. |
Agreed. |
I think we may all be missing the point here. Changing the syntax back to the mess from D7 is not the only answer. If we want to fix the UX of the installer, good, let's do that! :) If we want to improve the DX of the settings.php file, fine, let's do that too! But let's not move backwards. Let's find a new solution that doesn't have all the same problems that we've already solved.
These two things are unrelated. We don't need to break the DX to fix the UX :) Let's fix all the things! |
@jenlampton I think the 187 lines of documentation still exist; we just moved them to our docs site. 😄
Here's what it would look like:
I dearsay I think the latter is certainly less scary. In either case if we continue to use the string format, we must concede that users will have issues with password generators OR they will get nasty exceptions. Or we come up with an alternative to |
yes, because they aren't necessary anymore for people reading the settings.php file, thanks to our new cleaner syntax ;)
I gave two examples above of how this can be avoided...
Here's a third option, what WP does: https://codex.wordpress.org/Editing_wp-config.php |
Sorry missing those, can you explain? Solutions are always a good thing. |
/**
* Database configuration:
*
* Most sites can configure their database by entering the connection details
* below. If using master/slave databases or multiple connections, see the
* advanced database documentation at
* https://api.backdropcms.org/database-configuration
*/
$database = array(
'driver' => 'mysql',
'database' => 'databasename',
'username' => 'username',
'password' => 'password',
'host' => 'localhost',
'prefix' => '',
); This example looks pretty clean and tidy... Does this work for backdrop already? Can we test it real quick? |
If a user enters a password with special characters into the UI during installation, the installer should 1) switch to using the array syntax when it writes that info into settings.php, or 2) properly escape special characters (like slashes, using URI hex encodings) when necessary. |
I noticed that this wasn't working for CLI install. I have added these in as To make configurable in the CLI, we would need to either move Bee can (and will) be adapted as required. EDIT: And now cSpell passes ???? EDIT: if you want to test on something like Lando or another system that provides the db settings at server level, you may need to add this line to your if (isset($_SERVER["BACKDROP_SETTINGS"])) unset($_SERVER["BACKDROP_SETTINGS"]); |
I'm having some difficulty understanding the instructions on testing this. I guess I may just have to experiment with it in conjunction with the PR.
|
@izmeez - in Lando (and possibly in other docker-based systems) the database settings are never written to |
I posted a review to the PR: backdrop/backdrop#4567 (review) Overall, looking great! |
Thanks @quicksketch - I learned a new bit of syntax and have implemented those changes. The change from I have tested this through the UI and through |
As @yorkshire-pudding is already advocating for this issue and this is close to completion, this should be in the 1.30.0 milestone (as I just moved it). |
@yorkshire-pudding I tried out this PR and ran into some issues with some edge-case handling. We have a special check in But that check conflicted with this change because it tried to automatically rewrite So to avoid going down the rabbit hole of needing to expand The entire localhost/127.0.0.1 swapping seems to be less of an issue than it was previously, due to the increase in tools like DDEV and Lando. So removing the automatic attempt fix the issue and request the user set a different value seems okay to me. @yorkshire-pudding Please take a look at my changes (made directly on your PR) and see if you'd suggest anything different. |
@quicksketch - your changes make sense. I have no way to test this 'host' scenario. |
I merged backdrop/backdrop#4567 for 1.30.0 that should fully fix the original problem by avoiding needing to URL encode values entirely. This original issue was mostly solved back in 2019 by @jlfranklin (#2231 (comment)). A big thanks to @yorkshire-pudding for finishing the job! backdrop/backdrop@c53e13d by @yorkshire-pudding, @klonos, @izmeez, @quicksketch, @olafgrabienski, and @bugfolder. This issue is code complete but we need to both update the documentation page at https://docs.backdropcms.org/documentation/database-configuration and write a change record. |
I'll start the Change record first. |
I've added a change record at https://docs.backdropcms.org/change-records/database-configuration-can-now-be-stored-in-a-simple-array I've spotted that @quicksketch has already published a change record for 1.30.0 so I have published this. Edit if required. |
I just tried to install Backdrop 1.5 in a local AMPPS environment. During installation, after being on the language page, I got the message
Fatal error: Class 'DatabaseTasks_' not found in {...}/core/includes/install.inc on line 1362
and wasn't able to continue the installation.
Line 1362 concerns the database driver. Googling something like drupal error database driver led me to a comment on d.org regarding Backup and Migrate about a problem with special characters in the database password string. I had a look in my settings.php, noticed a forward slash in the password string, changed the database password in the relevant places and was able to continue the installation.
Are forward slashes (and possibly particular other special characters) in the database password string not supported by Backdrop for a certain technical reason? If so, we should document it somewhere. If not, can we fix that?
ADVOCATE: @yorkshire-pudding
The text was updated successfully, but these errors were encountered: