35 if ( !$status->isOK() ) {
39 $conn = $status->getDB();
44 if ( $this->getOption(
'CreateDBAccount' ) ) {
50 'password' => $password,
56 $grantableNames[] = $this->buildFullUserName( $conn, $dbUser, $server );
62 $grantableNames[] = $this->buildFullUserName( $conn, $dbUser, $server );
70 'localhost.localdomain',
74 $createHostList = array_unique( $createHostList );
75 $escPass = $conn->addQuotes( $password );
77 foreach ( $createHostList as $host ) {
78 $fullName = $this->buildFullUserName( $conn, $dbUser, $host );
79 if ( !$this->userDefinitelyExists( $conn, $host, $dbUser ) ) {
81 $conn->begin( __METHOD__ );
82 $conn->query(
"CREATE USER $fullName IDENTIFIED BY $escPass", __METHOD__ );
83 $conn->commit( __METHOD__ );
84 $grantableNames[] = $fullName;
85 }
catch ( DBQueryError $dqe ) {
86 if ( $conn->lastErrno() == 1396 ) {
88 $conn->rollback( __METHOD__ );
89 $status->warning(
'config-install-user-alreadyexists', $dbUser );
90 $grantableNames[] = $fullName;
95 $conn->rollback( __METHOD__ );
96 $status->warning(
'config-install-user-create-failed', $dbUser, $dqe->getMessage() );
100 $status->warning(
'config-install-user-alreadyexists', $dbUser );
101 $grantableNames[] = $fullName;
109 foreach ( $grantableNames as $name ) {
111 $conn->begin( __METHOD__ );
112 $conn->query(
"GRANT ALL PRIVILEGES ON $dbAllTables TO $name", __METHOD__ );
113 $conn->commit( __METHOD__ );
114 }
catch ( DBQueryError $dqe ) {
115 $conn->rollback( __METHOD__ );
116 $status->fatal(
'config-install-user-grant-failed', $dbUser, $dqe->getMessage() );