'config-install-database' => 'Setting up database',
'config-install-pg-schema-failed' => 'Tables creation failed.
Make sure that the user "$1" can write to the schema "$2".',
+ 'config-install-user' => 'Creating database user',
+ 'config-install-user-failed' => 'Granting permission to user "$1" failed: $2',
'config-install-tables' => 'Creating tables',
'config-install-interwiki' => 'Populating default interwiki table',
'config-install-interwiki-sql' => 'Could not find file <code>interwiki.sql</code>',
var $installSteps = array(
'database',
+ 'user',
'tables',
'interwiki',
'secretkey',
return $status;
}
+ public function installUser() {
+ $installer = $this->getDBInstaller( $this->getVar( 'wgDBtype' ) );
+ $status = $installer->setupUser();
+ return $status;
+ }
+
public function installTables() {
$installer = $this->getDBInstaller();
$status = $installer->createTables();
*/
abstract function setupDatabase();
+ /**
+ * Create a new non-root user for the database and return a Status
+ * object indicating success or failure. A default implementation
+ * that returns a good status is supplied for those databases that
+ * don't need to set up users.
+ *
+ * @return Status
+ */
+ function setupUser() {
+ return Status::newGood();
+ }
+
/**
* Create database tables from scratch
* @return \type Status
return $status;
}
+ function setupUser() {
+ global $IP;
+
+ if ( !$this->getVar( '_CreateDBAccount' ) ) {
+ return;
+ }
+
+ $status = $this->getConnection();
+ if ( !$status->isOK() ) {
+ return $status;
+ }
+
+ $db = $this->getVar( 'wgDBname' );
+ $this->db->selectDB( $db );
+ $error = $this->db->sourceFile( "$IP/maintenance/users.sql" );
+ if ( !$error ) {
+ $status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ), $error );
+ }
+
+ return $status;
+ }
+
function createTables() {
global $IP;
$status = $this->getConnection();