From 3f63ad4331eb0d2fd7aa3b1eff8eabe0f81764c9 Mon Sep 17 00:00:00 2001 From: Nick Jenkins Date: Wed, 25 Oct 2006 03:12:46 +0000 Subject: [PATCH] (bug 6531) fix PHP fatal error on MediaWiki installation page with bad input - patch by Werdna. Also tweak output HTML slightly so that Tidy doesn't complain about it, and add a few newlines to make View-Source a tiny bit easier to read. --- RELEASE-NOTES | 1 + config/index.php | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e0e4bc4728..e5378203dc 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -83,6 +83,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Fix user_newpass upgrade for prefixed tables (reported by Fyren) * (bug 7636) Fix typo in Firefox 2 check (tested by Werdna) * (bug 7663) Include language variant switcher links on Nostalgia skin +* (bug 6531) Fix PHP fatal error on installation page with bad username input. == Languages updated == diff --git a/config/index.php b/config/index.php index 5443614ef2..01fdba0b31 100644 --- a/config/index.php +++ b/config/index.php @@ -584,9 +584,11 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { /* Load up the settings and get installin' */ $local = writeLocalSettings( $conf ); + echo "
  • \n"; echo "

    Generating configuration file...

    \n"; // for debugging: // echo "
    " . htmlspecialchars( $local ) . "
    \n"; - + echo "
  • \n"; + $wgCommandLineMode = false; chdir( ".." ); eval($local); @@ -824,7 +826,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { print " done.\n"; - print "
  • Initializing data..."; + print "
  • Initializing data...
  • \n"; $wgDatabase->insert( 'site_stats', array ( 'ss_row_id' => 1, 'ss_total_views' => 0, @@ -838,18 +840,21 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { if( $wgDatabase2->isOpen() ) { # Nope, just close the test connection and continue $wgDatabase2->close(); - echo( "
  • User $wgDBuser exists. Skipping grants.
  • " ); + echo( "
  • User $wgDBuser exists. Skipping grants.
  • \n" ); } else { # Yes, so run the grants echo( "
  • Granting user permissions to $wgDBuser on $wgDBname..." ); dbsource( "../maintenance/users.sql", $wgDatabase ); - echo( "success.
  • " ); + echo( "success.\n" ); } } if( $conf->SysopName ) { $u = User::newFromName( $conf->getSysopName() ); - if ( 0 == $u->idForName() ) { + if ( !$u ) { + print "
  • Warning: Skipped sysop account creation - invalid username!
  • \n"; + } + else if ( 0 == $u->idForName() ) { $u->addToDatabase(); $u->setPassword( $conf->getSysopPass() ); $u->saveSettings(); @@ -883,6 +888,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { } /* Write out the config file now that all is well */ + print "
  • \n"; print "

    Creating LocalSettings.php...

    \n\n"; $localSettings = "<" . "?php$endl$local$endl?" . ">\r\n"; // Fix up a common line-ending problem (due to CVS on Windows) @@ -902,6 +908,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) { die("

    An error occured while writing the config/LocalSettings.php file. Check user rights and disk space then try again.

    \n"); } + print "
  • \n"; } while( false ); } -- 2.20.1