Index: trunk/phase3/includes/installer/Installer.i18n.php |
— | — | @@ -419,6 +419,8 @@ |
420 | 420 | 'config-install-database' => 'Setting up database', |
421 | 421 | 'config-install-pg-schema-failed' => 'Tables creation failed. |
422 | 422 | Make sure that the user "$1" can write to the schema "$2".', |
| 423 | + 'config-install-user' => 'Creating database user', |
| 424 | + 'config-install-user-failed' => 'Granting permission to user "$1" failed: $2', |
423 | 425 | 'config-install-tables' => 'Creating tables', |
424 | 426 | 'config-install-interwiki' => 'Populating default interwiki table', |
425 | 427 | 'config-install-interwiki-sql' => 'Could not find file <code>interwiki.sql</code>', |
Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -128,6 +128,7 @@ |
129 | 129 | |
130 | 130 | var $installSteps = array( |
131 | 131 | 'database', |
| 132 | + 'user', |
132 | 133 | 'tables', |
133 | 134 | 'interwiki', |
134 | 135 | 'secretkey', |
— | — | @@ -870,6 +871,12 @@ |
871 | 872 | return $status; |
872 | 873 | } |
873 | 874 | |
| 875 | + public function installUser() { |
| 876 | + $installer = $this->getDBInstaller( $this->getVar( 'wgDBtype' ) ); |
| 877 | + $status = $installer->setupUser(); |
| 878 | + return $status; |
| 879 | + } |
| 880 | + |
874 | 881 | public function installTables() { |
875 | 882 | $installer = $this->getDBInstaller(); |
876 | 883 | $status = $installer->createTables(); |
Index: trunk/phase3/includes/installer/MysqlInstaller.php |
— | — | @@ -376,6 +376,28 @@ |
377 | 377 | return $status; |
378 | 378 | } |
379 | 379 | |
| 380 | + function setupUser() { |
| 381 | + global $IP; |
| 382 | + |
| 383 | + if ( !$this->getVar( '_CreateDBAccount' ) ) { |
| 384 | + return; |
| 385 | + } |
| 386 | + |
| 387 | + $status = $this->getConnection(); |
| 388 | + if ( !$status->isOK() ) { |
| 389 | + return $status; |
| 390 | + } |
| 391 | + |
| 392 | + $db = $this->getVar( 'wgDBname' ); |
| 393 | + $this->db->selectDB( $db ); |
| 394 | + $error = $this->db->sourceFile( "$IP/maintenance/users.sql" ); |
| 395 | + if ( !$error ) { |
| 396 | + $status->fatal( 'config-install-user-failed', $this->getVar( 'wgDBuser' ), $error ); |
| 397 | + } |
| 398 | + |
| 399 | + return $status; |
| 400 | + } |
| 401 | + |
380 | 402 | function createTables() { |
381 | 403 | global $IP; |
382 | 404 | $status = $this->getConnection(); |
Index: trunk/phase3/includes/installer/InstallerDBType.php |
— | — | @@ -86,6 +86,18 @@ |
87 | 87 | abstract function setupDatabase(); |
88 | 88 | |
89 | 89 | /** |
| 90 | + * Create a new non-root user for the database and return a Status |
| 91 | + * object indicating success or failure. A default implementation |
| 92 | + * that returns a good status is supplied for those databases that |
| 93 | + * don't need to set up users. |
| 94 | + * |
| 95 | + * @return Status |
| 96 | + */ |
| 97 | + function setupUser() { |
| 98 | + return Status::newGood(); |
| 99 | + } |
| 100 | + |
| 101 | + /** |
90 | 102 | * Create database tables from scratch |
91 | 103 | * @return \type Status |
92 | 104 | */ |