A few more ok -> done
[lhc/web/wiklou.git] / includes / installer / Installer.php
index 8615516..d8afba1 100644 (file)
@@ -97,6 +97,7 @@ abstract class Installer {
                'envCheckPCRE',
                'envCheckMemory',
                'envCheckCache',
+               'envCheckModSecurity',
                'envCheckDiff3',
                'envCheckGraphics',
                'envCheckServer',
@@ -332,12 +333,14 @@ abstract class Installer {
                        $this->settings[$var] = $GLOBALS[$var];
                }
 
+               $compiledDBs = array();
                foreach ( self::getDBTypes() as $type ) {
                        $installer = $this->getDBInstaller( $type );
 
                        if ( !$installer->isCompiled() ) {
                                continue;
                        }
+                       $compiledDBs[] = $type;
 
                        $defaults = $installer->getGlobalDefaults();
 
@@ -349,6 +352,7 @@ abstract class Installer {
                                }
                        }
                }
+               $this->setVar( '_CompiledDBs', $compiledDBs );
 
                $this->parserTitle = Title::newFromText( 'Installer' );
                $this->parserOptions = new ParserOptions; // language will  be wrong :(
@@ -621,19 +625,13 @@ abstract class Installer {
        protected function envCheckDB() {
                global $wgLang;
 
-               $compiledDBs = array();
                $allNames = array();
 
                foreach ( self::getDBTypes() as $name ) {
-                       if ( $this->getDBInstaller( $name )->isCompiled() ) {
-                               $compiledDBs[] = $name;
-                       }
-                       $allNames[] = wfMsg( 'config-type-' . $name );
+                       $allNames[] = wfMsg( "config-type-$name" );
                }
 
-               $this->setVar( '_CompiledDBs', $compiledDBs );
-
-               if ( !$compiledDBs ) {
+               if ( !$this->getVar( '_CompiledDBs' ) ) {
                        $this->showError( 'config-no-db', $wgLang->commaList( $allNames ) );
                        // @todo FIXME: This only works for the web installer!
                        return false;
@@ -805,6 +803,15 @@ abstract class Installer {
                $this->setVar( '_Caches', $caches );
        }
 
+       /**
+        * Scare user to death if they have mod_security
+        */
+       protected function envCheckModSecurity() {
+               if ( self::apacheModulePresent( 'mod_security' ) ) {
+                       $this->showMessage( 'config-mod-security' );
+               }
+       }
+
        /**
         * Search for GNU diff3.
         */
@@ -846,7 +853,12 @@ abstract class Installer {
         * Environment check for the server hostname.
         */
        protected function envCheckServer() {
-               $server = WebRequest::detectServer();
+               if ( $this->getVar( 'wgServer' ) ) {
+                       // wgServer was pre-defined, perhaps by the cli installer
+                       $server = $this->getVar( 'wgServer' );
+               } else {
+                       $server = WebRequest::detectServer();
+               }
                $this->showMessage( 'config-using-server', $server );
                $this->setVar( 'wgServer', $server );
        }
@@ -858,6 +870,9 @@ abstract class Installer {
                global $IP;
                $IP = dirname( dirname( dirname( __FILE__ ) ) );
                $this->setVar( 'IP', $IP );
+
+               $this->showMessage( 'config-using-uri', $this->getVar( 'wgServer' ), $this->getVar( 'wgScriptPath' ) );
+               return true;
        }
 
        /**
@@ -971,7 +986,10 @@ abstract class Installer {
        protected function envCheckSuhosinMaxValueLength() {
                $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
                if ( $maxValueLength > 0 ) {
-                       $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
+                       if( $maxValueLength < 1024 ) {
+                               # Only warn if the value is below the sane 1024
+                               $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
+                       }
                } else {
                        $maxValueLength = -1;
                }
@@ -1028,7 +1046,7 @@ abstract class Installer {
                 */
                if( $utf8 ) {
                        $useNormalizer = 'utf8';
-                       $utf8 = utf8_normalize( $not_normal_c, UNORM_NFC );
+                       $utf8 = utf8_normalize( $not_normal_c, UtfNormal::UNORM_NFC );
                        if ( $utf8 !== $normal_c ) $needsUpdate = true;
                }
                if( $intl ) {
@@ -1108,6 +1126,9 @@ abstract class Installer {
        /**
         * Same as locateExecutable(), but checks in getPossibleBinPaths() by default
         * @see locateExecutable()
+        * @param $names
+        * @param $versionInfo bool
+        * @return bool|string
         */
        public static function locateExecutableInDefaultPaths( $names, $versionInfo = false ) {
                foreach( self::getPossibleBinPaths() as $path ) {
@@ -1165,6 +1186,23 @@ abstract class Installer {
                return false;
        }
 
+       /**
+        * 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.
+        * @return bool
+        */
+       public static function apacheModulePresent( $moduleName ) {
+               if ( function_exists( 'apache_get_modules' ) && in_array( $moduleName, apache_get_modules() ) ) {
+                       return true;
+               }
+               // try it the hard way
+               ob_start();
+               phpinfo( INFO_MODULES );
+               $info = ob_get_clean();
+               return strpos( $info, $moduleName ) !== false;
+       }
+
        /**
         * ParserOptions are constructed before we determined the language, so fix it
         *
@@ -1172,11 +1210,13 @@ abstract class Installer {
         */
        public function setParserLanguage( $lang ) {
                $this->parserOptions->setTargetLanguage( $lang );
-               $this->parserOptions->setUserLang( $lang->getCode() );
+               $this->parserOptions->setUserLang( $lang );
        }
 
        /**
         * Overridden by WebInstaller to provide lastPage parameters.
+        * @param $page stirng
+        * @return string
         */
        protected function getDocUrl( $page ) {
                return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
@@ -1464,6 +1504,7 @@ abstract class Installer {
        /**
         * Insert Main Page with default content.
         *
+        * @param $installer DatabaseInstaller
         * @return Status
         */
        protected function createMainpage( DatabaseInstaller $installer ) {