Improve installer:
authorRob Church <robchurch@users.mediawiki.org>
Sat, 14 Jan 2006 23:07:08 +0000 (23:07 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sat, 14 Jan 2006 23:07:08 +0000 (23:07 +0000)
* Use a superuser account (such as root), if specifed, to create tables
* Don't overwrite conservative permissions on the mySQL user with ALL permissions, if said user exists
* Changes to some of the wording of explanations for fields

This will pre-emptively fix an issue arising if the regular-use user doesn't have permissions to set up the schema, since the end-user must now indicate this and provide superuser account details. Follow-on from last night's fixing 921 et al.

RELEASE-NOTES
config/index.php

index 7382e61..5dfb357 100644 (file)
@@ -114,6 +114,14 @@ Images:
 Installer:
 * (bug 3782) Throw fatal installation warning if mbstring.func_overload on.
   Why do people invent these crazy options that change language semantics?
+* Fixed installer bugs 921 and 3914 (issues with using root and so forth)
+* (bug 4258) Use ugly urls for ISAPI by default
+  patch by Rob Church
+* Improve installer 
+       * Use a superuser account (such as root), if specifed, to create tables
+       * Don't overwrite conservative permissions on the mySQL user with ALL
+         permissions, if said user exists
+       * Changes to some of the wording of explanations for fields
 
 i18n / Languages:
 * Partial support for Basque language (from wikipedia and meta)
@@ -413,8 +421,6 @@ fully support the editing toolbar, but was found to be too confusing.
 * (bug 3407) Fix encoding of subject and from/to headers on notification
   mails; userMailer() now takes a MailAddress wrapper object instead of
   a raw string to abstract things a level.
-* (bug 4258) Use ugly urls for ISAPI by default
-  patch by Rob Church
 * Fixed --server override on dumpTextPass.php
 * Added plugin interface for dumpBackup, so additional filters and output
   sink types can be registered at runtime from an extension
@@ -480,7 +486,6 @@ fully support the editing toolbar, but was found to be too confusing.
 * Linker::formatComment corrupted the passed title object on PHP 5
   if the comment included a section link. Use clone() to make a safe copy.
 * Add wfClone() wrapper since we're still using PHP 4 on some servers.
-* Fixed installer bugs 921 and 3914 (issues with using root and so forth)
 * Remove obsolete killthread.php
 * Added wfDie() wrapper, and some manual die(-1), to force the return code
   to the shell to return nonzero when we crap out with an error.
index b4bed76..449de55 100644 (file)
@@ -395,7 +395,8 @@ print "<li style='font-weight:bold;color:green;font-size:110%'>Environment check
        $conf->DBpassword2 = importPost( "DBpassword2" );
        $conf->DBprefix = importPost( "DBprefix" );
        $conf->DBmysql5 = (importPost( "DBmysql5" ) == "true") ? "true" : "false";
-       $conf->RootPW = importPost( "RootPW" );
+       $conf->RootUser = importPost( "RootUser", "root" );
+       $conf->RootPW = importPost( "RootPW", "-" );
        $conf->LanguageCode = importPost( "LanguageCode", "en" );
        $conf->SysopName = importPost( "SysopName", "WikiSysop" );
        $conf->SysopPass = importPost( "SysopPass" );
@@ -503,67 +504,65 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                }
                $dbc = new $dbclass;
                
-               # Attempt to connect with the specific credentials *first*
-               # This is a quick fix to bug 921 ("Install script always attempts to connect to database as root")
-                               
                if( $conf->DBtype == 'mysql' ) {
                        $ok = true; # Let's be optimistic
-                       echo( "<li>Attempting to connect to database server..." );      
-                       $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, "", 1 );
-                       if( $wgDatabase->isOpen() ) {
-                               # Whee, we're in
+                       
+                       # Decide if we're going to use the superuser or the regular database user
+                       if( $conf->RootPW == '-' ) {
+                               # Regular user
                                $conf->Root = false;
-                               $wgDBadminuser = $wgDBuser;
+                               $db_user = $wgDBuser;
+                               $db_pass = $wgDBpassword;
+                       } else {
+                               # Superuser
+                               $conf->Root = true;
+                               $db_user = $conf->RootUser;
+                               $db_pass = $conf->RootPW;
+                       }
+                       
+                       # Attempt to connect
+                       echo( "<li>Attempting to connect to database server as $db_user..." );
+                       $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
+                       
+                       # Check the connection and respond to errors
+                       if( $wgDatabase->isOpen() ) {
+                               # Seems OK
+                               $ok = true;
+                               $wgDBadminuser = $db_user;
                                $wgDBadminpassword = $wgDBpassword;
-                               echo( "success. Connected as $wgDBuser.</li>\n" );
+                               echo( "success.</li>\n" );
+                               $wgDatabase->ignoreErrors( true );
+                               $myver = mysql_get_server_info( $wgDatabase->mConn );
                        } else {
-                               # Right, work out what's up
+                               # There were errors, report them and back out
+                               $ok = false;
                                $errno = mysql_errno();
                                $errtx = htmlspecialchars( mysql_error() );
                                switch( $errno ) {
-                                       case 2002:
-                                       case 2003:
-                                               # Connection to server failed
-                                               $ok = false;
-                                               echo( "failed with error [$errno] $errtx.</li>\n" );
-                                               $errs["DBserver"] = "Connection failed";
-                                               break;
                                        case 1045:
                                        case 2000:
-                                               # Authentication error, attempt to use root
-                                               sleep( 1 ); # Rate limiting
-                                               $wgDatabase = $dbc->newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
-                                               if( $wgDatabase->isOpen() ) {
-                                                       # Whee, fixed
-                                                       $conf->Root = true;
-                                                       echo( "success. Connected as root.</li>\n" );
+                                               echo( "failed due to authentication errors. Check passwords.</li>" );
+                                               if( $conf->Root ) {
+                                                       # The superuser details are wrong
+                                                       $errs["RootUser"] = "Check username";
+                                                       $errs["RootPW"] = "and password";
                                                } else {
-                                                       # That didn't work either
-                                                       $ok = false;
-                                                       echo( "failed due to authentication errors. Check passwords.</li>" );
-                                                       $errs["DBuser"] = "Check name/pass";
-                                                       $errs["DBpassword"] = "or enter root";
-                                                       $errs["DBpassword2"] = "password below";
-                                                       $errs["RootPW"] = "Got root?";
+                                                       # The regular user details are wrong
+                                                       $errs["DBuser"] = "Check username";
+                                                       $errs["DBpassword"] = "and password";
                                                }
                                                break;
+                                       case 2002:
+                                       case 2003:
                                        default:
-                                               # Something vicious and undocumented happened
-                                               # Panic and run our little installer ass off
-                                               $ok = false;
+                                               # General connection problem
                                                echo( "failed with error [$errno] $errtx.</li>\n" );
-                                               $errs["DBserver"] = "Couldn't connect to database";
+                                               $errs["DBserver"] = "Connection failed";
                                                break;
                                } # switch
-                       } # norm. conn. attempt
-                       
-                       if( $ok ) {
-                               # Set the version info. and ignore errors
-                               $wgDatabase->ignoreErrors( true );
-                               $myver = mysql_get_server_info( $wgDatabase->mConn );
-                       } else {
-                               continue;
-                       }
+                       } #conn. att.
+               
+                       if( !$ok ) { continue; }
 
                } else /* not mysql */ {
                        print "<li>Connecting to SQL server...";
@@ -678,12 +677,23 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                       'ss_total_views'   => 0,
                                       'ss_total_edits'   => 0,
                                       'ss_good_articles' => 0 ) );
-                       # setting up the db user
+                                          
+                       # Set up the "regular user" account *if we can, and if we need to*
                        if( $conf->Root ) {
-                               print "<li>Granting user permissions...</li>\n";
-                               dbsource( "../maintenance/users.sql", $wgDatabase );
+                               # See if we need to
+                               $wgDatabase2 = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, '', 1 );
+                               if( $wgDatabase2->isOpen() ) {
+                                       # Nope, just close the test connection and continue
+                                       $wgDatabase2->close();
+                                       echo( "<li>User $wgDBuser exists. Skipping grants.</li>" );
+                               } else {
+                                       # Yes, so run the grants
+                                       echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." );
+                                       dbsource( "../maintenance/users.sql", $wgDatabase );
+                                       echo( "success.</li>" );
+                               }
                        }
-
+                                          
                        if( $conf->SysopName ) {
                                $u = User::newFromName( $conf->getSysopName() );
                                if ( 0 == $u->idForName() ) {
@@ -985,6 +995,10 @@ if( count( $errs ) ) {
                enter those here. If you have database root access (see below)
                you can specify new accounts/databases to be created.
        </p>
+       <p>
+               This account will not be created if it pre-exists. If this is the case, ensure that it
+               has SELECT, INSERT, UPDATE and DELETE permissions on the MediaWiki database.
+       </p>
 
        <div class="config-input"><?php
                aField( $conf, "DBprefix", "Database table prefix:" );
@@ -1013,15 +1027,19 @@ if( count( $errs ) ) {
 
        <div class="config-input">
                <?php
-               aField( $conf, "RootPW", "DB root password:", "password" );
+               aField( $conf, "RootUser", "Superuser account:", "superuser" );
+               ?>
+       </div>
+       <div class="config-input">
+               <?php
+               aField( $conf, "RootPW", "Superuser password:", "password" );
                ?>
        </div>
+       
        <p class="config-desc">
-               You will only need this if the database and/or user account
-               above don't already exist.
-               Do <em>not</em> type in your machine's root password! MySQL
-               has its own "root" user with a separate password. (It might
-               even be blank, depending on your configuration.)
+               If the database user specified above does not exist, or does not have access to create
+               the database (if needed) or tables within it, please provide details of a superuser account,
+               such as <strong>root</strong>, which does. Leave the password set to <strong>-</strong> if this is not needed.
        </p>
 
        <div class="config-input" style="padding:2em 0 3em">