Remove Fallback::iconv()
authorKevin Israel <pleasestand@live.com>
Mon, 2 Jun 2014 05:30:21 +0000 (01:30 -0400)
committerKevin Israel <pleasestand@live.com>
Mon, 21 Jul 2014 04:36:22 +0000 (00:36 -0400)
The iconv fallback is, for the most part, a remnant of PHP 4 support.
Though iconv was not enabled by default in PHP 4, it is in PHP 5. This
is the case even for Windows builds, which use GNU libiconv.

As for the major Linux distributions:

* Debian, CentOS, Ubuntu -> always enabled
* Fedora, Slackware -> .so in the same package, enabled by default
* Arch -> .so in the same package, disabled by default
* openSUSE -> separate package

Change-Id: Ie1112a5742646a0e1f951e188480c23851859320

RELEASE-NOTES-1.24
includes/Fallback.php
includes/GlobalFunctions.php
includes/installer/Installer.php
includes/installer/i18n/en.json
includes/installer/i18n/qqq.json
includes/media/Exif.php
includes/utils/ZipDirectoryReader.php

index d76cd29..c66758f 100644 (file)
@@ -12,6 +12,9 @@ production.
 * MediaWiki will no longer run if register_globals is enabled. It has been
   deprecated for 5 years now, and was removed in PHP 5.4. For more information
   about why, see <https://www.mediawiki.org/wiki/register_globals>.
+* MediaWiki now requires PHP's iconv extension. openSUSE users may need to
+  install the php5-iconv package. Users of other systems may need to add
+  extension=iconv.so to php.ini or recompile PHP without --without-iconv.
 * The server's canonical hostname is available as $wgServerName, which is
   exposed in both mw.config and ApiQuerySiteInfo.
 * Introduced $wgPagePropsHaveSortkey as a backwards-compatibility switch,
index e38bdf1..c4b22f5 100644 (file)
  */
 class Fallback {
 
-       /**
-        * @param string $from
-        * @param string $to
-        * @param string $string
-        * @return string
-        */
-       public static function iconv( $from, $to, $string ) {
-               if ( substr( $to, -8 ) == '//IGNORE' ) {
-                       $to = substr( $to, 0, strlen( $to ) - 8 );
-               }
-               if ( strcasecmp( $from, $to ) == 0 ) {
-                       return $string;
-               }
-               if ( strcasecmp( $from, 'utf-8' ) == 0 ) {
-                       return utf8_decode( $string );
-               }
-               if ( strcasecmp( $to, 'utf-8' ) == 0 ) {
-                       return utf8_encode( $string );
-               }
-               return $string;
-       }
-
        /**
         * Fallback implementation for mb_substr, hardcoded to UTF-8.
         * Attempts to be at least _moderately_ efficient; best optimized
index feca005..b41ec9f 100644 (file)
@@ -35,16 +35,6 @@ if ( !defined( 'MEDIAWIKI' ) ) {
  * PHP extensions may be included here.
  */
 
-if ( !function_exists( 'iconv' ) ) {
-       /**
-        * @codeCoverageIgnore
-        * @return string
-        */
-       function iconv( $from, $to, $string ) {
-               return Fallback::iconv( $from, $to, $string );
-       }
-}
-
 if ( !function_exists( 'mb_substr' ) ) {
        /**
         * @codeCoverageIgnore
index 7c67ee8..cdc8266 100644 (file)
@@ -137,6 +137,7 @@ abstract class Installer {
                'envCheckLibicu',
                'envCheckSuhosinMaxValueLength',
                'envCheckCtype',
+               'envCheckIconv',
                'envCheckJSON',
        );
 
@@ -1206,6 +1207,19 @@ abstract class Installer {
                return true;
        }
 
+       /**
+        * @return bool
+        */
+       protected function envCheckIconv() {
+               if ( !function_exists( 'iconv' ) ) {
+                       $this->showError( 'config-iconv' );
+
+                       return false;
+               }
+
+               return true;
+       }
+
        /**
         * @return bool
         */
index b6606a6..f25c562 100644 (file)
@@ -62,6 +62,7 @@
        "config-memory-raised": "PHP's <code>memory_limit</code> is $1, raised to $2.",
        "config-memory-bad": "<strong>Warning:</strong> PHP's <code>memory_limit</code> is $1.\nThis is probably too low.\nThe installation may fail!",
        "config-ctype": "<strong>Fatal:</strong> PHP must be compiled with support for the [http://www.php.net/manual/en/ctype.installation.php Ctype extension].",
+       "config-iconv": "<strong>Fatal:</strong> PHP must be compiled with support for the [http://www.php.net/manual/en/iconv.installation.php iconv extension].",
        "config-json": "<strong>Fatal:</strong> PHP was compiled without JSON support.\nYou must install either the PHP JSON extension or the [http://pecl.php.net/package/jsonc PECL jsonc] extension before installing MediaWiki.\n* The PHP extension is included in Red Hat Enterprise Linux (CentOS) 5 and 6, though must be enabled in <code>/etc/php.ini</code> or <code>/etc/php.d/json.ini</code>.\n* Some Linux distributions released after May 2013 omit the PHP extension, instead packaging the PECL extension as <code>php5-json</code> or <code>php-pecl-jsonc</code>.",
        "config-xcache": "[http://xcache.lighttpd.net/ XCache] is installed",
        "config-apc": "[http://www.php.net/apc APC] is installed",
index d0a37a7..6ec724f 100644 (file)
@@ -80,6 +80,7 @@
        "config-memory-raised": "Parameters:\n* $1 is the configured <code>memory_limit</code>.\n* $2 is the value to which <code>memory_limit</code> was raised.",
        "config-memory-bad": "Parameters:\n* $1 is the configured <code>memory_limit</code>.",
        "config-ctype": "Message if support for [http://www.php.net/manual/en/ctype.installation.php Ctype] is missing from PHP.\n{{Related|Config-fatal}}",
+       "config-iconv": "Message if support for [http://www.php.net/manual/en/iconv.installation.php iconv] is missing from PHP.\n{{Related|Config-fatal}}",
        "config-json": "Message if support for [[wikipedia:JSON|JSON]] is missing from PHP.\n* \"[[wikipedia:Red Hat Enterprise Linux|Red Hat Enterprise Linux]]\" (RHEL) and \"[[wikipedia:CentOS|CentOS]]\" refer to two almost-identical Linux distributions. \"5 and 6\" refers to version 5 or 6 of either distribution. Because RHEL 7 likely will not include the PHP extension, do not translate as \"5 or newer\".\n* \"The [http://www.php.net/json PHP extension]\" is the JSON extension included with PHP 5.2 and newer.\n* \"The [http://pecl.php.net/package/jsonc PECL extension]\" is based on the PHP extension, though excludes code some distributions have found unacceptable (see [[bugzilla:47431]]).\n{{Related|Config-fatal}}",
        "config-xcache": "Message indicates if this program is available",
        "config-apc": "Message indicates if this program is available",
index b39e042..d630136 100644 (file)
@@ -470,8 +470,6 @@ class Exif {
                                        $charset = "";
                                        break;
                        }
-                       // This could possibly check to see if iconv is really installed
-                       // or if we're using the compatibility wrapper in globalFunctions.php
                        if ( $charset ) {
                                wfSuppressWarnings();
                                $val = iconv( $charset, 'UTF-8//IGNORE', $val );
index 6be186f..454a97b 100644 (file)
@@ -430,9 +430,7 @@ class ZipDirectoryReader {
                                $year, $month, $day, $hour, $minute, $second );
 
                        // Convert the character set in the file name
-                       if ( !function_exists( 'iconv' )
-                               || $this->testBit( $data['general bits'], self::GENERAL_UTF8 )
-                       ) {
+                       if ( $this->testBit( $data['general bits'], self::GENERAL_UTF8 ) ) {
                                $name = $data['name'];
                        } else {
                                $name = iconv( 'CP437', 'UTF-8', $data['name'] );