jenkins-bot has submitted this change and it was merged.

Change subject: Remove Fallback::iconv()
......................................................................


Remove Fallback::iconv()

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
---
M RELEASE-NOTES-1.24
M includes/Fallback.php
M includes/GlobalFunctions.php
M includes/installer/Installer.php
M includes/installer/i18n/en.json
M includes/installer/i18n/qqq.json
M includes/media/Exif.php
M includes/utils/ZipDirectoryReader.php
8 files changed, 20 insertions(+), 37 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  Siebrand: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24
index d76cd29..c66758f 100644
--- a/RELEASE-NOTES-1.24
+++ b/RELEASE-NOTES-1.24
@@ -12,6 +12,9 @@
 * 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,
diff --git a/includes/Fallback.php b/includes/Fallback.php
index e38bdf1..c4b22f5 100644
--- a/includes/Fallback.php
+++ b/includes/Fallback.php
@@ -26,28 +26,6 @@
 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
         * for relatively small offset and count values -- about 5x slower
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index feca005..b41ec9f 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -35,16 +35,6 @@
  * 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
diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php
index 7c67ee8..cdc8266 100644
--- a/includes/installer/Installer.php
+++ b/includes/installer/Installer.php
@@ -137,6 +137,7 @@
                'envCheckLibicu',
                'envCheckSuhosinMaxValueLength',
                'envCheckCtype',
+               'envCheckIconv',
                'envCheckJSON',
        );
 
@@ -1209,6 +1210,19 @@
        /**
         * @return bool
         */
+       protected function envCheckIconv() {
+               if ( !function_exists( 'iconv' ) ) {
+                       $this->showError( 'config-iconv' );
+
+                       return false;
+               }
+
+               return true;
+       }
+
+       /**
+        * @return bool
+        */
        protected function envCheckJSON() {
                if ( !function_exists( 'json_decode' ) ) {
                        $this->showError( 'config-json' );
diff --git a/includes/installer/i18n/en.json b/includes/installer/i18n/en.json
index b6606a6..f25c562 100644
--- a/includes/installer/i18n/en.json
+++ b/includes/installer/i18n/en.json
@@ -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",
diff --git a/includes/installer/i18n/qqq.json b/includes/installer/i18n/qqq.json
index d0a37a7..6ec724f 100644
--- a/includes/installer/i18n/qqq.json
+++ b/includes/installer/i18n/qqq.json
@@ -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",
diff --git a/includes/media/Exif.php b/includes/media/Exif.php
index b39e042..d630136 100644
--- a/includes/media/Exif.php
+++ b/includes/media/Exif.php
@@ -470,8 +470,6 @@
                                        $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 );
diff --git a/includes/utils/ZipDirectoryReader.php 
b/includes/utils/ZipDirectoryReader.php
index 6be186f..454a97b 100644
--- a/includes/utils/ZipDirectoryReader.php
+++ b/includes/utils/ZipDirectoryReader.php
@@ -430,9 +430,7 @@
                                $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'] 
);

-- 
To view, visit https://gerrit.wikimedia.org/r/148012
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie1112a5742646a0e1f951e188480c23851859320
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MarkAHershberger <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to