X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2Finstall-utils.inc;h=e37aeb9f7c819fe5e34d24dc9612f2b2c720d43f;hb=5cd45f79d1b9164e87040da8d9a204e19fa2938b;hp=bb2cac399977f25bee87d56297b55a47474a5ad4;hpb=8a09b9d26126bab29ccc4391a5ebb4de256522a5;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/install-utils.inc b/maintenance/install-utils.inc index bb2cac3999..e37aeb9f7c 100644 --- a/maintenance/install-utils.inc +++ b/maintenance/install-utils.inc @@ -12,30 +12,20 @@ function install_version_checks() { # if PHP is globally configured to run through a gzip filter. @ob_implicit_flush( true ); - if( !function_exists( 'version_compare' ) ) { + if ( !function_exists( 'version_compare' ) ) { # version_compare was introduced in 4.1.0 - echo "Your PHP version is much too old; 4.0.x will _not_ work. 5.0.0 or higher is required. ABORTING.\n"; + echo "Your PHP version is much too old; 4.0.x will _not_ work. 5.1.0 or higher is required. ABORTING.\n"; die( 1 ); } - if( version_compare( phpversion(), '5.0.0' ) < 0 ) { - echo "PHP 5.0.0 or higher is required. If PHP 5 is available only when \n". - "PHP files have a .php5 extension, please navigate to index.php5 \n". + if ( version_compare( phpversion(), '5.1.0' ) < 0 ) { + echo "PHP 5.1.0 or higher is required. If PHP 5 is available only when \n" . + "PHP files have a .php5 extension, please navigate to index.php5 \n" . "to continue installation. ABORTING.\n"; die( 1 ); } - // Test for PHP bug which breaks PHP 5.0.x on 64-bit... - // As of 1.8 this breaks lots of common operations instead - // of just some rare ones like export. - $borked = str_replace( 'a', 'b', array( -1 => -1 ) ); - if( !isset( $borked[-1] ) ) { - echo "PHP 5.0.x is buggy on your 64-bit system; you must upgrade to PHP 5.1.x\n" . - "or higher. ABORTING. (http://bugs.php.net/bug.php?id=34879 for details)\n"; - die( 1 ); - } - $test = new PhpXmlBugTester(); - if( !$test->ok ) { + if ( !$test->ok ) { echo "Your system has a combination of PHP and libxml2 versions which is buggy\n" . "and can cause hidden data corruption in MediaWiki and other web apps.\n" . "Upgrade to PHP 5.2.9 or later and libxml2 2.7.3 or later!\n" . @@ -73,10 +63,10 @@ class PhpXmlBugTester { $parser = xml_parser_create(); xml_set_character_data_handler( $parser, array( $this, 'chardata' ) ); - $parsedOk = xml_parse($parser, $xml, true); - $this->ok = $parsedOk && ($this->parsedData == $charData); + $parsedOk = xml_parse( $parser, $xml, true ); + $this->ok = $parsedOk && ( $this->parsedData == $charData ); } - public function chardata($parser, $data) { + public function chardata( $parser, $data ) { $this->parsedData .= $data; } } @@ -105,10 +95,18 @@ class PhpRefCallBugTester { } } +if ( !function_exists( 'posix_isatty' ) ) { + # We default as considering stdin a tty (for nice readline methods) + # but treating stout as not a tty to avoid color codes + function posix_isatty( $fd ) { + return !$fd; + } +} + function readconsole( $prompt = '' ) { static $isatty = null; if ( is_null( $isatty ) ) { - if ( !function_exists( 'posix_isatty' ) || posix_isatty( 0 /*STDIN*/ ) ) { + if ( posix_isatty( 0 /*STDIN*/ ) ) { $isatty = true; } else { $isatty = false; @@ -124,10 +122,10 @@ function readconsole( $prompt = '' ) { if ( feof( STDIN ) ) { $st = false; } else { - $st = fgets(STDIN, 1024); + $st = fgets( STDIN, 1024 ); } } - if ($st === false) return false; + if ( $st === false ) return false; $resp = trim( $st ); return $resp; } @@ -135,10 +133,10 @@ function readconsole( $prompt = '' ) { function findExecutable( $name ) { $paths = explode( PATH_SEPARATOR, getenv( "PATH" ) ); - foreach( $paths as $path ) { + foreach ( $paths as $path ) { $full = $path . DIRECTORY_SEPARATOR . $name; - if( file_exists( $full ) ) { - if( wfIsWindows() || is_executable( $full ) ) { + if ( file_exists( $full ) ) { + if ( wfIsWindows() || is_executable( $full ) ) { return $full; } } @@ -148,16 +146,16 @@ function findExecutable( $name ) { function readlineEmulation( $prompt ) { $bash = "bash"; - if( !wfIsWindows() && findExecutable( $bash ) ) { + if ( !wfIsWindows() && findExecutable( $bash ) ) { $retval = false; $encPrompt = wfEscapeShellArg( $prompt ); $command = "read -er -p $encPrompt && echo \"\$REPLY\""; $encCommand = wfEscapeShellArg( $command ); $line = wfShellExec( "$bash -c $encCommand", $retval ); - if( $retval == 0 ) { + if ( $retval == 0 ) { return $line; - } elseif( $retval == 127 ) { + } elseif ( $retval == 127 ) { // Couldn't execute bash even though we thought we saw it. // Shell probably spit out an error message, sorry :( // Fall through to fgets()... @@ -172,7 +170,7 @@ function readlineEmulation( $prompt ) { return false; } print $prompt; - return fgets(STDIN, 1024); + return fgets( STDIN, 1024 ); } @@ -182,22 +180,20 @@ function readlineEmulation( $prompt ) { function dbsource( $fname, $db = false ) { wfDeprecated( __METHOD__ ); if ( !$db ) { - // Try $wgDatabase, which is used in the install and update scripts - global $wgDatabase; - if ( isset( $wgDatabase ) ) { - $db = $wgDatabase; - } else { - // No? Well, we must be outside of those scripts, so use the standard method - $db = wfGetDB( DB_MASTER ); - } + $db = wfGetDB( DB_MASTER ); } $error = $db->sourceFile( $fname ); if ( $error !== true ) { print $error; - exit(1); + exit( 1 ); } } +function archive( $name ) { + wfDeprecated( __METHOD__ ); + return DatabaseBase::patchPath( $name ); +} + /** * Get the value of session.save_path *