Index: branches/new-installer/phase3/maintenance/language/messages.inc |
— | — | @@ -3351,14 +3351,14 @@ |
3352 | 3352 | 'config-memcached-help', |
3353 | 3353 | 'config-extensions', |
3354 | 3354 | 'config-extensions-help', |
3355 | | - 'config-stage-done', |
| 3355 | + 'config-install-step-done', |
| 3356 | + 'config-install-step-failed', |
3356 | 3357 | 'config-install-extensions', |
3357 | 3358 | 'config-install-database', |
3358 | 3359 | 'config-install-tables', |
3359 | 3360 | 'config-install-interwiki-sql', |
3360 | 3361 | 'config-install-secretkey', |
3361 | | - 'config-insecure-secretkey', |
3362 | | - 'config-install-user', |
| 3362 | + 'config-install-sysop', |
3363 | 3363 | 'config-install-localsettings', |
3364 | 3364 | 'config-install-done', |
3365 | 3365 | ), |
Index: branches/new-installer/phase3/includes/installer/WebInstaller.php |
— | — | @@ -1502,85 +1502,24 @@ |
1503 | 1503 | } |
1504 | 1504 | $this->startForm(); |
1505 | 1505 | $this->parent->output->addHTML("<ul>"); |
1506 | | - |
1507 | | - // Extensions |
1508 | | - $exts = $this->parent->getVar( '_Extensions' ); |
1509 | | - if( count( $exts ) ) { |
1510 | | - global $wgHooks, $wgAutoloadClasses; |
1511 | | - $this->startStage( 'config-install-extensions' ); |
1512 | | - $path = $this->getVar( 'IP' ) . '/extensions'; |
1513 | | - foreach( $exts as $e ) { |
1514 | | - require( "$path/$e/$e.php" ); |
1515 | | - } |
1516 | | - $this->endStage(); |
| 1506 | + foreach( $this->parent->getInstallSteps() as $step ) { |
| 1507 | + $this->startStage( "config-install-$step" ); |
| 1508 | + $func = 'install' . ucfirst( $step ); |
| 1509 | + $success = $this->parent->{$func}(); |
| 1510 | + $this->endStage( $success ); |
1517 | 1511 | } |
1518 | | - |
1519 | | - // Get database |
1520 | | - $this->startStage( 'config-install-database' ); |
1521 | | - $dbType = $this->parent->getVar( 'wgDBtype' ); |
1522 | | - $installer = $this->parent->getDBInstaller( $dbType ); |
1523 | | - $db = $installer->setupDatabase(); |
1524 | | - if( !$db ) { |
1525 | | - // @todo Need some sort of failure |
1526 | | - return; |
1527 | | - } |
1528 | | - $this->endStage(); |
1529 | | - |
1530 | | - // Create tables |
1531 | | - $this->startStage( 'config-install-tables' ); |
1532 | | - $this->parent->createTables(); |
1533 | | - $this->endStage(); |
1534 | | - |
1535 | | - $this->startStage( 'config-install-secretkey' ); |
1536 | | - $file = @fopen( "/dev/urandom", "r" ); |
1537 | | - if ( $file ) { |
1538 | | - $secretKey = bin2hex( fread( $file, 32 ) ); |
1539 | | - fclose( $file ); |
1540 | | - $this->endStage(); |
1541 | | - } else { |
1542 | | - $secretKey = ""; |
1543 | | - for ( $i=0; $i<8; $i++ ) { |
1544 | | - $secretKey .= dechex(mt_rand(0, 0x7fffffff)); |
1545 | | - } |
1546 | | - $this->parent->output->addHTML( wfMsgHtml( 'config-insecure-secretkey' ) . "</li>\n" ); |
1547 | | - } |
1548 | | - $this->setVar( 'wgSecretKey', $secretKey ); |
1549 | | - |
1550 | | - // @TODO initialize DB first |
1551 | | - //$this->createWikiSysop(); |
1552 | | - |
1553 | | - $this->startStage( 'config-install-localsettings' ); |
1554 | | - $localSettings = new LocalSettings( $this->parent ); |
1555 | | - $localSettings->writeLocalSettings(); |
1556 | | - $this->endStage(); |
1557 | | - |
1558 | 1512 | $this->endForm(); |
1559 | | - } |
| 1513 | + return true; |
1560 | 1514 | |
1561 | | - private function createWikiSysop() { |
1562 | | - $user = User::newFromName( $this->getVar( '_AdminName' ) ); |
1563 | | - if ( !$user ) { |
1564 | | - //@todo |
1565 | | - } |
1566 | | - if ( $user->idForName() == 0 ) { |
1567 | | - $user->addToDatabase(); |
1568 | | - try { |
1569 | | - $user->setPassword( $this->getVar( '_AdminPassword' ) ); |
1570 | | - } catch( PasswordError $pwe ) { |
1571 | | - // need better failure here! |
1572 | | - } |
1573 | | - $user->saveSettings(); |
1574 | | - $user->addGroup( 'sysop' ); |
1575 | | - $user->addGroup( 'bureaucrat' ); |
1576 | | - } |
1577 | 1515 | } |
1578 | 1516 | |
1579 | 1517 | private function startStage( $msg ) { |
1580 | 1518 | $this->parent->output->addHTML( "<li>" . wfMsgHtml( $msg ) . wfMsg( 'ellipsis') ); |
1581 | 1519 | } |
1582 | 1520 | |
1583 | | - private function endStage() { |
1584 | | - $this->parent->output->addHTML( wfMsgHtml( 'config-stage-done' ) . "</li>\n" ); |
| 1521 | + private function endStage( $success = true ) { |
| 1522 | + $msg = $success ? 'config-install-step-done' : 'config-install-step-failed'; |
| 1523 | + $this->parent->output->addHTML( wfMsgHtml( $msg ) . "</li>\n" ); |
1585 | 1524 | } |
1586 | 1525 | } |
1587 | 1526 | class WebInstaller_Complete extends WebInstallerPage { |
Index: branches/new-installer/phase3/includes/installer/Installer.php |
— | — | @@ -124,6 +124,15 @@ |
125 | 125 | 'envCheckShellLocale', |
126 | 126 | ); |
127 | 127 | |
| 128 | + var $installSteps = array( |
| 129 | + 'extensions', |
| 130 | + 'database', |
| 131 | + 'tables', |
| 132 | + 'secretkey', |
| 133 | + // 'sysop', |
| 134 | + 'localsettings', |
| 135 | + ); |
| 136 | + |
128 | 137 | /** |
129 | 138 | * Known object cache types and the functions used to test for their existence |
130 | 139 | * @protected |
— | — | @@ -732,10 +741,81 @@ |
733 | 742 | return $exts; |
734 | 743 | } |
735 | 744 | |
736 | | - public function createTables() { |
| 745 | + |
| 746 | + |
| 747 | + public function getInstallSteps() { |
| 748 | + if( !count( $this->getVar( '_Extensions' ) ) ) { |
| 749 | + unset( $this->installSteps['extensions'] ); |
| 750 | + } |
| 751 | + return $this->installSteps; |
| 752 | + } |
| 753 | + |
| 754 | + public function installExtensions() { |
| 755 | + global $wgHooks, $wgAutoloadClasses; |
| 756 | + $exts = $this->getVar( '_Extensions' ); |
| 757 | + $path = $this->getVar( 'IP' ) . '/extensions'; |
| 758 | + foreach( $exts as $e ) { |
| 759 | + require( "$path/$e/$e.php" ); |
| 760 | + } |
| 761 | + return true; |
| 762 | + } |
| 763 | + |
| 764 | + public function installDatabase() { |
| 765 | + $installer = $this->getDBInstaller( $this->getVar( 'wgDBtype' ) ); |
| 766 | + $db = $installer->setupDatabase(); |
| 767 | + if( !$db ) { |
| 768 | + return false; |
| 769 | + } |
| 770 | + return true; |
| 771 | + } |
| 772 | + |
| 773 | + public function installTables() { |
737 | 774 | $installer = $this->getDBInstaller(); |
738 | | - $installer->createTables(); |
| 775 | + $status = $installer->createTables(); |
| 776 | + return $status->isGood(); |
739 | 777 | } |
| 778 | + |
| 779 | + public function installSecretKey() { |
| 780 | + $file = wfIsWindows() ? null : @fopen( "/dev/urandom", "r" ); |
| 781 | + if ( $file ) { |
| 782 | + $secretKey = bin2hex( fread( $file, 32 ) ); |
| 783 | + fclose( $file ); |
| 784 | + $ret = true; |
| 785 | + } else { |
| 786 | + $secretKey = ""; |
| 787 | + for ( $i=0; $i<8; $i++ ) { |
| 788 | + $secretKey .= dechex(mt_rand(0, 0x7fffffff)); |
| 789 | + } |
| 790 | + $ret = false; |
| 791 | + } |
| 792 | + $this->setVar( 'wgSecretKey', $secretKey ); |
| 793 | + return $ret; |
| 794 | + } |
| 795 | + |
| 796 | + private function installSysop() { |
| 797 | + $user = User::newFromName( $this->getVar( '_AdminName' ) ); |
| 798 | + if ( !$user ) { |
| 799 | + return false; // we should've validated this earlier anyway! |
| 800 | + } |
| 801 | + if ( $user->idForName() == 0 ) { |
| 802 | + $user->addToDatabase(); |
| 803 | + try { |
| 804 | + $user->setPassword( $this->getVar( '_AdminPassword' ) ); |
| 805 | + } catch( PasswordError $pwe ) { |
| 806 | + return false; |
| 807 | + } |
| 808 | + $user->saveSettings(); |
| 809 | + $user->addGroup( 'sysop' ); |
| 810 | + $user->addGroup( 'bureaucrat' ); |
| 811 | + } |
| 812 | + return true; |
| 813 | + } |
| 814 | + |
| 815 | + public function installLocalsettings() { |
| 816 | + $localSettings = new LocalSettings( $this ); |
| 817 | + $localSettings->writeLocalSettings(); |
| 818 | + return true; |
| 819 | + } |
740 | 820 | } |
741 | 821 | |
742 | 822 | /** |
Index: branches/new-installer/phase3/languages/messages/MessagesEn.php |
— | — | @@ -4450,14 +4450,14 @@ |
4451 | 4451 | 'config-extensions-help' => "The following extensions were automatically detected in your extensions directory.\n |
4452 | 4452 | They may require additional configuration, but you can enable them now", |
4453 | 4453 | |
4454 | | -'config-stage-done' => 'done', |
| 4454 | +'config-install-step-done' => 'done', |
| 4455 | +'config-install-step-failed' => "'''FAILED'''", |
4455 | 4456 | 'config-install-extensions' => 'Including extensions', |
4456 | 4457 | 'config-install-database' => 'Setting up database', |
4457 | 4458 | 'config-install-tables' => 'Creating tables', |
4458 | 4459 | 'config-install-interwiki-sql' => 'Could not find file interwiki.sql', |
4459 | 4460 | 'config-install-secretkey' => 'Generating secret key', |
4460 | | -'config-insecure-secretkey' => 'Warning: Unable to create secure $wgSecretKey. Consider changing it manually.', |
4461 | | -'config-install-user' => 'Creating administrator user account', |
| 4461 | +'config-install-sysop' => 'Creating administrator user account', |
4462 | 4462 | 'config-install-localsettings' => 'Writing LocalSettings.php', |
4463 | 4463 | 'config-install-done' => "'''Congratulations''', you have successfully installed MediaWiki. |
4464 | 4464 | |