Merge "Fixed spacing in skins folder"
[lhc/web/wiklou.git] / includes / installer / Installer.php
index 4d8e5f0..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;
                }
@@ -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']]
                                );
                        }
                }
@@ -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() );
                }