MDL-28412 detect broken iconv
authorPetr Skoda <commits@skodak.org>
Sat, 6 Aug 2011 19:11:55 +0000 (21:11 +0200)
committerPetr Skoda <commits@skodak.org>
Sat, 6 Aug 2011 21:04:31 +0000 (23:04 +0200)
admin/index.php
install.php

index 70b47dd..b8138cf 100644 (file)
@@ -38,6 +38,18 @@ if (version_compare(phpversion(), '5.3.2') < 0) {
     die;
 }
 
+// make sure iconv is available and actually works
+if (!function_exists('iconv')) {
+    // this should not happen, this must be very borked install
+    echo 'Moodle requires iconv PHP extension. Please install or enabled iconv extension.';
+    die();
+}
+if (iconv('UTF-8', 'UTF-8//IGNORE', 'abc') !== 'abc') {
+    // known to be broken in mid-2011 MAMP installations
+    echo 'Broken iconv PHP extension detected, installation/upgrade can not continue.';
+    die;
+}
+
 define('NO_OUTPUT_BUFFERING', true);
 
 require('../config.php');
index 03d8122..7fd3949 100644 (file)
@@ -67,6 +67,18 @@ if (version_compare(phpversion(), "5.2.0") < 0) {
     die;
 }
 
+// make sure iconv is available and actually works
+if (!function_exists('iconv')) {
+    // this should not happen, this must be very borked install
+    echo 'Moodle requires iconv PHP extension. Please install or enabled iconv extension.';
+    die();
+}
+if (iconv('UTF-8', 'UTF-8//IGNORE', 'abc') !== 'abc') {
+    // known to be broken in mid-2011 MAMP installations
+    echo 'Broken iconv PHP extension detected, installation can not continue.';
+    die;
+}
+
 if (PHP_INT_SIZE > 4) {
     // most probably 64bit PHP - we need a lot more memory
     $minrequiredmemory = '70M';