(bug 38249) No PCRE unicode causes installer to spew giberish
authorBrian Wolff <bawolff+wn@gmail.com>
Sun, 19 Aug 2012 17:44:00 +0000 (14:44 -0300)
committerCatrope <roan.kattouw@gmail.com>
Wed, 22 Aug 2012 01:35:17 +0000 (18:35 -0700)
If PHP's PCRE is not compiled with unicode property support, this causes
the regexes used by the parser to not compile, causing the parser to
output giberish. Its been reported that the default PHP package for
cent os has PCRE in such a config.

As a result the installer will output total giberish. The user has
no idea what went wrong because there is no meaningful output.

To counter that, cause Parser to throw an exception in that case.
It seemed easier than figuring out how to convince the installer
not to parse the environment check. For completeness sake though
I fixed the PCRE environment check to adequetely check for PCRE
not having unicode support.

This should be backported to 1.19 since there are quite a few
complaints about the issue on project:Support_desk. /me has
no idea what the procedure for that is in our new git world

Change-Id: Idb1658be4ee6203a55740450e335f570a616671c

RELEASE-NOTES-1.20
includes/installer/Installer.php
includes/parser/Parser.php

index 3364519..012d04d 100644 (file)
@@ -214,6 +214,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
   are now remembered between successive clicks.
 * (bug 26069) Page title is no longer "Error" for all error pages
 * (bug 39297) Show warning if thumbnail of animated image will not be animated.
+* (bug 38249) Parser will throw an exception instead of outputting gibberish if
+  PCRE is compiled without support for unicode properties.
 
 === API changes in 1.20 ===
 * (bug 34316) Add ability to retrieve maximum upload size from MediaWiki API.
index d87f294..2cad7d1 100644 (file)
@@ -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;
                }
index 2d5f966..489451a 100644 (file)
@@ -1522,6 +1522,9 @@ class Parser {
                wfProfileIn( __METHOD__ );
 
                $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
+               if ( $bits === false ) {
+                       throw new MWException( "PCRE needs to be compiled with --enable-unicode-properties in order for MediaWiki to function" );
+               }
                $s = array_shift( $bits );
 
                $i = 0;