<?php
function install_version_checks() {
+ # Turn off output buffering if it's on
+ @ob_end_flush();
+
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" );
}
}
-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",
$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();
}
# 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;