r69526 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69525‎ | r69526 | r69527 >
Date:02:41, 19 July 2010
Author:jeroendedauw
Status:ok
Tags:
Comment:
Clarified field and method visibility
Modified paths:
  • /trunk/phase3/includes/installer/Installer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/Installer.php
@@ -1,11 +1,12 @@
22 <?php
33
44 /**
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.
77 */
88 abstract class Installer {
9 - var $settings, $output;
 9+ public $settings;
 10+ public $output;
1011
1112 /**
1213 * MediaWiki configuration globals that will eventually be passed through
@@ -88,7 +89,7 @@
8990 );
9091
9192 /**
92 - * Minimum memory size in MB
 93+ * Minimum memory size in MB.
9394 */
9495 private $minMemorySize = 50;
9596
@@ -136,7 +137,7 @@
137138 );
138139
139140 /**
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.
141142 */
142143 protected $objectCaches = array(
143144 'xcache' => 'xcache_get',
@@ -146,9 +147,9 @@
147148 );
148149
149150 /**
150 - * User rights profiles
 151+ * User rights profiles.
151152 */
152 - var $rightsProfiles = array(
 153+ public $rightsProfiles = array(
153154 'wiki' => array(),
154155 'no-anon' => array(
155156 '*' => array( 'edit' => false )
@@ -169,9 +170,9 @@
170171 );
171172
172173 /**
173 - * License types
 174+ * License types.
174175 */
175 - var $licenses = array(
 176+ public $licenses = array(
176177 'none' => array(
177178 'url' => '',
178179 'icon' => '',
@@ -212,7 +213,7 @@
213214 /**
214215 * Constructor, always call this from child classes
215216 */
216 - function __construct() {
 217+ public function __construct() {
217218 // Disable the i18n cache and LoadBalancer
218219 Language::getLocalisationCache()->disableBackend();
219220 LBFactory::disableBackend();
@@ -260,22 +261,22 @@
261262 * The messages will be in wikitext format, which will be converted to an
262263 * output format such as HTML or text before being sent to the user.
263264 */
264 - abstract function showMessage( $msg /*, ... */ );
 265+ public abstract function showMessage( $msg /*, ... */ );
265266
266 - abstract function showStatusMessage( $status );
 267+ public abstract function showStatusMessage( $status );
267268
268269 /**
269 - * Get a list of known DB types
 270+ * Get a list of known DB types.
270271 */
271 - function getDBTypes() {
 272+ public function getDBTypes() {
272273 return $this->dbTypes;
273274 }
274275
275276 /**
276277 * 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.
278279 */
279 - function getDBInstaller( $type = false ) {
 280+ public function getDBInstaller( $type = false ) {
280281 if ( !$type ) {
281282 $type = $this->getVar( 'wgDBtype' );
282283 }
@@ -299,7 +300,7 @@
300301 * Under the web subclass, it can already be assumed that PHP 5+ is in use
301302 * and that sessions are working.
302303 */
303 - function doEnvironmentChecks() {
 304+ public function doEnvironmentChecks() {
304305 $this->showMessage( 'config-env-php', phpversion() );
305306
306307 $good = true;
@@ -323,7 +324,7 @@
324325 * The defaults come from $GLOBALS (ultimately DefaultSettings.php).
325326 * Installer variables are typically prefixed by an underscore.
326327 */
327 - function getVar( $name, $default = null ) {
 328+ public function getVar( $name, $default = null ) {
328329 if ( !isset( $this->settings[$name] ) ) {
329330 return $default;
330331 } else {
@@ -334,14 +335,14 @@
335336 /**
336337 * Set a MW configuration variable, or internal installer configuration variable.
337338 */
338 - function setVar( $name, $value ) {
 339+ public function setVar( $name, $value ) {
339340 $this->settings[$name] = $value;
340341 }
341342
342343 /**
343344 * Exports all wg* variables stored by the installer into global scope
344345 */
345 - function exportVars() {
 346+ public function exportVars() {
346347 foreach ( $this->settings as $name => $value ) {
347348 if ( substr( $name, 0, 2 ) == 'wg' ) {
348349 $GLOBALS[$name] = $value;
@@ -354,7 +355,7 @@
355356 * This is a security mechanism to avoid compromise of the password in the
356357 * event of session ID compromise.
357358 */
358 - function getFakePassword( $realPassword ) {
 359+ public function getFakePassword( $realPassword ) {
359360 return str_repeat( '*', strlen( $realPassword ) );
360361 }
361362
@@ -362,14 +363,14 @@
363364 * Set a variable which stores a password, except if the new value is a
364365 * fake password in which case leave it as it is.
365366 */
366 - function setPassword( $name, $value ) {
 367+ public function setPassword( $name, $value ) {
367368 if ( !preg_match( '/^\*+$/', $value ) ) {
368369 $this->setVar( $name, $value );
369370 }
370371 }
371372
372373 /** Check if we're installing the latest version */
373 - function envLatestVersion() {
 374+ public function envLatestVersion() {
374375 global $wgVersion;
375376 $latestInfoUrl = 'http://www.mediawiki.org/w/api.php?action=mwreleases&format=json';
376377 $latestInfo = Http::get( $latestInfoUrl );
@@ -399,7 +400,7 @@
400401 }
401402
402403 /** Environment check for DB types */
403 - function envCheckDB() {
 404+ public function envCheckDB() {
404405 $compiledDBs = array();
405406 $goodNames = array();
406407 $allNames = array();
@@ -424,14 +425,14 @@
425426 }
426427
427428 /** Environment check for register_globals */
428 - function envCheckRegisterGlobals() {
 429+ public function envCheckRegisterGlobals() {
429430 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
430431 $this->showMessage( 'config-register-globals' );
431432 }
432433 }
433434
434435 /** Environment check for magic_quotes_runtime */
435 - function envCheckMagicQuotes() {
 436+ public function envCheckMagicQuotes() {
436437 if( wfIniGetBool( "magic_quotes_runtime" ) ) {
437438 $this->showMessage( 'config-magic-quotes-runtime' );
438439 return false;
@@ -439,7 +440,7 @@
440441 }
441442
442443 /** Environment check for magic_quotes_sybase */
443 - function envCheckMagicSybase() {
 444+ public function envCheckMagicSybase() {
444445 if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
445446 $this->showMessage( 'config-magic-quotes-sybase' );
446447 return false;
@@ -447,7 +448,7 @@
448449 }
449450
450451 /* Environment check for mbstring.func_overload */
451 - function envCheckMbstring() {
 452+ public function envCheckMbstring() {
452453 if ( wfIniGetBool( 'mbstring.func_overload' ) ) {
453454 $this->showMessage( 'config-mbstring' );
454455 return false;
@@ -455,7 +456,7 @@
456457 }
457458
458459 /** Environment check for zend.ze1_compatibility_mode */
459 - function envCheckZE1() {
 460+ public function envCheckZE1() {
460461 if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) {
461462 $this->showMessage( 'config-ze1' );
462463 return false;
@@ -463,7 +464,7 @@
464465 }
465466
466467 /** Environment check for safe_mode */
467 - function envCheckSafeMode() {
 468+ public function envCheckSafeMode() {
468469 if ( wfIniGetBool( 'safe_mode' ) ) {
469470 $this->setVar( '_SafeMode', true );
470471 $this->showMessage( 'config-safe-mode' );
@@ -471,7 +472,7 @@
472473 }
473474
474475 /** Environment check for the XML module */
475 - function envCheckXML() {
 476+ public function envCheckXML() {
476477 if ( !function_exists( "utf8_encode" ) ) {
477478 $this->showMessage( 'config-xml-bad' );
478479 return false;
@@ -480,7 +481,7 @@
481482 }
482483
483484 /** Environment check for the PCRE module */
484 - function envCheckPCRE() {
 485+ public function envCheckPCRE() {
485486 if ( !function_exists( 'preg_match' ) ) {
486487 $this->showMessage( 'config-pcre' );
487488 return false;
@@ -488,7 +489,7 @@
489490 }
490491
491492 /** Environment check for available memory */
492 - function envCheckMemory() {
 493+ public function envCheckMemory() {
493494 $limit = ini_get( 'memory_limit' );
494495 if ( !$limit || $limit == -1 ) {
495496 $this->showMessage( 'config-memory-none' );
@@ -512,7 +513,7 @@
513514 }
514515
515516 /** Environment check for compiled object cache types */
516 - function envCheckCache() {
 517+ public function envCheckCache() {
517518 $caches = array();
518519 foreach ( $this->objectCaches as $name => $function ) {
519520 if ( function_exists( $function ) ) {
@@ -527,7 +528,7 @@
528529 }
529530
530531 /** Search for GNU diff3 */
531 - function envCheckDiff3() {
 532+ public function envCheckDiff3() {
532533 $paths = array_merge(
533534 array(
534535 "/usr/bin",
@@ -559,7 +560,7 @@
560561 /**
561562 * Search a path for any of the given executable names. Returns the
562563 * executable name if found. Also checks the version string returned
563 - * by each executable
 564+ * by each executable.
564565 *
565566 * @param $path String: path to search
566567 * @param $names Array of executable names
@@ -570,7 +571,7 @@
571572 * If $versionInfo is not false, only executables with a version
572573 * matching $versionInfo[1] will be returned.
573574 */
574 - function locateExecutable( $path, $names, $versionInfo = false ) {
 575+ public function locateExecutable( $path, $names, $versionInfo = false ) {
575576 if (!is_array($names))
576577 $names = array($names);
577578
@@ -591,7 +592,7 @@
592593 }
593594
594595 /** Environment check for ImageMagick and GD */
595 - function envCheckGraphics() {
 596+ public function envCheckGraphics() {
596597 $imcheck = array( "/usr/bin", "/opt/csw/bin", "/usr/local/bin", "/sw/bin", "/opt/local/bin" );
597598 foreach( $imcheck as $dir ) {
598599 $im = "$dir/convert";
@@ -609,7 +610,7 @@
610611 }
611612
612613 /** Environment check for setting $IP and $wgScriptPath */
613 - function envCheckPath() {
 614+ public function envCheckPath() {
614615 $IP = dirname( dirname( dirname( __FILE__ ) ) );
615616 $this->setVar( 'IP', $IP );
616617 $this->showMessage( 'config-dir', $IP );
@@ -634,7 +635,7 @@
635636 }
636637
637638 /** Environment check for writable config/ directory */
638 - function envCheckWriteableDir() {
 639+ public function envCheckWriteableDir() {
639640 $ipDir = $this->getVar( 'IP' );
640641 $configDir = $ipDir . '/config';
641642 if( !is_writeable( $configDir ) ) {
@@ -649,7 +650,7 @@
650651 }
651652
652653 /** Environment check for setting the preferred PHP file extension */
653 - function envCheckExtension() {
 654+ public function envCheckExtension() {
654655 // FIXME: detect this properly
655656 if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
656657 $ext = 'php5';
@@ -660,7 +661,7 @@
661662 $this->showMessage( 'config-file-extension', $ext );
662663 }
663664
664 - function envCheckShellLocale() {
 665+ public function envCheckShellLocale() {
665666 # Give up now if we're in safe mode or open_basedir
666667 # It's theoretically possible but tricky to work with
667668 if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) || !function_exists( 'exec' ) ) {
@@ -733,7 +734,7 @@
734735 return true;
735736 }
736737
737 - function envCheckUploadsDirectory() {
 738+ public function envCheckUploadsDirectory() {
738739 global $IP, $wgServer;
739740 $dir = $IP . '/images/';
740741 $url = $wgServer . $this->getVar( 'wgScriptPath' ) . '/images/';
@@ -746,9 +747,9 @@
747748 }
748749
749750 /**
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.
751752 */
752 - function dirIsExecutable( $dir, $url ) {
 753+ public function dirIsExecutable( $dir, $url ) {
753754 $scriptTypes = array(
754755 'php' => array(
755756 "<?php echo 'ex' . 'ec';",
@@ -792,7 +793,7 @@
793794 * @param $lineStart Boolean
794795 * @return String
795796 */
796 - function parse( $text, $lineStart = false ) {
 797+ public function parse( $text, $lineStart = false ) {
797798 global $wgParser;
798799 try {
799800 $out = $wgParser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
@@ -807,17 +808,17 @@
808809 }
809810
810811 /**
811 - * Register tag hook below
 812+ * Register tag hook below.
812813 */
813 - function registerDocLink( &$parser ) {
 814+ public function registerDocLink( &$parser ) {
814815 $parser->setHook( 'doclink', array( $this, 'docLink' ) );
815816 return true;
816817 }
817818
818819 /**
819 - * Extension tag hook for a documentation link
 820+ * Extension tag hook for a documentation link.
820821 */
821 - function docLink( $linkText, $attribs, $parser ) {
 822+ public function docLink( $linkText, $attribs, $parser ) {
822823 $url = $this->getDocUrl( $attribs['href'] );
823824 return '<a href="' . htmlspecialchars( $url ) . '">' .
824825 htmlspecialchars( $linkText ) .
@@ -825,7 +826,7 @@
826827 }
827828
828829 /**
829 - * Overridden by WebInstaller to provide lastPage parameters
 830+ * Overridden by WebInstaller to provide lastPage parameters.
830831 */
831832 protected function getDocUrl( $page ) {
832833 return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $attribs['href'] );
@@ -858,7 +859,7 @@
859860 }
860861
861862 /**
862 - * Actually perform the installation
 863+ * Actually perform the installation.
863864 * @param Array $startCB A callback array for the beginning of each step
864865 * @param Array $endCB A callback array for the end of each step
865866 * @return Array of Status objects
@@ -976,10 +977,10 @@
977978
978979 /**
979980 * 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.
981982 * @return Status
982983 */
983 - function getLocalSettingsStatus() {
 984+ public function getLocalSettingsStatus() {
984985 global $IP;
985986
986987 $status = Status::newGood();
@@ -1017,7 +1018,7 @@
10181019 }
10191020
10201021 # 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.
10221023 $gid = posix_getegid();
10231024 $getpwuid = posix_getpwuid( $gid );
10241025 $group = $getpwuid["name"];
@@ -1026,7 +1027,7 @@
10271028 }
10281029
10291030 /**
1030 - * Override the necessary bits of the config to run an installation
 1031+ * Override the necessary bits of the config to run an installation.
10311032 */
10321033 public static function overrideConfig() {
10331034 define( 'MW_NO_SESSION', 1 );
@@ -1048,12 +1049,11 @@
10491050 * @param $findStep String the step to find. Use NULL to put the step at the beginning.
10501051 * @param $callback array
10511052 */
1052 - function addInstallStepFollowing( $findStep, $callback ) {
 1053+ public function addInstallStepFollowing( $findStep, $callback ) {
10531054 $where = 0;
10541055 if( $findStep !== null ) $where = array_search( $findStep, $this->installSteps );
10551056
10561057 array_splice( $this->installSteps, $where, 0, $callback );
10571058 }
10581059
1059 -
1060 -}
 1060+}
\ No newline at end of file

Status & tagging log