From 0cf4e92decfee98985eed96b31bdf4d814438ba2 Mon Sep 17 00:00:00 2001 From: pubudu538 Date: Sat, 15 Mar 2014 12:37:07 +0530 Subject: [PATCH] Error Msg for missing db username & password when installing Added configurations for Mysql and Postgresql installers to display an error message if user doesnt input a username to the database username Bug: 43528 Bug: 59663 Change-Id: Ib6b05d2d7e8ebb4438d3b0051c33d367f41a9957 --- includes/installer/MysqlInstaller.php | 10 +++++++++- includes/installer/PostgresInstaller.php | 12 ++++++++++-- includes/installer/i18n/en.json | 1 + includes/installer/i18n/qqq.json | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 2d433244ae..4c725286e2 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -100,7 +100,9 @@ class MysqlInstaller extends DatabaseInstaller { public function submitConnectForm() { // Get variables from the request. - $newValues = $this->setVarsFromRequest( array( 'wgDBserver', 'wgDBname', 'wgDBprefix' ) ); + $newValues = $this->setVarsFromRequest( array( + 'wgDBserver', 'wgDBname', 'wgDBprefix', '_InstallUser', '_InstallPassword' + ) ); // Validate them. $status = Status::newGood(); @@ -115,6 +117,12 @@ class MysqlInstaller extends DatabaseInstaller { if ( !preg_match( '/^[a-z0-9_-]*$/i', $newValues['wgDBprefix'] ) ) { $status->fatal( 'config-invalid-db-prefix', $newValues['wgDBprefix'] ); } + if ( !strlen( $newValues['_InstallUser'] ) ) { + $status->fatal( 'config-db-username-empty' ); + } + if (!strlen( $newValues['_InstallPassword'] ) ) { + $status->fatal( 'config-db-password-empty', $newValues['_InstallUser'] ); + } if ( !$status->isOK() ) { return $status; } diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index 2cf41564f0..780431a4bf 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -83,8 +83,10 @@ class PostgresInstaller extends DatabaseInstaller { function submitConnectForm() { // Get variables from the request - $newValues = $this->setVarsFromRequest( array( 'wgDBserver', 'wgDBport', - 'wgDBname', 'wgDBmwschema' ) ); + $newValues = $this->setVarsFromRequest( array( + 'wgDBserver', 'wgDBport','wgDBname', 'wgDBmwschema', + '_InstallUser', '_InstallPassword' + ) ); // Validate them $status = Status::newGood(); @@ -96,6 +98,12 @@ class PostgresInstaller extends DatabaseInstaller { if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBmwschema'] ) ) { $status->fatal( 'config-invalid-schema', $newValues['wgDBmwschema'] ); } + if ( !strlen( $newValues['_InstallUser'] ) ) { + $status->fatal( 'config-db-username-empty' ); + } + if ( !strlen( $newValues['_InstallPassword'] ) ) { + $status->fatal( 'config-db-password-empty', $newValues['_InstallUser'] ); + } // Submit user box if ( $status->isOK() ) { diff --git a/includes/installer/i18n/en.json b/includes/installer/i18n/en.json index 45149c592b..32a99126a4 100644 --- a/includes/installer/i18n/en.json +++ b/includes/installer/i18n/en.json @@ -97,6 +97,7 @@ "config-db-username": "Database username:", "config-db-password": "Database password:", "config-db-password-empty": "Please enter a password for the new database user: $1.\nWhile it may be possible to create users with no passwords, it is not secure.", + "config-db-username-empty": "You must enter a value for \"Database username\"", "config-db-install-username": "Enter the username that will be used to connect to the database during the installation process.\nThis is not the username of the MediaWiki account; this is the username for your database.", "config-db-install-password": "Enter the password that will be used to connect to the database during the installation process.\nThis is not the password for the MediaWiki account; this is the password for your database.", "config-db-install-help": "Enter the username and password that will be used to connect to the database during the installation process.", diff --git a/includes/installer/i18n/qqq.json b/includes/installer/i18n/qqq.json index 06638535d5..3f610a602c 100644 --- a/includes/installer/i18n/qqq.json +++ b/includes/installer/i18n/qqq.json @@ -79,6 +79,7 @@ "config-db-wiki-settings": "This is more acurate: \"Enter identifying or distinguishing data for this wiki\" since a MySQL database can host tables of several wikis.", "config-db-account-oracle-warn": "A \"[[:wikipedia:Front and back ends|backend]]\" is a system or component that ordinary users don't interact with directly and don't need to know about, and that is responsible for a distinct task or service - for example, a storage back-end is a generic system for storing data which other applications can use. Possible alternatives for back-end are \"system\" or \"service\", or (depending on context and language) even leave it untranslated.", "config-db-password-empty": "Used as error message. Parameters:\n* $1 - database username", + "config-db-username-empty": "Used as error message. Shown when the database username is not entered by the user.", "config-db-account-lock": "It might be easier to translate ''normal operation'' as \"also after the installation process\"", "config-mysql-old": "Used as error message. Parameters:\n* $1 - minimum version\n* $2 - the version of MySQL that has been installed", "config-pg-test-error": "* $1 - database name\n* $2 - error message", -- 2.20.1