PHP version check on install/update; remove 4.0.x compatibility functions, as we...
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 16 Nov 2003 14:30:39 +0000 (14:30 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 16 Nov 2003 14:30:39 +0000 (14:30 +0000)
includes/GlobalFunctions.php
install.php
update.php

index 22ae3ca..0d05f41 100644 (file)
@@ -10,22 +10,16 @@ include_once( "$IP/DatabaseFunctions.php" );
 include_once( "$IP/UpdateClasses.php" );
 include_once( "$IP/LogPage.php" );
 
-# PHP 4.1+ has array_key_exists, PHP 4.0.6 has key_exists instead, and earlier
-# versions of PHP have neither. So we roll our own. Note that this
-# function will return false even for keys that exist but whose associated 
-# value is NULL.
-#
-if ( phpversion() == "4.0.6" ) {
-       function array_key_exists( $k, $a ) {
-               return key_exists( $k, $a );
-       }
-} else if (phpversion() < "4.1") {
-       function array_key_exists( $k, $a ) {
-               return isset($a[$k]);
-       }
-}
+/*
+ * Compatibility functions
+ */
+
+# PHP <4.3.x is not actively supported; 4.1.x and 4.2.x might or might not work.
+# <4.1.x will not work, as we use a number of features introduced in 4.1.0
+# such as the new autoglobals.
 
 if( !function_exists('iconv') ) {
+       # iconv support is not in the default configuration and so may not be present.
        # Assume will only ever use utf-8 and iso-8859-1.
        # This will *not* work in all circumstances.
        function iconv( $from, $to, $string ) {
index 9791eb2..3ebccd5 100644 (file)
@@ -1,5 +1,16 @@
 <?
 
+if( !function_exists( "version_compare" ) ) {
+       # version_compare was introduced in 4.1.0
+       die( "Your PHP version is much too old; 4.0.x will _not_ work. 4.3.2 or higher is recommended. ABORTING.\n" );
+}
+if( version_compare( phpversion(), "4.3.2" ) < 0 ) {
+       echo "WARNING: PHP 4.3.2 or higher is recommended. Older versions from 4.1.x up may work but are not actively supported.\n\n";
+}
+if( !ini_get( "register_globals" ) ) {
+       echo "WARNING: register_globals is not on; MediaWiki currently relies on this option.\n\n";
+}
+
 if (!extension_loaded('mysql')) {
     if (!dl('mysql.so')) {
         print "Could not load MySQL driver! Please compile ".
index 5639d35..054c192 100644 (file)
@@ -1,5 +1,15 @@
 <?
 
+if( !function_exists( "version_compare" ) ) {
+       # version_compare was introduced in 4.1.0
+       die( "Your PHP version is much too old; 4.0.x will _not_ work. 4.3.2 or higher is recommended. ABORTING.\n" );
+}
+if( version_compare( phpversion(), "4.3.2" ) < 0 ) {
+       echo "WARNING: PHP 4.3.2 or higher is recommended. Older versions from 4.1.x up may work but are not actively supported.\n\n";
+}
+if( !ini_get( "register_globals" ) ) {
+       echo "WARNING: register_globals is not on; MediaWiki currently relies on this option.\n\n";
+}
 
 /*
 
@@ -134,7 +144,7 @@ function copydirectory( $source, $dest ) {
 
 function readconsole() {
        $fp = fopen( "php://stdin", "r" );
-       $resp = trim( fgets( $fp ) );
+       $resp = trim( fgets( $fp, 1024 ) );
        fclose( $fp );
        return $resp;
 }