http://www.mediawiki.org/wiki/Special:Code/MediaWiki/69020
Revision: 69020
Author: avar
Date: 2010-07-04 21:25:16 +0000 (Sun, 04 Jul 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/phase3/includes/installer/Installer.php
trunk/phase3/includes/installer/InstallerDBType.php
trunk/phase3/includes/installer/MysqlInstaller.php
trunk/phase3/includes/installer/WebInstaller.php
Modified: trunk/phase3/includes/installer/Installer.php
===================================================================
--- trunk/phase3/includes/installer/Installer.php 2010-07-04 21:13:09 UTC
(rev 69019)
+++ trunk/phase3/includes/installer/Installer.php 2010-07-04 21:25:16 UTC
(rev 69020)
@@ -128,7 +128,6 @@
var $installSteps = array(
'database',
- 'user',
'tables',
'interwiki',
'secretkey',
Modified: trunk/phase3/includes/installer/InstallerDBType.php
===================================================================
--- trunk/phase3/includes/installer/InstallerDBType.php 2010-07-04 21:13:09 UTC
(rev 69019)
+++ trunk/phase3/includes/installer/InstallerDBType.php 2010-07-04 21:25:16 UTC
(rev 69020)
@@ -86,18 +86,6 @@
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
*/
Modified: trunk/phase3/includes/installer/MysqlInstaller.php
===================================================================
--- trunk/phase3/includes/installer/MysqlInstaller.php 2010-07-04 21:13:09 UTC
(rev 69019)
+++ trunk/phase3/includes/installer/MysqlInstaller.php 2010-07-04 21:25:16 UTC
(rev 69020)
@@ -31,6 +31,20 @@
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' );
Modified: trunk/phase3/includes/installer/WebInstaller.php
===================================================================
--- trunk/phase3/includes/installer/WebInstaller.php 2010-07-04 21:13:09 UTC
(rev 69019)
+++ trunk/phase3/includes/installer/WebInstaller.php 2010-07-04 21:25:16 UTC
(rev 69020)
@@ -1571,10 +1571,22 @@
}
$this->startForm();
$this->addHTML("<ul>");
- foreach( $this->parent->getInstallSteps() as $step ) {
+ foreach( $this->parent->getInstallSteps() as $stepObj ) {
+ $step = is_array( $stepObj ) ? $stepObj['name'] :
$stepObj;
$this->startStage( "config-install-$step" );
- $func = 'install' . ucfirst( $step );
- $status = $this->parent->{$func}();
+ $status = null;
+
+ # Call our working function
+ if ( is_array( $step ) ) {
+ # A custom callaback
+ $callback = $stepObj['callback'];
+ $status = call_user_func_array( $callback,
array() );
+ } else {
+ # Boring implicitly named callback
+ $func = 'install' . ucfirst( $step );
+ $status = $this->parent->{$func}();
+ }
+
$ok = $status->isGood();
if ( !$ok ) {
$this->parent->showStatusErrorBox( $status );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs