From 0307faa10d4f9dd0d13e6e8412fb9028c047087f Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sun, 4 Jul 2010 21:25:16 +0000 Subject: [PATCH] new-installer: A better implementation of the database user creation added in r69008 Since MysqlInstaller isn't in the same class hierarchy as WebInstaller the database user functions I added in r69008 messed up the namespace for non-MySQL, and added redundant user creation messages to e.g. SQLite, which doesn't even have users. Instead support either a plain string in $installSteps, or an array that has callback data that'll be called with call_user_func_array. The implementation is a bit ad-hoc, we should probably move the magic in Hooks.php's wfRunHooks to some general library function so we can use that here, or perhaps just implement these installSteps with something like: $wgHook['Installer::steps'][] = array(...) And then use wfRunHooks to run all the steps. But in the meantime this'll do. This breaks the nascent CliInstaller (indicating that we should do these calls better), and I haven't added the equivalent functionality to $envChecks. --- includes/installer/Installer.php | 1 - includes/installer/InstallerDBType.php | 12 ------------ includes/installer/MysqlInstaller.php | 14 ++++++++++++++ includes/installer/WebInstaller.php | 18 +++++++++++++++--- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 24da5cc138..47637d1183 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -128,7 +128,6 @@ abstract class Installer { var $installSteps = array( 'database', - 'user', 'tables', 'interwiki', 'secretkey', diff --git a/includes/installer/InstallerDBType.php b/includes/installer/InstallerDBType.php index 46269a05d2..9703f4b57d 100644 --- a/includes/installer/InstallerDBType.php +++ b/includes/installer/InstallerDBType.php @@ -85,18 +85,6 @@ abstract class InstallerDBType { */ 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 diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index c0829f42d2..1951f9b359 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -31,6 +31,20 @@ class MysqlInstaller extends InstallerDBType { function getName() { return 'mysql'; } + + function __construct( $parent ) { + parent::__construct( $parent ); + + # Add our user callback to installSteps, right before the tables are created. + $where_tables = array_search( "tables", $this->parent->installSteps ); + $callback = array( + array( + 'name' => 'user', + 'callback' => array( &$this, 'setupUser' ), + ) + ); + array_splice( $this->parent->installSteps, $where_tables, 0, $callback ); + } function isCompiled() { return $this->checkExtension( 'mysql' ); diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index f5ada78ba8..40057d436e 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -1571,10 +1571,22 @@ class WebInstaller_Install extends WebInstallerPage { } $this->startForm(); $this->addHTML("