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
* 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,
*/
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
* 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
'envCheckLibicu',
'envCheckSuhosinMaxValueLength',
'envCheckCtype',
+ 'envCheckIconv',
'envCheckJSON',
);
return true;
}
+ /**
+ * @return bool
+ */
+ protected function envCheckIconv() {
+ if ( !function_exists( 'iconv' ) ) {
+ $this->showError( 'config-iconv' );
+
+ return false;
+ }
+
+ return true;
+ }
+
/**
* @return bool
*/
"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",
"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",
$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 );
$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'] );