Skip to content
Snippets Groups Projects
Commit 7851004a authored by Neil Drumm's avatar Neil Drumm :wave:
Browse files

#81218 by chx. Allow install.php to act on array db urls and prefixes.

parent 03be9b6f
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -106,7 +106,7 @@ function install_verify_settings() { ...@@ -106,7 +106,7 @@ function install_verify_settings() {
// We need this because we want to run form_get_errors. // We need this because we want to run form_get_errors.
include_once './includes/form.inc'; include_once './includes/form.inc';
$url = parse_url($db_url); $url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url);
$db_user = urldecode($url['user']); $db_user = urldecode($url['user']);
$db_pass = urldecode($url['pass']); $db_pass = urldecode($url['pass']);
$db_host = urldecode($url['host']); $db_host = urldecode($url['host']);
...@@ -128,7 +128,7 @@ function install_verify_settings() { ...@@ -128,7 +128,7 @@ function install_verify_settings() {
function install_change_settings($profile = 'default', $install_locale = '') { function install_change_settings($profile = 'default', $install_locale = '') {
global $db_url, $db_type, $db_prefix; global $db_url, $db_type, $db_prefix;
$url = parse_url($db_url); $url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url);
$db_user = urldecode($url['user']); $db_user = urldecode($url['user']);
$db_pass = urldecode($url['pass']); $db_pass = urldecode($url['pass']);
$db_host = urldecode($url['host']); $db_host = urldecode($url['host']);
...@@ -304,7 +304,7 @@ function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pas ...@@ -304,7 +304,7 @@ function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pas
} }
// Verify database prefix // Verify database prefix
if (!empty($db_prefix) && preg_match('/[^A-Za-z0-9_]/', $db_prefix)) { if (!empty($db_prefix) && is_string($db_prefix) && preg_match('/[^A-Za-z0-9_]/', $db_prefix)) {
form_set_error('db_prefix', st('The database prefix you have entered, %db_prefix, is invalid. The database prefix can only contain alphanumeric characters and underscores.', array('%db_prefix' => $db_prefix)), 'error'); form_set_error('db_prefix', st('The database prefix you have entered, %db_prefix, is invalid. The database prefix can only contain alphanumeric characters and underscores.', array('%db_prefix' => $db_prefix)), 'error');
} }
...@@ -314,7 +314,8 @@ function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pas ...@@ -314,7 +314,8 @@ function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pas
// Check database type // Check database type
if (!isset($form)) { if (!isset($form)) {
$db_type = substr($db_url, 0, strpos($db_url, '://')); $_db_url = is_array($db_url) ? $db_url['default'] : $db_url;
$db_type = substr($_db_url, 0, strpos($_db_url, '://'));
} }
$databases = drupal_detect_database_types(); $databases = drupal_detect_database_types();
if (!in_array($db_type, $databases)) { if (!in_array($db_type, $databases)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment