r69693 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69692‎ | r69693 | r69694 >
Date:17:20, 21 July 2010
Author:jeroendedauw
Status:ok
Tags:
Comment:
Style and doc improvements
Modified paths:
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/Installer.php
@@ -5,13 +5,21 @@
66 * Handles everything that is independent of user interface.
77 */
88 abstract class Installer {
 9+
910 public $settings;
 11+
 12+ /**
 13+ *
 14+ * @var unknown_type
 15+ */
1016 public $output;
1117
1218 /**
1319 * MediaWiki configuration globals that will eventually be passed through
1420 * to LocalSettings.php. The names only are given here, the defaults
1521 * typically come from DefaultSettings.php.
 22+ *
 23+ * @var array
1624 */
1725 protected $defaultVarNames = array(
1826 'wgSitename',
@@ -45,6 +53,8 @@
4654 * Variables that are stored alongside globals, and are used for any
4755 * configuration of the installation process aside from the MediaWiki
4856 * configuration. Map of names to defaults.
 57+ *
 58+ * @var array
4959 */
5060 protected $internalDefaults = array(
5161 '_UserLang' => 'en',
@@ -80,6 +90,8 @@
8191 *
8292 * To add a new type, create a <type>Installer class and a Database<type>
8393 * class, and add a config-type-<type> message to MessagesEn.php.
 94+ *
 95+ * @var array
8496 */
8597 private $dbTypes = array(
8698 'mysql',
@@ -90,18 +102,34 @@
91103
92104 /**
93105 * Minimum memory size in MB.
 106+ *
 107+ * @var integer
94108 */
95109 private $minMemorySize = 50;
96110
97111 /**
98 - * Cached DB installer instances, access using getDBInstaller()
 112+ * Cached Title, used by parse().
99113 */
 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+ */
100126 private $dbInstallers = array();
101127
102128 /**
103129 * A list of environment check methods called by doEnvironmentChecks().
104130 * These may output warnings using showMessage(), and/or abort the
105131 * installation process by returning false.
 132+ *
 133+ * @var array
106134 */
107135 protected $envChecks = array(
108136 'envLatestVersion',
@@ -127,6 +155,8 @@
128156
129157 /**
130158 * Steps for installation.
 159+ *
 160+ * @var array
131161 */
132162 protected $installSteps = array(
133163 'database',
@@ -138,6 +168,8 @@
139169
140170 /**
141171 * Known object cache types and the functions used to test for their existence.
 172+ *
 173+ * @var array
142174 */
143175 protected $objectCaches = array(
144176 'xcache' => 'xcache_get',
@@ -148,6 +180,8 @@
149181
150182 /**
151183 * User rights profiles.
 184+ *
 185+ * @var array
152186 */
153187 public $rightsProfiles = array(
154188 'wiki' => array(),
@@ -171,6 +205,8 @@
172206
173207 /**
174208 * License types.
 209+ *
 210+ * @var array
175211 */
176212 public $licenses = array(
177213 'none' => array(
@@ -205,11 +241,8 @@
206242 'text' => '',
207243 ),
208244 );
209 - /**
210 - * Cached Title and ParserOptions used by parse()
211 - */
212 - private $parserTitle, $parserOptions;
213245
 246+
214247 /**
215248 * Constructor, always call this from child classes
216249 */
@@ -401,37 +434,47 @@
402435
403436 /** Environment check for DB types */
404437 public function envCheckDB() {
 438+ global $wgLang;
 439+
405440 $compiledDBs = array();
406441 $goodNames = array();
407442 $allNames = array();
 443+
408444 foreach ( $this->dbTypes as $name ) {
409445 $db = $this->getDBInstaller( $name );
410446 $readableName = wfMsg( 'config-type-' . $name );
 447+
411448 if ( $db->isCompiled() ) {
412449 $compiledDBs[] = $name;
413450 $goodNames[] = $readableName;
414451 }
 452+
415453 $allNames[] = $readableName;
416454 }
 455+
417456 $this->setVar( '_CompiledDBs', $compiledDBs );
418 -
419 - global $wgLang;
 457+
420458 if ( !$compiledDBs ) {
421459 $this->showMessage( 'config-no-db' );
422460 $this->showHelpBox( 'config-no-db-help', $wgLang->commaList( $allNames ) );
423461 return false;
424462 }
 463+
425464 $this->showMessage( 'config-have-db', $wgLang->commaList( $goodNames ) );
426465 }
427466
428 - /** Environment check for register_globals */
 467+ /**
 468+ * Environment check for register_globals.
 469+ */
429470 public function envCheckRegisterGlobals() {
430471 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
431472 $this->showMessage( 'config-register-globals' );
432473 }
433474 }
434475
435 - /** Environment check for magic_quotes_runtime */
 476+ /**
 477+ * Environment check for magic_quotes_runtime.
 478+ */
436479 public function envCheckMagicQuotes() {
437480 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
438481 $this->showMessage( 'config-magic-quotes-runtime' );
@@ -439,7 +482,9 @@
440483 }
441484 }
442485
443 - /** Environment check for magic_quotes_sybase */
 486+ /**
 487+ * Environment check for magic_quotes_sybase.
 488+ */
444489 public function envCheckMagicSybase() {
445490 if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
446491 $this->showMessage( 'config-magic-quotes-sybase' );
@@ -447,7 +492,9 @@
448493 }
449494 }
450495
451 - /* Environment check for mbstring.func_overload */
 496+ /**
 497+ * Environment check for mbstring.func_overload.
 498+ */
452499 public function envCheckMbstring() {
453500 if ( wfIniGetBool( 'mbstring.func_overload' ) ) {
454501 $this->showMessage( 'config-mbstring' );
@@ -455,7 +502,9 @@
456503 }
457504 }
458505
459 - /** Environment check for zend.ze1_compatibility_mode */
 506+ /**
 507+ * Environment check for zend.ze1_compatibility_mode.
 508+ */
460509 public function envCheckZE1() {
461510 if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) {
462511 $this->showMessage( 'config-ze1' );
@@ -463,7 +512,9 @@
464513 }
465514 }
466515
467 - /** Environment check for safe_mode */
 516+ /**
 517+ * Environment check for safe_mode.
 518+ */
468519 public function envCheckSafeMode() {
469520 if ( wfIniGetBool( 'safe_mode' ) ) {
470521 $this->setVar( '_SafeMode', true );
@@ -471,7 +522,9 @@
472523 }
473524 }
474525
475 - /** Environment check for the XML module */
 526+ /**
 527+ * Environment check for the XML module.
 528+ */
476529 public function envCheckXML() {
477530 if ( !function_exists( "utf8_encode" ) ) {
478531 $this->showMessage( 'config-xml-bad' );
@@ -480,7 +533,9 @@
481534 $this->showMessage( 'config-xml-good' );
482535 }
483536
484 - /** Environment check for the PCRE module */
 537+ /**
 538+ * Environment check for the PCRE module.
 539+ */
485540 public function envCheckPCRE() {
486541 if ( !function_exists( 'preg_match' ) ) {
487542 $this->showMessage( 'config-pcre' );
@@ -488,20 +543,27 @@
489544 }
490545 }
491546
492 - /** Environment check for available memory */
 547+ /**
 548+ * Environment check for available memory.
 549+ */
493550 public function envCheckMemory() {
494551 $limit = ini_get( 'memory_limit' );
 552+
495553 if ( !$limit || $limit == -1 ) {
496554 $this->showMessage( 'config-memory-none' );
497555 return true;
498556 }
 557+
499558 $n = intval( $limit );
 559+
500560 if( preg_match( '/^([0-9]+)[Mm]$/', trim( $limit ), $m ) ) {
501 - $n = intval( $m[1] * (1024*1024) );
 561+ $n = intval( $m[1] * ( 1024 * 1024 ) );
502562 }
503 - if( $n < $this->minMemorySize*1024*1024 ) {
 563+
 564+ if( $n < $this->minMemorySize * 1024 * 1024 ) {
504565 $newLimit = "{$this->minMemorySize}M";
505 - if( false === ini_set( "memory_limit", $newLimit ) ) {
 566+
 567+ if( ini_set( "memory_limit", $newLimit ) === false ) {
506568 $this->showMessage( 'config-memory-bad', $limit );
507569 } else {
508570 $this->showMessage( 'config-memory-raised', $limit, $newLimit );
@@ -512,22 +574,29 @@
513575 }
514576 }
515577
516 - /** Environment check for compiled object cache types */
 578+ /**
 579+ * Environment check for compiled object cache types.
 580+ */
517581 public function envCheckCache() {
518582 $caches = array();
 583+
519584 foreach ( $this->objectCaches as $name => $function ) {
520585 if ( function_exists( $function ) ) {
521586 $caches[$name] = true;
522587 $this->showMessage( 'config-' . $name );
523588 }
524589 }
 590+
525591 if ( !$caches ) {
526592 $this->showMessage( 'config-no-cache' );
527593 }
 594+
528595 $this->setVar( '_Caches', $caches );
529596 }
530597
531 - /** Search for GNU diff3 */
 598+ /**
 599+ * Search for GNU diff3.
 600+ */
532601 public function envCheckDiff3() {
533602 $paths = array_merge(
534603 array(
@@ -535,20 +604,26 @@
536605 "/usr/local/bin",
537606 "/opt/csw/bin",
538607 "/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+
541613 $names = array( "gdiff3", "diff3", "diff3.exe" );
542 -
543614 $versionInfo = array( '$1 --version 2>&1', 'diff3 (GNU diffutils)' );
 615+
544616 $haveDiff3 = false;
 617+
545618 foreach ( $paths as $path ) {
546619 $exe = $this->locateExecutable( $path, $names, $versionInfo );
 620+
547621 if ($exe !== false) {
548622 $this->setVar( 'wgDiff3', $exe );
549623 $haveDiff3 = true;
550624 break;
551625 }
552626 }
 627+
553628 if ( $haveDiff3 ) {
554629 $this->showMessage( 'config-diff3-good', $exe );
555630 } else {
@@ -572,26 +647,34 @@
573648 * matching $versionInfo[1] will be returned.
574649 */
575650 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+ }
578654
579 - foreach ($names as $name) {
 655+ foreach ( $names as $name ) {
580656 $command = "$path/$name";
 657+
581658 if ( @file_exists( $command ) ) {
582 - if ( !$versionInfo )
 659+ if ( !$versionInfo ) {
583660 return $command;
584 -
 661+ }
 662+
585663 $file = str_replace( '$1', $command, $versionInfo[0] );
 664+
586665 # Should maybe be wfShellExec( $file), but runs into a ulimit, see
587666 # 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 ) {
589668 return $command;
 669+ }
590670 }
591671 }
 672+
592673 return false;
593674 }
594675
595 - /** Environment check for ImageMagick and GD */
 676+ /**
 677+ * Environment check for ImageMagick and GD.
 678+ */
596679 public function envCheckGraphics() {
597680 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
598681 foreach( $imcheck as $dir ) {

Status & tagging log