r69020 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69019‎ | r69020 | r69021 >
Date:21:25, 4 July 2010
Author:avar
Status:ok
Tags:
Comment:
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 (modified) (history)
  • /trunk/phase3/includes/installer/InstallerDBType.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/WebInstaller.php
@@ -1571,10 +1571,22 @@
15721572 }
15731573 $this->startForm();
15741574 $this->addHTML("<ul>");
1575 - foreach( $this->parent->getInstallSteps() as $step ) {
 1575+ foreach( $this->parent->getInstallSteps() as $stepObj ) {
 1576+ $step = is_array( $stepObj ) ? $stepObj['name'] : $stepObj;
15761577 $this->startStage( "config-install-$step" );
1577 - $func = 'install' . ucfirst( $step );
1578 - $status = $this->parent->{$func}();
 1578+ $status = null;
 1579+
 1580+ # Call our working function
 1581+ if ( is_array( $step ) ) {
 1582+ # A custom callaback
 1583+ $callback = $stepObj['callback'];
 1584+ $status = call_user_func_array( $callback, array() );
 1585+ } else {
 1586+ # Boring implicitly named callback
 1587+ $func = 'install' . ucfirst( $step );
 1588+ $status = $this->parent->{$func}();
 1589+ }
 1590+
15791591 $ok = $status->isGood();
15801592 if ( !$ok ) {
15811593 $this->parent->showStatusErrorBox( $status );
Index: trunk/phase3/includes/installer/Installer.php
@@ -128,7 +128,6 @@
129129
130130 var $installSteps = array(
131131 'database',
132 - 'user',
133132 'tables',
134133 'interwiki',
135134 'secretkey',
Index: trunk/phase3/includes/installer/MysqlInstaller.php
@@ -31,6 +31,20 @@
3232 function getName() {
3333 return 'mysql';
3434 }
 35+
 36+ function __construct( $parent ) {
 37+ parent::__construct( $parent );
 38+
 39+ # Add our user callback to installSteps, right before the tables are created.
 40+ $where_tables = array_search( "tables", $this->parent->installSteps );
 41+ $callback = array(
 42+ array(
 43+ 'name' => 'user',
 44+ 'callback' => array( &$this, 'setupUser' ),
 45+ )
 46+ );
 47+ array_splice( $this->parent->installSteps, $where_tables, 0, $callback );
 48+ }
3549
3650 function isCompiled() {
3751 return $this->checkExtension( 'mysql' );
Index: trunk/phase3/includes/installer/InstallerDBType.php
@@ -86,18 +86,6 @@
8787 abstract function setupDatabase();
8888
8989 /**
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 - /**
10290 * Create database tables from scratch
10391 * @return \type Status
10492 */

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r69008new-installer: GRANT permissions to our new non-root user by sourcing users.sql...avar16:16, 4 July 2010

Status & tagging log