Merge "Fixes to the "reset password" mode of Special:ChangeEmail"
[lhc/web/wiklou.git] / includes / installer / Installer.php
index bac85cd..325f894 100644 (file)
@@ -308,24 +308,24 @@ abstract class Installer {
 
        /**
         * UI interface for displaying a short message
-        * The parameters are like parameters to wfMsg().
+        * The parameters are like parameters to wfMessage().
         * The messages will be in wikitext format, which will be converted to an
         * output format such as HTML or text before being sent to the user.
         * @param $msg
         */
-       public abstract function showMessage( $msg /*, ... */ );
+       abstract public function showMessage( $msg /*, ... */ );
 
        /**
         * Same as showMessage(), but for displaying errors
         * @param $msg
         */
-       public abstract function showError( $msg /*, ... */ );
+       abstract public function showError( $msg /*, ... */ );
 
        /**
         * Show a message to the installing user by using a Status object
         * @param $status Status
         */
-       public abstract function showStatusMessage( Status $status );
+       abstract public function showStatusMessage( Status $status );
 
        /**
         * Constructor, always call this from child classes.
@@ -339,7 +339,7 @@ abstract class Installer {
 
                // Load the installer's i18n file.
                $wgExtensionMessagesFiles['MediawikiInstaller'] =
-                       dirname( __FILE__ ) . '/Installer.i18n.php';
+                       __DIR__ . '/Installer.i18n.php';
 
                // Having a user with id = 0 safeguards us from DB access via User::loadOptions().
                $wgUser = User::newFromId( 0 );
@@ -488,7 +488,7 @@ abstract class Installer {
                if( !$_lsExists ) {
                        return false;
                }
-               unset($_lsExists);
+               unset( $_lsExists );
 
                require( "$IP/includes/DefaultSettings.php" );
                require( "$IP/LocalSettings.php" );
@@ -645,7 +645,7 @@ abstract class Installer {
                $allNames = array();
 
                foreach ( self::getDBTypes() as $name ) {
-                       $allNames[] = wfMsg( "config-type-$name" );
+                       $allNames[] = wfMessage( "config-type-$name" )->text();
                }
 
                // cache initially available databases to make sure that everything will be displayed correctly
@@ -788,6 +788,10 @@ abstract class Installer {
 
        /**
         * Environment check for the PCRE module.
+        *
+        * @note If this check were to fail, the parser would
+        *   probably throw an exception before the result
+        *   of this check is shown to the user.
         * @return bool
         */
        protected function envCheckPCRE() {
@@ -797,8 +801,13 @@ abstract class Installer {
                }
                wfSuppressWarnings();
                $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' );
+               // Need to check for \p support too, as PCRE can be compiled
+               // with utf8 support, but not unicode property support.
+               // check that \p{Zs} (space separators) matches
+               // U+3000 (Ideographic space)
+               $regexprop = preg_replace( '/\p{Zs}/u', '', "-\xE3\x80\x80-" );
                wfRestoreWarnings();
-               if ( $regexd != '--' ) {
+               if ( $regexd != '--' || $regexprop != '--' ) {
                        $this->showError( 'config-pcre-no-utf8' );
                        return false;
                }
@@ -918,7 +927,7 @@ abstract class Installer {
         * Helper function to be called from envCheckServer()
         * @return String
         */
-       protected abstract function envGetDefaultServer();
+       abstract protected function envGetDefaultServer();
 
        /**
         * Environment check for setting $IP and $wgScriptPath.
@@ -926,7 +935,7 @@ abstract class Installer {
         */
        protected function envCheckPath() {
                global $IP;
-               $IP = dirname( dirname( dirname( __FILE__ ) ) );
+               $IP = dirname( dirname( __DIR__ ) );
                $this->setVar( 'IP', $IP );
 
                $this->showMessage( 'config-using-uri', $this->getVar( 'wgServer' ), $this->getVar( 'wgScriptPath' ) );
@@ -1064,18 +1073,18 @@ abstract class Installer {
         * @return string
         */
        protected function unicodeChar( $c ) {
-               $c = hexdec($c);
-               if ($c <= 0x7F) {
-                       return chr($c);
-               } elseif ($c <= 0x7FF) {
-                       return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
-               } elseif ($c <= 0xFFFF) {
-                       return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
-                               . chr(0x80 | $c & 0x3F);
-               } elseif ($c <= 0x10FFFF) {
-                       return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
-                               . chr(0x80 | $c >> 6 & 0x3F)
-                               . chr(0x80 | $c & 0x3F);
+               $c = hexdec( $c );
+               if ( $c <= 0x7F ) {
+                       return chr( $c );
+               } elseif ( $c <= 0x7FF ) {
+                       return chr( 0xC0 | $c >> 6 ) . chr( 0x80 | $c & 0x3F );
+               } elseif ( $c <= 0xFFFF ) {
+                       return chr( 0xE0 | $c >> 12 ) . chr( 0x80 | $c >> 6 & 0x3F )
+                               . chr( 0x80 | $c & 0x3F );
+               } elseif ( $c <= 0x10FFFF ) {
+                       return chr( 0xF0 | $c >> 18 ) . chr( 0x80 | $c >> 12 & 0x3F )
+                               . chr( 0x80 | $c >> 6 & 0x3F )
+                               . chr( 0x80 | $c & 0x3F );
                } else {
                        return false;
                }
@@ -1096,8 +1105,8 @@ abstract class Installer {
                 * Note that we use the hex representation to create the code
                 * points in order to avoid any Unicode-destroying during transit.
                 */
-               $not_normal_c = $this->unicodeChar("FA6C");
-               $normal_c = $this->unicodeChar("242EE");
+               $not_normal_c = $this->unicodeChar( "FA6C" );
+               $normal_c = $this->unicodeChar( "242EE" );
 
                $useNormalizer = 'php';
                $needsUpdate = false;
@@ -1586,15 +1595,15 @@ abstract class Installer {
                try {
                        $page = WikiPage::factory( Title::newMainPage() );
                        $content = new WikitextContent (
-                               wfMsgForContent( 'mainpagetext' ) . "\n\n" .
-                               wfMsgForContent( 'mainpagedocfooter' )
+                               wfMessage( 'mainpagetext' )->inContentLanguage()->text() . "\n\n" .
+                               wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text()
                        );
 
                        $page->doEditContent( $content,
-                                                       '',
-                                                       EDIT_NEW,
-                                                       false,
-                                                       User::newFromName( 'MediaWiki default' ) );
+                                       '',
+                                       EDIT_NEW,
+                                       false,
+                                       User::newFromName( 'MediaWiki default' ) );
                } catch (MWException $e) {
                        //using raw, because $wgShowExceptionDetails can not be set yet
                        $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );