fix a problem by not inserting __MWTEMPLATESECTION for section titles that don't...
[lhc/web/wiklou.git] / install-utils.inc
index 8d1734e..1fb2cc8 100644 (file)
@@ -1,6 +1,10 @@
 <?php
 
 function install_version_checks() {
+       # We dare not turn output buffer _off_ since this will break completely
+       # if PHP is globally configured to run through a gzip filter.
+       @ob_implicit_flush( true );
+       
        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" );
@@ -8,9 +12,6 @@ function install_version_checks() {
        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')) {
@@ -55,14 +56,18 @@ function copydirectory( $source, $dest ) {
        }
 }
 
-function readconsole() {
-       $fp = fopen( "php://stdin", "r" );
-       $resp = trim( fgets( $fp, 1024 ) );
-       fclose( $fp );
-       return $resp;
+function readconsole( $prompt = "" ) {
+       if ( function_exists( "readline" ) ) {
+               return readline( $prompt );
+       } else {
+               print $prompt;
+               $fp = fopen( "php://stdin", "r" );
+               $resp = trim( fgets( $fp, 1024 ) );
+               fclose( $fp );
+               return $resp;
+       }
 }
 
-
 function replacevars( $ins ) {
        $varnames = array(
                "wgDBserver", "wgDBname", "wgDBintlname", "wgDBuser",
@@ -113,7 +118,8 @@ function dbsource( $fname, $database = false ) {
                                $res = mysql_query( $cmd );
 
                        if ( false === $res ) {
-                               print "Query \"{$cmd}\" failed.\n";
+                               $err = mysql_error();
+                               print "Query \"{$cmd}\" failed with error code \"$err\".\n";
                                exit();
                        }
 
@@ -127,10 +133,11 @@ function dbsource( $fname, $database = false ) {
 # Obsolete, use Database::fieldExists()
 function field_exists( $table, $field ) {
        $fname = "Update script: field_exists";
-       $res = wfQuery( "DESCRIBE $table", $fname );
+       $db =& wfGetDB( DB_SLAVE );
+       $res = $db->query( "DESCRIBE $table", $fname );
        $found = false;
        
-       while ( $row = wfFetchObject( $res ) ) {
+       while ( $row = $db->fetchObject( $res ) ) {
                if ( $row->Field == $field ) {
                        $found = true;
                        break;