Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -5,13 +5,21 @@ |
6 | 6 | * Handles everything that is independent of user interface. |
7 | 7 | */ |
8 | 8 | abstract class Installer { |
| 9 | + |
9 | 10 | public $settings; |
| 11 | + |
| 12 | + /** |
| 13 | + * |
| 14 | + * @var unknown_type |
| 15 | + */ |
10 | 16 | public $output; |
11 | 17 | |
12 | 18 | /** |
13 | 19 | * MediaWiki configuration globals that will eventually be passed through |
14 | 20 | * to LocalSettings.php. The names only are given here, the defaults |
15 | 21 | * typically come from DefaultSettings.php. |
| 22 | + * |
| 23 | + * @var array |
16 | 24 | */ |
17 | 25 | protected $defaultVarNames = array( |
18 | 26 | 'wgSitename', |
— | — | @@ -45,6 +53,8 @@ |
46 | 54 | * Variables that are stored alongside globals, and are used for any |
47 | 55 | * configuration of the installation process aside from the MediaWiki |
48 | 56 | * configuration. Map of names to defaults. |
| 57 | + * |
| 58 | + * @var array |
49 | 59 | */ |
50 | 60 | protected $internalDefaults = array( |
51 | 61 | '_UserLang' => 'en', |
— | — | @@ -80,6 +90,8 @@ |
81 | 91 | * |
82 | 92 | * To add a new type, create a <type>Installer class and a Database<type> |
83 | 93 | * class, and add a config-type-<type> message to MessagesEn.php. |
| 94 | + * |
| 95 | + * @var array |
84 | 96 | */ |
85 | 97 | private $dbTypes = array( |
86 | 98 | 'mysql', |
— | — | @@ -90,18 +102,34 @@ |
91 | 103 | |
92 | 104 | /** |
93 | 105 | * Minimum memory size in MB. |
| 106 | + * |
| 107 | + * @var integer |
94 | 108 | */ |
95 | 109 | private $minMemorySize = 50; |
96 | 110 | |
97 | 111 | /** |
98 | | - * Cached DB installer instances, access using getDBInstaller() |
| 112 | + * Cached Title, used by parse(). |
99 | 113 | */ |
| 114 | + private $parserTitle; |
| 115 | + |
| 116 | + /** |
| 117 | + * Cached ParserOptions, used by parse(). |
| 118 | + */ |
| 119 | + private $parserOptions; |
| 120 | + |
| 121 | + /** |
| 122 | + * Cached DB installer instances, access using getDBInstaller(). |
| 123 | + * |
| 124 | + * @var array |
| 125 | + */ |
100 | 126 | private $dbInstallers = array(); |
101 | 127 | |
102 | 128 | /** |
103 | 129 | * A list of environment check methods called by doEnvironmentChecks(). |
104 | 130 | * These may output warnings using showMessage(), and/or abort the |
105 | 131 | * installation process by returning false. |
| 132 | + * |
| 133 | + * @var array |
106 | 134 | */ |
107 | 135 | protected $envChecks = array( |
108 | 136 | 'envLatestVersion', |
— | — | @@ -127,6 +155,8 @@ |
128 | 156 | |
129 | 157 | /** |
130 | 158 | * Steps for installation. |
| 159 | + * |
| 160 | + * @var array |
131 | 161 | */ |
132 | 162 | protected $installSteps = array( |
133 | 163 | 'database', |
— | — | @@ -138,6 +168,8 @@ |
139 | 169 | |
140 | 170 | /** |
141 | 171 | * Known object cache types and the functions used to test for their existence. |
| 172 | + * |
| 173 | + * @var array |
142 | 174 | */ |
143 | 175 | protected $objectCaches = array( |
144 | 176 | 'xcache' => 'xcache_get', |
— | — | @@ -148,6 +180,8 @@ |
149 | 181 | |
150 | 182 | /** |
151 | 183 | * User rights profiles. |
| 184 | + * |
| 185 | + * @var array |
152 | 186 | */ |
153 | 187 | public $rightsProfiles = array( |
154 | 188 | 'wiki' => array(), |
— | — | @@ -171,6 +205,8 @@ |
172 | 206 | |
173 | 207 | /** |
174 | 208 | * License types. |
| 209 | + * |
| 210 | + * @var array |
175 | 211 | */ |
176 | 212 | public $licenses = array( |
177 | 213 | 'none' => array( |
— | — | @@ -205,11 +241,8 @@ |
206 | 242 | 'text' => '', |
207 | 243 | ), |
208 | 244 | ); |
209 | | - /** |
210 | | - * Cached Title and ParserOptions used by parse() |
211 | | - */ |
212 | | - private $parserTitle, $parserOptions; |
213 | 245 | |
| 246 | + |
214 | 247 | /** |
215 | 248 | * Constructor, always call this from child classes |
216 | 249 | */ |
— | — | @@ -401,37 +434,47 @@ |
402 | 435 | |
403 | 436 | /** Environment check for DB types */ |
404 | 437 | public function envCheckDB() { |
| 438 | + global $wgLang; |
| 439 | + |
405 | 440 | $compiledDBs = array(); |
406 | 441 | $goodNames = array(); |
407 | 442 | $allNames = array(); |
| 443 | + |
408 | 444 | foreach ( $this->dbTypes as $name ) { |
409 | 445 | $db = $this->getDBInstaller( $name ); |
410 | 446 | $readableName = wfMsg( 'config-type-' . $name ); |
| 447 | + |
411 | 448 | if ( $db->isCompiled() ) { |
412 | 449 | $compiledDBs[] = $name; |
413 | 450 | $goodNames[] = $readableName; |
414 | 451 | } |
| 452 | + |
415 | 453 | $allNames[] = $readableName; |
416 | 454 | } |
| 455 | + |
417 | 456 | $this->setVar( '_CompiledDBs', $compiledDBs ); |
418 | | - |
419 | | - global $wgLang; |
| 457 | + |
420 | 458 | if ( !$compiledDBs ) { |
421 | 459 | $this->showMessage( 'config-no-db' ); |
422 | 460 | $this->showHelpBox( 'config-no-db-help', $wgLang->commaList( $allNames ) ); |
423 | 461 | return false; |
424 | 462 | } |
| 463 | + |
425 | 464 | $this->showMessage( 'config-have-db', $wgLang->commaList( $goodNames ) ); |
426 | 465 | } |
427 | 466 | |
428 | | - /** Environment check for register_globals */ |
| 467 | + /** |
| 468 | + * Environment check for register_globals. |
| 469 | + */ |
429 | 470 | public function envCheckRegisterGlobals() { |
430 | 471 | if( wfIniGetBool( "magic_quotes_runtime" ) ) { |
431 | 472 | $this->showMessage( 'config-register-globals' ); |
432 | 473 | } |
433 | 474 | } |
434 | 475 | |
435 | | - /** Environment check for magic_quotes_runtime */ |
| 476 | + /** |
| 477 | + * Environment check for magic_quotes_runtime. |
| 478 | + */ |
436 | 479 | public function envCheckMagicQuotes() { |
437 | 480 | if( wfIniGetBool( "magic_quotes_runtime" ) ) { |
438 | 481 | $this->showMessage( 'config-magic-quotes-runtime' ); |
— | — | @@ -439,7 +482,9 @@ |
440 | 483 | } |
441 | 484 | } |
442 | 485 | |
443 | | - /** Environment check for magic_quotes_sybase */ |
| 486 | + /** |
| 487 | + * Environment check for magic_quotes_sybase. |
| 488 | + */ |
444 | 489 | public function envCheckMagicSybase() { |
445 | 490 | if ( wfIniGetBool( 'magic_quotes_sybase' ) ) { |
446 | 491 | $this->showMessage( 'config-magic-quotes-sybase' ); |
— | — | @@ -447,7 +492,9 @@ |
448 | 493 | } |
449 | 494 | } |
450 | 495 | |
451 | | - /* Environment check for mbstring.func_overload */ |
| 496 | + /** |
| 497 | + * Environment check for mbstring.func_overload. |
| 498 | + */ |
452 | 499 | public function envCheckMbstring() { |
453 | 500 | if ( wfIniGetBool( 'mbstring.func_overload' ) ) { |
454 | 501 | $this->showMessage( 'config-mbstring' ); |
— | — | @@ -455,7 +502,9 @@ |
456 | 503 | } |
457 | 504 | } |
458 | 505 | |
459 | | - /** Environment check for zend.ze1_compatibility_mode */ |
| 506 | + /** |
| 507 | + * Environment check for zend.ze1_compatibility_mode. |
| 508 | + */ |
460 | 509 | public function envCheckZE1() { |
461 | 510 | if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) { |
462 | 511 | $this->showMessage( 'config-ze1' ); |
— | — | @@ -463,7 +512,9 @@ |
464 | 513 | } |
465 | 514 | } |
466 | 515 | |
467 | | - /** Environment check for safe_mode */ |
| 516 | + /** |
| 517 | + * Environment check for safe_mode. |
| 518 | + */ |
468 | 519 | public function envCheckSafeMode() { |
469 | 520 | if ( wfIniGetBool( 'safe_mode' ) ) { |
470 | 521 | $this->setVar( '_SafeMode', true ); |
— | — | @@ -471,7 +522,9 @@ |
472 | 523 | } |
473 | 524 | } |
474 | 525 | |
475 | | - /** Environment check for the XML module */ |
| 526 | + /** |
| 527 | + * Environment check for the XML module. |
| 528 | + */ |
476 | 529 | public function envCheckXML() { |
477 | 530 | if ( !function_exists( "utf8_encode" ) ) { |
478 | 531 | $this->showMessage( 'config-xml-bad' ); |
— | — | @@ -480,7 +533,9 @@ |
481 | 534 | $this->showMessage( 'config-xml-good' ); |
482 | 535 | } |
483 | 536 | |
484 | | - /** Environment check for the PCRE module */ |
| 537 | + /** |
| 538 | + * Environment check for the PCRE module. |
| 539 | + */ |
485 | 540 | public function envCheckPCRE() { |
486 | 541 | if ( !function_exists( 'preg_match' ) ) { |
487 | 542 | $this->showMessage( 'config-pcre' ); |
— | — | @@ -488,20 +543,27 @@ |
489 | 544 | } |
490 | 545 | } |
491 | 546 | |
492 | | - /** Environment check for available memory */ |
| 547 | + /** |
| 548 | + * Environment check for available memory. |
| 549 | + */ |
493 | 550 | public function envCheckMemory() { |
494 | 551 | $limit = ini_get( 'memory_limit' ); |
| 552 | + |
495 | 553 | if ( !$limit || $limit == -1 ) { |
496 | 554 | $this->showMessage( 'config-memory-none' ); |
497 | 555 | return true; |
498 | 556 | } |
| 557 | + |
499 | 558 | $n = intval( $limit ); |
| 559 | + |
500 | 560 | if( preg_match( '/^([0-9]+)[Mm]$/', trim( $limit ), $m ) ) { |
501 | | - $n = intval( $m[1] * (1024*1024) ); |
| 561 | + $n = intval( $m[1] * ( 1024 * 1024 ) ); |
502 | 562 | } |
503 | | - if( $n < $this->minMemorySize*1024*1024 ) { |
| 563 | + |
| 564 | + if( $n < $this->minMemorySize * 1024 * 1024 ) { |
504 | 565 | $newLimit = "{$this->minMemorySize}M"; |
505 | | - if( false === ini_set( "memory_limit", $newLimit ) ) { |
| 566 | + |
| 567 | + if( ini_set( "memory_limit", $newLimit ) === false ) { |
506 | 568 | $this->showMessage( 'config-memory-bad', $limit ); |
507 | 569 | } else { |
508 | 570 | $this->showMessage( 'config-memory-raised', $limit, $newLimit ); |
— | — | @@ -512,22 +574,29 @@ |
513 | 575 | } |
514 | 576 | } |
515 | 577 | |
516 | | - /** Environment check for compiled object cache types */ |
| 578 | + /** |
| 579 | + * Environment check for compiled object cache types. |
| 580 | + */ |
517 | 581 | public function envCheckCache() { |
518 | 582 | $caches = array(); |
| 583 | + |
519 | 584 | foreach ( $this->objectCaches as $name => $function ) { |
520 | 585 | if ( function_exists( $function ) ) { |
521 | 586 | $caches[$name] = true; |
522 | 587 | $this->showMessage( 'config-' . $name ); |
523 | 588 | } |
524 | 589 | } |
| 590 | + |
525 | 591 | if ( !$caches ) { |
526 | 592 | $this->showMessage( 'config-no-cache' ); |
527 | 593 | } |
| 594 | + |
528 | 595 | $this->setVar( '_Caches', $caches ); |
529 | 596 | } |
530 | 597 | |
531 | | - /** Search for GNU diff3 */ |
| 598 | + /** |
| 599 | + * Search for GNU diff3. |
| 600 | + */ |
532 | 601 | public function envCheckDiff3() { |
533 | 602 | $paths = array_merge( |
534 | 603 | array( |
— | — | @@ -535,20 +604,26 @@ |
536 | 605 | "/usr/local/bin", |
537 | 606 | "/opt/csw/bin", |
538 | 607 | "/usr/gnu/bin", |
539 | | - "/usr/sfw/bin" ), |
540 | | - explode( PATH_SEPARATOR, getenv( "PATH" ) ) ); |
| 608 | + "/usr/sfw/bin" |
| 609 | + ), |
| 610 | + explode( PATH_SEPARATOR, getenv( "PATH" ) ) |
| 611 | + ); |
| 612 | + |
541 | 613 | $names = array( "gdiff3", "diff3", "diff3.exe" ); |
542 | | - |
543 | 614 | $versionInfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' ); |
| 615 | + |
544 | 616 | $haveDiff3 = false; |
| 617 | + |
545 | 618 | foreach ( $paths as $path ) { |
546 | 619 | $exe = $this->locateExecutable( $path, $names, $versionInfo ); |
| 620 | + |
547 | 621 | if ($exe !== false) { |
548 | 622 | $this->setVar( 'wgDiff3', $exe ); |
549 | 623 | $haveDiff3 = true; |
550 | 624 | break; |
551 | 625 | } |
552 | 626 | } |
| 627 | + |
553 | 628 | if ( $haveDiff3 ) { |
554 | 629 | $this->showMessage( 'config-diff3-good', $exe ); |
555 | 630 | } else { |
— | — | @@ -572,26 +647,34 @@ |
573 | 648 | * matching $versionInfo[1] will be returned. |
574 | 649 | */ |
575 | 650 | public function locateExecutable( $path, $names, $versionInfo = false ) { |
576 | | - if (!is_array($names)) |
577 | | - $names = array($names); |
| 651 | + if ( !is_array( $names ) ) { |
| 652 | + $names = array( $names ); |
| 653 | + } |
578 | 654 | |
579 | | - foreach ($names as $name) { |
| 655 | + foreach ( $names as $name ) { |
580 | 656 | $command = "$path/$name"; |
| 657 | + |
581 | 658 | if ( @file_exists( $command ) ) { |
582 | | - if ( !$versionInfo ) |
| 659 | + if ( !$versionInfo ) { |
583 | 660 | return $command; |
584 | | - |
| 661 | + } |
| 662 | + |
585 | 663 | $file = str_replace( '$1', $command, $versionInfo[0] ); |
| 664 | + |
586 | 665 | # Should maybe be wfShellExec( $file), but runs into a ulimit, see |
587 | 666 | # http://www.mediawiki.org/w/index.php?title=New-installer_issues&diff=prev&oldid=335456 |
588 | | - if ( strstr( `$file`, $versionInfo[1]) !== false ) |
| 667 | + if ( strstr( `$file`, $versionInfo[1]) !== false ) { |
589 | 668 | return $command; |
| 669 | + } |
590 | 670 | } |
591 | 671 | } |
| 672 | + |
592 | 673 | return false; |
593 | 674 | } |
594 | 675 | |
595 | | - /** Environment check for ImageMagick and GD */ |
| 676 | + /** |
| 677 | + * Environment check for ImageMagick and GD. |
| 678 | + */ |
596 | 679 | public function envCheckGraphics() { |
597 | 680 | $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" ); |
598 | 681 | foreach( $imcheck as $dir ) { |