summaryrefslogtreecommitdiff
path: root/includes/installer/MysqlInstaller.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/installer/MysqlInstaller.php')
-rw-r--r--includes/installer/MysqlInstaller.php33
1 files changed, 21 insertions, 12 deletions
diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php
index 5f76972c..b82e6114 100644
--- a/includes/installer/MysqlInstaller.php
+++ b/includes/installer/MysqlInstaller.php
@@ -65,7 +65,7 @@ class MysqlInstaller extends DatabaseInstaller {
}
/**
- * @return Bool
+ * @return bool
*/
public function isCompiled() {
return self::checkExtension( 'mysql' ) || self::checkExtension( 'mysqli' );
@@ -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;
}
@@ -268,9 +276,7 @@ class MysqlInstaller extends DatabaseInstaller {
if ( !$status->isOK() ) {
return false;
}
- /**
- * @var $conn DatabaseBase
- */
+ /** @var $conn DatabaseBase */
$conn = $status->value;
// Get current account name
@@ -436,13 +442,14 @@ class MysqlInstaller extends DatabaseInstaller {
if ( !$create ) {
// Test the web account
try {
- $db = DatabaseBase::factory( 'mysql', array(
+ DatabaseBase::factory( 'mysql', array(
'host' => $this->getVar( 'wgDBserver' ),
'user' => $this->getVar( 'wgDBuser' ),
'password' => $this->getVar( 'wgDBpassword' ),
'dbname' => false,
'flags' => 0,
- 'tablePrefix' => $this->getVar( 'wgDBprefix' ) ) );
+ 'tablePrefix' => $this->getVar( 'wgDBprefix' )
+ ) );
} catch ( DBConnectionError $e ) {
return Status::newFatal( 'config-connection-error', $e->getMessage() );
}
@@ -479,6 +486,7 @@ class MysqlInstaller extends DatabaseInstaller {
if ( !$status->isOK() ) {
return $status;
}
+ /** @var DatabaseBase $conn */
$conn = $status->value;
$dbName = $this->getVar( 'wgDBname' );
if ( !$conn->selectDB( $dbName ) ) {
@@ -516,13 +524,14 @@ class MysqlInstaller extends DatabaseInstaller {
if ( $this->getVar( '_CreateDBAccount' ) ) {
// Before we blindly try to create a user that already has access,
try { // first attempt to connect to the database
- $db = DatabaseBase::factory( 'mysql', array(
+ DatabaseBase::factory( 'mysql', array(
'host' => $server,
'user' => $dbUser,
'password' => $password,
'dbname' => false,
'flags' => 0,
- 'tablePrefix' => $this->getVar( 'wgDBprefix' ) ) );
+ 'tablePrefix' => $this->getVar( 'wgDBprefix' )
+ ) );
$grantableNames[] = $this->buildFullUserName( $dbUser, $server );
$tryToCreate = false;
} catch ( DBConnectionError $e ) {
@@ -594,7 +603,7 @@ class MysqlInstaller extends DatabaseInstaller {
* Return a formal 'User'@'Host' username for use in queries
* @param string $name Username, quotes will be added
* @param string $host Hostname, quotes will be added
- * @return String
+ * @return string
*/
private function buildFullUserName( $name, $host ) {
return $this->db->addQuotes( $name ) . '@' . $this->db->addQuotes( $host );
@@ -605,7 +614,7 @@ class MysqlInstaller extends DatabaseInstaller {
* access to mysql.user, so false means "no" or "maybe"
* @param string $host Hostname to check
* @param string $user Username to check
- * @return boolean
+ * @return bool
*/
private function userDefinitelyExists( $host, $user ) {
try {
@@ -622,7 +631,7 @@ class MysqlInstaller extends DatabaseInstaller {
* Return any table options to be applied to all tables that don't
* override them.
*
- * @return String
+ * @return string
*/
protected function getTableOptions() {
$options = array();