Merge "Fixed spacing in skins folder"
[lhc/web/wiklou.git] / includes / installer / Installer.php
index e349b6a..6a7970b 100644 (file)
@@ -114,6 +114,7 @@ abstract class Installer {
                'envCheckModSecurity',
                'envCheckDiff3',
                'envCheckGraphics',
+               'envCheckGit',
                'envCheckServer',
                'envCheckPath',
                'envCheckExtension',
@@ -147,6 +148,7 @@ abstract class Installer {
                'wgDBtype',
                'wgDiff3',
                'wgImageMagickConvertCommand',
+               'wgGitBin',
                'IP',
                'wgServer',
                'wgScriptPath',
@@ -464,7 +466,7 @@ abstract class Installer {
                $type = strtolower( $type );
 
                if ( !isset( $this->dbInstallers[$type] ) ) {
-                       $class = ucfirst( $type ). 'Installer';
+                       $class = ucfirst( $type ) . 'Installer';
                        $this->dbInstallers[$type] = new $class( $this );
                }
 
@@ -643,6 +645,8 @@ abstract class Installer {
 
                $allNames = array();
 
+               // Give grep a chance to find the usages:
+               // config-type-mysql, config-type-postgres, config-type-oracle, config-type-sqlite
                foreach ( self::getDBTypes() as $name ) {
                        $allNames[] = wfMessage( "config-type-$name" )->text();
                }
@@ -896,7 +900,8 @@ abstract class Installer {
         */
        protected function envCheckGraphics() {
                $names = array( wfIsWindows() ? 'convert.exe' : 'convert' );
-               $convert = self::locateExecutableInDefaultPaths( $names, array( '$1 -version', 'ImageMagick' ) );
+               $versionInfo = array( '$1 -version', 'ImageMagick' );
+               $convert = self::locateExecutableInDefaultPaths( $names, $versionInfo );
 
                $this->setVar( 'wgImageMagickConvertCommand', '' );
                if ( $convert ) {
@@ -912,6 +917,28 @@ abstract class Installer {
                return true;
        }
 
+       /**
+        * Search for git.
+        *
+        * @since 1.22
+        * @return bool
+        */
+       protected function envCheckGit() {
+               $names = array( wfIsWindows() ? 'git.exe' : 'git' );
+               $versionInfo = array( '$1 --version', 'git version' );
+
+               $git = self::locateExecutableInDefaultPaths( $names, $versionInfo );
+
+               if ( $git ) {
+                       $this->setVar( 'wgGitBin', $git );
+                       $this->showMessage( 'config-git', $git );
+               } else {
+                       $this->setVar( 'wgGitBin', false );
+                       $this->showMessage( 'config-git-bad' );
+               }
+               return true;
+       }
+
        /**
         * Environment check for the server hostname.
         */
@@ -995,7 +1022,7 @@ abstract class Installer {
                }
 
                # Try the current value of LANG.
-               if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
+               if ( isset( $candidatesByLocale[getenv( 'LANG' )] ) ) {
                        $this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
                        return true;
                }
@@ -1172,8 +1199,8 @@ abstract class Installer {
         *
         * Used only by environment checks.
         *
-        * @param $path String: path to search
-        * @param $names Array of executable names
+        * @param string $path path to search
+        * @param array $names of executable names
         * @param $versionInfo Boolean false or array with two members:
         *               0 => Command to run for version check, with $1 for the full executable name
         *               1 => String to compare the output with
@@ -1277,7 +1304,7 @@ abstract class Installer {
        /**
         * Checks for presence of an Apache module. Works only if PHP is running as an Apache module, too.
         *
-        * @param $moduleName String: Name of module to check.
+        * @param string $moduleName Name of module to check.
         * @return bool
         */
        public static function apacheModulePresent( $moduleName ) {
@@ -1318,13 +1345,16 @@ abstract class Installer {
         */
        public function findExtensions() {
                if( $this->getVar( 'IP' ) === null ) {
-                       return false;
+                       return array();
                }
 
-               $exts = array();
                $extDir = $this->getVar( 'IP' ) . '/extensions';
-               $dh = opendir( $extDir );
+               if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) {
+                       return array();
+               }
 
+               $dh = opendir( $extDir );
+               $exts = array();
                while ( ( $file = readdir( $dh ) ) !== false ) {
                        if( !is_dir( "$extDir/$file" ) ) {
                                continue;
@@ -1333,6 +1363,7 @@ abstract class Installer {
                                $exts[] = $file;
                        }
                }
+               closedir( $dh );
                natcasesort( $exts );
 
                return $exts;
@@ -1402,10 +1433,10 @@ abstract class Installer {
                // then adding any callbacks that wanted to attach after a given step
                foreach( $coreInstallSteps as $step ) {
                        $this->installSteps[] = $step;
-                       if( isset( $this->extraInstallSteps[ $step['name'] ] ) ) {
+                       if( isset( $this->extraInstallSteps[$step['name']] ) ) {
                                $this->installSteps = array_merge(
                                        $this->installSteps,
-                                       $this->extraInstallSteps[ $step['name'] ]
+                                       $this->extraInstallSteps[$step['name']]
                                );
                        }
                }
@@ -1434,8 +1465,8 @@ abstract class Installer {
        /**
         * Actually perform the installation.
         *
-        * @param $startCB Array A callback array for the beginning of each step
-        * @param $endCB Array A callback array for the end of each step
+        * @param array $startCB A callback array for the beginning of each step
+        * @param array $endCB A callback array for the end of each step
         *
         * @return Array of Status objects
         */
@@ -1592,7 +1623,7 @@ abstract class Installer {
                $status = Status::newGood();
                try {
                        $page = WikiPage::factory( Title::newMainPage() );
-                       $content = new WikitextContent (
+                       $content = new WikitextContent(
                                wfMessage( 'mainpagetext' )->inContentLanguage()->text() . "\n\n" .
                                wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text()
                        );
@@ -1602,7 +1633,7 @@ abstract class Installer {
                                        EDIT_NEW,
                                        false,
                                        User::newFromName( 'MediaWiki default' ) );
-               } catch (MWException $e) {
+               } catch ( MWException $e ) {
                        //using raw, because $wgShowExceptionDetails can not be set yet
                        $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
                }
@@ -1642,9 +1673,9 @@ abstract class Installer {
        /**
         * Add an installation step following the given step.
         *
-        * @param $callback Array A valid installation callback array, in this form:
+        * @param array $callback A valid installation callback array, in this form:
         *    array( 'name' => 'some-unique-name', 'callback' => array( $obj, 'function' ) );
-        * @param $findStep String the step to find. Omit to put the step at the beginning
+        * @param string $findStep the step to find. Omit to put the step at the beginning
         */
        public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
                $this->extraInstallSteps[$findStep][] = $callback;