Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -1,11 +1,12 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Base installer class |
6 | | - * Handles everything that is independent of user interface |
| 5 | + * Base installer class. |
| 6 | + * Handles everything that is independent of user interface. |
7 | 7 | */ |
8 | 8 | abstract class Installer { |
9 | | - var $settings, $output; |
| 9 | + public $settings; |
| 10 | + public $output; |
10 | 11 | |
11 | 12 | /** |
12 | 13 | * MediaWiki configuration globals that will eventually be passed through |
— | — | @@ -88,7 +89,7 @@ |
89 | 90 | ); |
90 | 91 | |
91 | 92 | /** |
92 | | - * Minimum memory size in MB |
| 93 | + * Minimum memory size in MB. |
93 | 94 | */ |
94 | 95 | private $minMemorySize = 50; |
95 | 96 | |
— | — | @@ -136,7 +137,7 @@ |
137 | 138 | ); |
138 | 139 | |
139 | 140 | /** |
140 | | - * Known object cache types and the functions used to test for their existence |
| 141 | + * Known object cache types and the functions used to test for their existence. |
141 | 142 | */ |
142 | 143 | protected $objectCaches = array( |
143 | 144 | 'xcache' => 'xcache_get', |
— | — | @@ -146,9 +147,9 @@ |
147 | 148 | ); |
148 | 149 | |
149 | 150 | /** |
150 | | - * User rights profiles |
| 151 | + * User rights profiles. |
151 | 152 | */ |
152 | | - var $rightsProfiles = array( |
| 153 | + public $rightsProfiles = array( |
153 | 154 | 'wiki' => array(), |
154 | 155 | 'no-anon' => array( |
155 | 156 | '*' => array( 'edit' => false ) |
— | — | @@ -169,9 +170,9 @@ |
170 | 171 | ); |
171 | 172 | |
172 | 173 | /** |
173 | | - * License types |
| 174 | + * License types. |
174 | 175 | */ |
175 | | - var $licenses = array( |
| 176 | + public $licenses = array( |
176 | 177 | 'none' => array( |
177 | 178 | 'url' => '', |
178 | 179 | 'icon' => '', |
— | — | @@ -212,7 +213,7 @@ |
213 | 214 | /** |
214 | 215 | * Constructor, always call this from child classes |
215 | 216 | */ |
216 | | - function __construct() { |
| 217 | + public function __construct() { |
217 | 218 | // Disable the i18n cache and LoadBalancer |
218 | 219 | Language::getLocalisationCache()->disableBackend(); |
219 | 220 | LBFactory::disableBackend(); |
— | — | @@ -260,22 +261,22 @@ |
261 | 262 | * The messages will be in wikitext format, which will be converted to an |
262 | 263 | * output format such as HTML or text before being sent to the user. |
263 | 264 | */ |
264 | | - abstract function showMessage( $msg /*, ... */ ); |
| 265 | + public abstract function showMessage( $msg /*, ... */ ); |
265 | 266 | |
266 | | - abstract function showStatusMessage( $status ); |
| 267 | + public abstract function showStatusMessage( $status ); |
267 | 268 | |
268 | 269 | /** |
269 | | - * Get a list of known DB types |
| 270 | + * Get a list of known DB types. |
270 | 271 | */ |
271 | | - function getDBTypes() { |
| 272 | + public function getDBTypes() { |
272 | 273 | return $this->dbTypes; |
273 | 274 | } |
274 | 275 | |
275 | 276 | /** |
276 | 277 | * Get an instance of InstallerDBType for the specified DB type |
277 | | - * @param $type Mixed: DB installer for which is needed, false to use default |
| 278 | + * @param $type Mixed: DB installer for which is needed, false to use default. |
278 | 279 | */ |
279 | | - function getDBInstaller( $type = false ) { |
| 280 | + public function getDBInstaller( $type = false ) { |
280 | 281 | if ( !$type ) { |
281 | 282 | $type = $this->getVar( 'wgDBtype' ); |
282 | 283 | } |
— | — | @@ -299,7 +300,7 @@ |
300 | 301 | * Under the web subclass, it can already be assumed that PHP 5+ is in use |
301 | 302 | * and that sessions are working. |
302 | 303 | */ |
303 | | - function doEnvironmentChecks() { |
| 304 | + public function doEnvironmentChecks() { |
304 | 305 | $this->showMessage( 'config-env-php', phpversion() ); |
305 | 306 | |
306 | 307 | $good = true; |
— | — | @@ -323,7 +324,7 @@ |
324 | 325 | * The defaults come from $GLOBALS (ultimately DefaultSettings.php). |
325 | 326 | * Installer variables are typically prefixed by an underscore. |
326 | 327 | */ |
327 | | - function getVar( $name, $default = null ) { |
| 328 | + public function getVar( $name, $default = null ) { |
328 | 329 | if ( !isset( $this->settings[$name] ) ) { |
329 | 330 | return $default; |
330 | 331 | } else { |
— | — | @@ -334,14 +335,14 @@ |
335 | 336 | /** |
336 | 337 | * Set a MW configuration variable, or internal installer configuration variable. |
337 | 338 | */ |
338 | | - function setVar( $name, $value ) { |
| 339 | + public function setVar( $name, $value ) { |
339 | 340 | $this->settings[$name] = $value; |
340 | 341 | } |
341 | 342 | |
342 | 343 | /** |
343 | 344 | * Exports all wg* variables stored by the installer into global scope |
344 | 345 | */ |
345 | | - function exportVars() { |
| 346 | + public function exportVars() { |
346 | 347 | foreach ( $this->settings as $name => $value ) { |
347 | 348 | if ( substr( $name, 0, 2 ) == 'wg' ) { |
348 | 349 | $GLOBALS[$name] = $value; |
— | — | @@ -354,7 +355,7 @@ |
355 | 356 | * This is a security mechanism to avoid compromise of the password in the |
356 | 357 | * event of session ID compromise. |
357 | 358 | */ |
358 | | - function getFakePassword( $realPassword ) { |
| 359 | + public function getFakePassword( $realPassword ) { |
359 | 360 | return str_repeat( '*', strlen( $realPassword ) ); |
360 | 361 | } |
361 | 362 | |
— | — | @@ -362,14 +363,14 @@ |
363 | 364 | * Set a variable which stores a password, except if the new value is a |
364 | 365 | * fake password in which case leave it as it is. |
365 | 366 | */ |
366 | | - function setPassword( $name, $value ) { |
| 367 | + public function setPassword( $name, $value ) { |
367 | 368 | if ( !preg_match( '/^\*+$/', $value ) ) { |
368 | 369 | $this->setVar( $name, $value ); |
369 | 370 | } |
370 | 371 | } |
371 | 372 | |
372 | 373 | /** Check if we're installing the latest version */ |
373 | | - function envLatestVersion() { |
| 374 | + public function envLatestVersion() { |
374 | 375 | global $wgVersion; |
375 | 376 | $latestInfoUrl = 'http://www.mediawiki.org/w/api.php?action=mwreleases&format=json'; |
376 | 377 | $latestInfo = Http::get( $latestInfoUrl ); |
— | — | @@ -399,7 +400,7 @@ |
400 | 401 | } |
401 | 402 | |
402 | 403 | /** Environment check for DB types */ |
403 | | - function envCheckDB() { |
| 404 | + public function envCheckDB() { |
404 | 405 | $compiledDBs = array(); |
405 | 406 | $goodNames = array(); |
406 | 407 | $allNames = array(); |
— | — | @@ -424,14 +425,14 @@ |
425 | 426 | } |
426 | 427 | |
427 | 428 | /** Environment check for register_globals */ |
428 | | - function envCheckRegisterGlobals() { |
| 429 | + public function envCheckRegisterGlobals() { |
429 | 430 | if( wfIniGetBool( "magic_quotes_runtime" ) ) { |
430 | 431 | $this->showMessage( 'config-register-globals' ); |
431 | 432 | } |
432 | 433 | } |
433 | 434 | |
434 | 435 | /** Environment check for magic_quotes_runtime */ |
435 | | - function envCheckMagicQuotes() { |
| 436 | + public function envCheckMagicQuotes() { |
436 | 437 | if( wfIniGetBool( "magic_quotes_runtime" ) ) { |
437 | 438 | $this->showMessage( 'config-magic-quotes-runtime' ); |
438 | 439 | return false; |
— | — | @@ -439,7 +440,7 @@ |
440 | 441 | } |
441 | 442 | |
442 | 443 | /** Environment check for magic_quotes_sybase */ |
443 | | - function envCheckMagicSybase() { |
| 444 | + public function envCheckMagicSybase() { |
444 | 445 | if ( wfIniGetBool( 'magic_quotes_sybase' ) ) { |
445 | 446 | $this->showMessage( 'config-magic-quotes-sybase' ); |
446 | 447 | return false; |
— | — | @@ -447,7 +448,7 @@ |
448 | 449 | } |
449 | 450 | |
450 | 451 | /* Environment check for mbstring.func_overload */ |
451 | | - function envCheckMbstring() { |
| 452 | + public function envCheckMbstring() { |
452 | 453 | if ( wfIniGetBool( 'mbstring.func_overload' ) ) { |
453 | 454 | $this->showMessage( 'config-mbstring' ); |
454 | 455 | return false; |
— | — | @@ -455,7 +456,7 @@ |
456 | 457 | } |
457 | 458 | |
458 | 459 | /** Environment check for zend.ze1_compatibility_mode */ |
459 | | - function envCheckZE1() { |
| 460 | + public function envCheckZE1() { |
460 | 461 | if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) { |
461 | 462 | $this->showMessage( 'config-ze1' ); |
462 | 463 | return false; |
— | — | @@ -463,7 +464,7 @@ |
464 | 465 | } |
465 | 466 | |
466 | 467 | /** Environment check for safe_mode */ |
467 | | - function envCheckSafeMode() { |
| 468 | + public function envCheckSafeMode() { |
468 | 469 | if ( wfIniGetBool( 'safe_mode' ) ) { |
469 | 470 | $this->setVar( '_SafeMode', true ); |
470 | 471 | $this->showMessage( 'config-safe-mode' ); |
— | — | @@ -471,7 +472,7 @@ |
472 | 473 | } |
473 | 474 | |
474 | 475 | /** Environment check for the XML module */ |
475 | | - function envCheckXML() { |
| 476 | + public function envCheckXML() { |
476 | 477 | if ( !function_exists( "utf8_encode" ) ) { |
477 | 478 | $this->showMessage( 'config-xml-bad' ); |
478 | 479 | return false; |
— | — | @@ -480,7 +481,7 @@ |
481 | 482 | } |
482 | 483 | |
483 | 484 | /** Environment check for the PCRE module */ |
484 | | - function envCheckPCRE() { |
| 485 | + public function envCheckPCRE() { |
485 | 486 | if ( !function_exists( 'preg_match' ) ) { |
486 | 487 | $this->showMessage( 'config-pcre' ); |
487 | 488 | return false; |
— | — | @@ -488,7 +489,7 @@ |
489 | 490 | } |
490 | 491 | |
491 | 492 | /** Environment check for available memory */ |
492 | | - function envCheckMemory() { |
| 493 | + public function envCheckMemory() { |
493 | 494 | $limit = ini_get( 'memory_limit' ); |
494 | 495 | if ( !$limit || $limit == -1 ) { |
495 | 496 | $this->showMessage( 'config-memory-none' ); |
— | — | @@ -512,7 +513,7 @@ |
513 | 514 | } |
514 | 515 | |
515 | 516 | /** Environment check for compiled object cache types */ |
516 | | - function envCheckCache() { |
| 517 | + public function envCheckCache() { |
517 | 518 | $caches = array(); |
518 | 519 | foreach ( $this->objectCaches as $name => $function ) { |
519 | 520 | if ( function_exists( $function ) ) { |
— | — | @@ -527,7 +528,7 @@ |
528 | 529 | } |
529 | 530 | |
530 | 531 | /** Search for GNU diff3 */ |
531 | | - function envCheckDiff3() { |
| 532 | + public function envCheckDiff3() { |
532 | 533 | $paths = array_merge( |
533 | 534 | array( |
534 | 535 | "/usr/bin", |
— | — | @@ -559,7 +560,7 @@ |
560 | 561 | /** |
561 | 562 | * Search a path for any of the given executable names. Returns the |
562 | 563 | * executable name if found. Also checks the version string returned |
563 | | - * by each executable |
| 564 | + * by each executable. |
564 | 565 | * |
565 | 566 | * @param $path String: path to search |
566 | 567 | * @param $names Array of executable names |
— | — | @@ -570,7 +571,7 @@ |
571 | 572 | * If $versionInfo is not false, only executables with a version |
572 | 573 | * matching $versionInfo[1] will be returned. |
573 | 574 | */ |
574 | | - function locateExecutable( $path, $names, $versionInfo = false ) { |
| 575 | + public function locateExecutable( $path, $names, $versionInfo = false ) { |
575 | 576 | if (!is_array($names)) |
576 | 577 | $names = array($names); |
577 | 578 | |
— | — | @@ -591,7 +592,7 @@ |
592 | 593 | } |
593 | 594 | |
594 | 595 | /** Environment check for ImageMagick and GD */ |
595 | | - function envCheckGraphics() { |
| 596 | + public function envCheckGraphics() { |
596 | 597 | $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" ); |
597 | 598 | foreach( $imcheck as $dir ) { |
598 | 599 | $im = "$dir/convert"; |
— | — | @@ -609,7 +610,7 @@ |
610 | 611 | } |
611 | 612 | |
612 | 613 | /** Environment check for setting $IP and $wgScriptPath */ |
613 | | - function envCheckPath() { |
| 614 | + public function envCheckPath() { |
614 | 615 | $IP = dirname( dirname( dirname( __FILE__ ) ) ); |
615 | 616 | $this->setVar( 'IP', $IP ); |
616 | 617 | $this->showMessage( 'config-dir', $IP ); |
— | — | @@ -634,7 +635,7 @@ |
635 | 636 | } |
636 | 637 | |
637 | 638 | /** Environment check for writable config/ directory */ |
638 | | - function envCheckWriteableDir() { |
| 639 | + public function envCheckWriteableDir() { |
639 | 640 | $ipDir = $this->getVar( 'IP' ); |
640 | 641 | $configDir = $ipDir . '/config'; |
641 | 642 | if( !is_writeable( $configDir ) ) { |
— | — | @@ -649,7 +650,7 @@ |
650 | 651 | } |
651 | 652 | |
652 | 653 | /** Environment check for setting the preferred PHP file extension */ |
653 | | - function envCheckExtension() { |
| 654 | + public function envCheckExtension() { |
654 | 655 | // FIXME: detect this properly |
655 | 656 | if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) { |
656 | 657 | $ext = 'php5'; |
— | — | @@ -660,7 +661,7 @@ |
661 | 662 | $this->showMessage( 'config-file-extension', $ext ); |
662 | 663 | } |
663 | 664 | |
664 | | - function envCheckShellLocale() { |
| 665 | + public function envCheckShellLocale() { |
665 | 666 | # Give up now if we're in safe mode or open_basedir |
666 | 667 | # It's theoretically possible but tricky to work with |
667 | 668 | if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) || !function_exists( 'exec' ) ) { |
— | — | @@ -733,7 +734,7 @@ |
734 | 735 | return true; |
735 | 736 | } |
736 | 737 | |
737 | | - function envCheckUploadsDirectory() { |
| 738 | + public function envCheckUploadsDirectory() { |
738 | 739 | global $IP, $wgServer; |
739 | 740 | $dir = $IP . '/images/'; |
740 | 741 | $url = $wgServer . $this->getVar( 'wgScriptPath' ) . '/images/'; |
— | — | @@ -746,9 +747,9 @@ |
747 | 748 | } |
748 | 749 | |
749 | 750 | /** |
750 | | - * Checks if scripts located in the given directory can be executed via the given URL |
| 751 | + * Checks if scripts located in the given directory can be executed via the given URL. |
751 | 752 | */ |
752 | | - function dirIsExecutable( $dir, $url ) { |
| 753 | + public function dirIsExecutable( $dir, $url ) { |
753 | 754 | $scriptTypes = array( |
754 | 755 | 'php' => array( |
755 | 756 | "<?php echo 'ex' . 'ec';", |
— | — | @@ -792,7 +793,7 @@ |
793 | 794 | * @param $lineStart Boolean |
794 | 795 | * @return String |
795 | 796 | */ |
796 | | - function parse( $text, $lineStart = false ) { |
| 797 | + public function parse( $text, $lineStart = false ) { |
797 | 798 | global $wgParser; |
798 | 799 | try { |
799 | 800 | $out = $wgParser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart ); |
— | — | @@ -807,17 +808,17 @@ |
808 | 809 | } |
809 | 810 | |
810 | 811 | /** |
811 | | - * Register tag hook below |
| 812 | + * Register tag hook below. |
812 | 813 | */ |
813 | | - function registerDocLink( &$parser ) { |
| 814 | + public function registerDocLink( &$parser ) { |
814 | 815 | $parser->setHook( 'doclink', array( $this, 'docLink' ) ); |
815 | 816 | return true; |
816 | 817 | } |
817 | 818 | |
818 | 819 | /** |
819 | | - * Extension tag hook for a documentation link |
| 820 | + * Extension tag hook for a documentation link. |
820 | 821 | */ |
821 | | - function docLink( $linkText, $attribs, $parser ) { |
| 822 | + public function docLink( $linkText, $attribs, $parser ) { |
822 | 823 | $url = $this->getDocUrl( $attribs['href'] ); |
823 | 824 | return '<a href="' . htmlspecialchars( $url ) . '">' . |
824 | 825 | htmlspecialchars( $linkText ) . |
— | — | @@ -825,7 +826,7 @@ |
826 | 827 | } |
827 | 828 | |
828 | 829 | /** |
829 | | - * Overridden by WebInstaller to provide lastPage parameters |
| 830 | + * Overridden by WebInstaller to provide lastPage parameters. |
830 | 831 | */ |
831 | 832 | protected function getDocUrl( $page ) { |
832 | 833 | return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $attribs['href'] ); |
— | — | @@ -858,7 +859,7 @@ |
859 | 860 | } |
860 | 861 | |
861 | 862 | /** |
862 | | - * Actually perform the installation |
| 863 | + * Actually perform the installation. |
863 | 864 | * @param Array $startCB A callback array for the beginning of each step |
864 | 865 | * @param Array $endCB A callback array for the end of each step |
865 | 866 | * @return Array of Status objects |
— | — | @@ -976,10 +977,10 @@ |
977 | 978 | |
978 | 979 | /** |
979 | 980 | * Determine if LocalSettings exists. If it does, return an appropriate |
980 | | - * status for whether we should can upgrade or not |
| 981 | + * status for whether we should can upgrade or not. |
981 | 982 | * @return Status |
982 | 983 | */ |
983 | | - function getLocalSettingsStatus() { |
| 984 | + public function getLocalSettingsStatus() { |
984 | 985 | global $IP; |
985 | 986 | |
986 | 987 | $status = Status::newGood(); |
— | — | @@ -1017,7 +1018,7 @@ |
1018 | 1019 | } |
1019 | 1020 | |
1020 | 1021 | # posix_getegid() *not* getmygid() because we want the group of the webserver, |
1021 | | - # not whoever owns the current script |
| 1022 | + # not whoever owns the current script. |
1022 | 1023 | $gid = posix_getegid(); |
1023 | 1024 | $getpwuid = posix_getpwuid( $gid ); |
1024 | 1025 | $group = $getpwuid["name"]; |
— | — | @@ -1026,7 +1027,7 @@ |
1027 | 1028 | } |
1028 | 1029 | |
1029 | 1030 | /** |
1030 | | - * Override the necessary bits of the config to run an installation |
| 1031 | + * Override the necessary bits of the config to run an installation. |
1031 | 1032 | */ |
1032 | 1033 | public static function overrideConfig() { |
1033 | 1034 | define( 'MW_NO_SESSION', 1 ); |
— | — | @@ -1048,12 +1049,11 @@ |
1049 | 1050 | * @param $findStep String the step to find. Use NULL to put the step at the beginning. |
1050 | 1051 | * @param $callback array |
1051 | 1052 | */ |
1052 | | - function addInstallStepFollowing( $findStep, $callback ) { |
| 1053 | + public function addInstallStepFollowing( $findStep, $callback ) { |
1053 | 1054 | $where = 0; |
1054 | 1055 | if( $findStep !== null ) $where = array_search( $findStep, $this->installSteps ); |
1055 | 1056 | |
1056 | 1057 | array_splice( $this->installSteps, $where, 0, $callback ); |
1057 | 1058 | } |
1058 | 1059 | |
1059 | | - |
1060 | | -} |
| 1060 | +} |
\ No newline at end of file |