From 32b8199dacd055e0ce8e705af8a436d2a1890c51 Mon Sep 17 00:00:00 2001 From: wilsonge Date: Thu, 10 May 2018 01:34:54 +0100 Subject: [PATCH 1/3] Cleanup of messages in installation error cases --- installation/language/en-GB/en-GB.ini | 1 + installation/language/en-US/en-US.ini | 1 + .../src/Controller/InstallationController.php | 10 ++++--- installation/template/js/setup.js | 27 ++++++++++--------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/installation/language/en-GB/en-GB.ini b/installation/language/en-GB/en-GB.ini index fc6491f29c347..59cf272b4cf57 100644 --- a/installation/language/en-GB/en-GB.ini +++ b/installation/language/en-GB/en-GB.ini @@ -39,6 +39,7 @@ INSTL_DATABASE_NAME_LABEL="Database Name" INSTL_DATABASE_NO_SCHEMA="No database schema exists for this database type." INSTL_DATABASE_PASSWORD_DESC="Either a password you created or a password provided by your host." INSTL_DATABASE_PREFIX_DESC="Enter a table prefix or use the randomly generated one." +INSTL_DATABASE_PREFIX_MSG="The table prefix must start with a letter, be followed by optional alphanumeric characters and by an underscore" INSTL_DATABASE_TYPE_DESC="Select the database type." INSTL_DATABASE_USER_DESC="Either a username you created or a username provided by your host." INSTL_DATABASE_VALIDATION_ERROR="Check your database credentials, database type, database name or hostname" diff --git a/installation/language/en-US/en-US.ini b/installation/language/en-US/en-US.ini index 25356917f14b3..84e4df9b33361 100644 --- a/installation/language/en-US/en-US.ini +++ b/installation/language/en-US/en-US.ini @@ -162,6 +162,7 @@ INSTL_DATABASE_INVALID_NAME="MySQL versions previous to 5.1.6 may not contain pe INSTL_DATABASE_NAME_INVALID_SPACES="MySQL database names and table names may not begin or end with spaces." INSTL_DATABASE_NAME_INVALID_CHAR="No MySQL identifier can contain a NULL ASCII(0x00)." INSTL_DATABASE_FILE_DOES_NOT_EXIST="File %s does not exist" +INSTL_DATABASE_PREFIX_MSG="The table prefix must start with a letter, be followed by optional alphanumeric characters and by an underscore" INSTL_DATABASE_VALIDATION_ERROR="Check your database credentials, database type, database name or hostname" ;controllers diff --git a/installation/src/Controller/InstallationController.php b/installation/src/Controller/InstallationController.php index e2fa9cd7bb9ea..67be6de8ad129 100644 --- a/installation/src/Controller/InstallationController.php +++ b/installation/src/Controller/InstallationController.php @@ -60,12 +60,16 @@ public function dbcheck() // Check the form /** @var \Joomla\CMS\Installation\Model\SetupModel $model */ $model = $this->getModel('Setup'); - if ($model->checkForm('setup') === false || $model->validateDbConnection() === false) + if ($model->checkForm('setup') === false) { - $r->messages = Text::_('INSTL_DATABASE_VALIDATION_ERROR'); - $r->view = 'setup'; + $this->app->enqueueMessage(Text::_('INSTL_DATABASE_VALIDATION_ERROR'), 'error'); + $r->validated = false; + $this->sendJsonResponse($r); + return; } + $r->validated = $model->validateDbConnection(); + $this->sendJsonResponse($r); } diff --git a/installation/template/js/setup.js b/installation/template/js/setup.js index 6d90059ef1734..4e95ec923af83 100644 --- a/installation/template/js/setup.js +++ b/installation/template/js/setup.js @@ -84,20 +84,21 @@ Joomla.checkDbCredentials = function() { headers: {'Content-Type': 'application/x-www-form-urlencoded'}, onSuccess: function(response, xhr){ response = JSON.parse(response); - Joomla.loadingLayer('hide'); - Joomla.replaceTokens(response.token); - if (response.data.messages) { - Joomla.loadingLayer('hide'); - Joomla.renderMessages({ - "error": [response.data.messages] - }); - // You shall not pass, DB credentials error!!!! - } else { - Joomla.loadingLayer('hide'); + if (response.messages) { + Joomla.renderMessages(response.messages); + } - // Run the installer - we let this handle the redirect for now - // TODO: Convert to promises - Joomla.install(['config'], form); + Joomla.replaceTokens(response.token); + Joomla.loadingLayer("hide"); + + if (response.error) { + Joomla.renderMessages({'error': [response.message]}); + } else { + if (response.data && response.data.validated === true) { + // Run the installer - we let this handle the redirect for now + // TODO: Convert to promises + Joomla.install(['config'], form); + } } }, onError: function(xhr){ From 683067615111b9ca3cd05da9ddd91883ceb92809 Mon Sep 17 00:00:00 2001 From: wilsonge Date: Thu, 10 May 2018 09:07:11 +0100 Subject: [PATCH 2/3] Implement feedback --- installation/language/en-GB/en-GB.ini | 2 +- installation/language/en-US/en-US.ini | 2 +- installation/src/Controller/InstallationController.php | 1 + installation/template/js/setup.js | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/installation/language/en-GB/en-GB.ini b/installation/language/en-GB/en-GB.ini index 59cf272b4cf57..15ab0e6433110 100644 --- a/installation/language/en-GB/en-GB.ini +++ b/installation/language/en-GB/en-GB.ini @@ -39,7 +39,7 @@ INSTL_DATABASE_NAME_LABEL="Database Name" INSTL_DATABASE_NO_SCHEMA="No database schema exists for this database type." INSTL_DATABASE_PASSWORD_DESC="Either a password you created or a password provided by your host." INSTL_DATABASE_PREFIX_DESC="Enter a table prefix or use the randomly generated one." -INSTL_DATABASE_PREFIX_MSG="The table prefix must start with a letter, be followed by optional alphanumeric characters and by an underscore" +INSTL_DATABASE_PREFIX_MSG="The table prefix must start with a letter, optionally be followed by alphanumeric characters and by an underscore" INSTL_DATABASE_TYPE_DESC="Select the database type." INSTL_DATABASE_USER_DESC="Either a username you created or a username provided by your host." INSTL_DATABASE_VALIDATION_ERROR="Check your database credentials, database type, database name or hostname" diff --git a/installation/language/en-US/en-US.ini b/installation/language/en-US/en-US.ini index 84e4df9b33361..fca1eb64db031 100644 --- a/installation/language/en-US/en-US.ini +++ b/installation/language/en-US/en-US.ini @@ -162,7 +162,7 @@ INSTL_DATABASE_INVALID_NAME="MySQL versions previous to 5.1.6 may not contain pe INSTL_DATABASE_NAME_INVALID_SPACES="MySQL database names and table names may not begin or end with spaces." INSTL_DATABASE_NAME_INVALID_CHAR="No MySQL identifier can contain a NULL ASCII(0x00)." INSTL_DATABASE_FILE_DOES_NOT_EXIST="File %s does not exist" -INSTL_DATABASE_PREFIX_MSG="The table prefix must start with a letter, be followed by optional alphanumeric characters and by an underscore" +INSTL_DATABASE_PREFIX_MSG="The table prefix must start with a letter, optionally be followed by alphanumeric characters and by an underscore" INSTL_DATABASE_VALIDATION_ERROR="Check your database credentials, database type, database name or hostname" ;controllers diff --git a/installation/src/Controller/InstallationController.php b/installation/src/Controller/InstallationController.php index 67be6de8ad129..b7e0611a6a37c 100644 --- a/installation/src/Controller/InstallationController.php +++ b/installation/src/Controller/InstallationController.php @@ -65,6 +65,7 @@ public function dbcheck() $this->app->enqueueMessage(Text::_('INSTL_DATABASE_VALIDATION_ERROR'), 'error'); $r->validated = false; $this->sendJsonResponse($r); + return; } diff --git a/installation/template/js/setup.js b/installation/template/js/setup.js index 4e95ec923af83..5a6bb01427519 100644 --- a/installation/template/js/setup.js +++ b/installation/template/js/setup.js @@ -88,7 +88,7 @@ Joomla.checkDbCredentials = function() { Joomla.renderMessages(response.messages); } - Joomla.replaceTokens(response.token); + Joomla.replaceTokens(response.token); Joomla.loadingLayer("hide"); if (response.error) { From 42a628ec6193b31436b91c954afa124af5421198 Mon Sep 17 00:00:00 2001 From: George Wilson Date: Thu, 10 May 2018 10:59:21 +0100 Subject: [PATCH 3/3] Code cleanup --- installation/template/js/setup.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/installation/template/js/setup.js b/installation/template/js/setup.js index 5a6bb01427519..c869d4ffc62fd 100644 --- a/installation/template/js/setup.js +++ b/installation/template/js/setup.js @@ -93,12 +93,10 @@ Joomla.checkDbCredentials = function() { if (response.error) { Joomla.renderMessages({'error': [response.message]}); - } else { - if (response.data && response.data.validated === true) { - // Run the installer - we let this handle the redirect for now - // TODO: Convert to promises - Joomla.install(['config'], form); - } + } else if (response.data && response.data.validated === true) { + // Run the installer - we let this handle the redirect for now + // TODO: Convert to promises + Joomla.install(['config'], form); } }, onError: function(xhr){