* Cripple the old installer (entry point is gone, supporting code immediately exits). Keeping the latter for reference still :)
* Move posix_isatty() wrapper to Maintenance.php, all CLI scripts include this
* Clarify docs on archive() deprecation and removal - hasn't been used going back thru 1.15
* Clarify docs on dbsource() deprecation and removal - was in wide use thru 1.15. 1.16 removed all extension usages
* Move the two PHP bug tests to a file with the other installer files, moved them to more logical places in new install/update sequence
* Remove mw_have_dl/mw_get_session_save_path, zero callers
* Move readconsole() and helpers to be a static method on Maintenance, no extensions have used it since 1.15 either
<?php
/**
- * MediaWiki web-based config/installation
- *
- * Copyright © 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.com>
- * http://www.mediawiki.org/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
+ * DO NOT USE ANY OF THIS CODE. BEING RETAINED FOR REFERENCE UNTIL JUST BEFORE
+ * THE 1.17 BRANCH
*
* @file
*/
-if( !defined( 'MEDIAWIKI_INSTALL' ) ) {
- die( 'Not an entry point.' );
-}
+die( 'Now nearly 100% obsolete!' );
error_reporting( E_ALL | E_STRICT );
header( "Content-type: text/html; charset=utf-8" );
+++ /dev/null
-<?php
-/**
- * MediaWiki web-based config/installation
- *
- * Copyright © 2004 Brion Vibber <brion@pobox.com>, 2006 Rob Church <robchur@gmail.com>
- * http://www.mediawiki.org/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-# Attempt to set up the include path, to fix problems with relative includes
-$IP = dirname( dirname( __FILE__ ) );
-define( 'MW_INSTALL_PATH', $IP );
-
-# Define an entry point and include some files
-define( "MEDIAWIKI", true );
-define( "MEDIAWIKI_INSTALL", true );
-
-# Check for PHP 5
-if ( !function_exists( 'version_compare' )
- || version_compare( phpversion(), '5.0.0' ) < 0
-) {
- define( 'MW_PHP4', '1' );
- require( "$IP/includes/DefaultSettings.php" );
- require( "$IP/includes/templates/PHP4.php" );
- exit;
-}
-
-// Isolate the rest of the code so this file can die out cleanly
-// if we find we're running under PHP 4.x... We use PHP 5 syntax
-// which doesn't parse under 4.
-require( dirname( __FILE__ ) . "/Installer.php" );
'WebInstallerOutput' => 'includes/installer/WebInstallerOutput.php',
'MysqlInstaller' => 'includes/installer/MysqlInstaller.php',
'MysqlUpdater' => 'includes/installer/MysqlUpdater.php',
+ 'PhpXmlBugTester' => 'includes/installer/PhpBugTests.php',
+ 'PhpRefCallBugTester' => 'includes/installer/PhpBugTests.php',
'PostgresInstaller' => 'includes/installer/PostgresInstaller.php',
'PostgresUpdater' => 'includes/installer/PostgresUpdater.php',
'SqliteInstaller' => 'includes/installer/SqliteInstaller.php',
'config-uploads-safe' => 'The default directory for uploads is safe from arbitrary scripts execution.',
'config-uploads-not-safe' => "'''Warning:''' Your default directory for uploads <code>$1</code> is vulnerable to arbitrary scripts execution.
Although MediaWiki checks all uploaded files for security threats, it is highly recommended to [http://www.mediawiki.org/wiki/Manual:Security#Upload_security close this security vulnerability] before enabling uploads.",
+ 'config-brokenlibxml' => 'Your system has a combination of PHP and libxml2 versions which is buggy and can cause hidden data corruption in MediaWiki and other web apps.
+Upgrade to PHP 5.2.9 or later and libxml2 2.7.3 or later! ABORTING ([http://bugs.php.net/bug.php?id=45996 bug filed with PHP]).',
+ 'config-using531' => 'PHP $1 is not compatible with MediaWiki due to a bug involving reference parameters to <code>__call()</code>.
+Upgrade to PHP 5.3.2 or higher, or downgrade to PHP 5.3.0 to fix this. ABORTING ([http://bugs.php.net/bug.php?id=50394 bug filed with PHP])',
'config-db-type' => 'Database type:',
'config-db-host' => 'Database host:',
'config-db-host-help' => 'If your database server is on different server, enter the host name or IP address here.
'envCheckMediaWikiVersion',
'envCheckDB',
'envCheckRegisterGlobals',
+ 'envCheckBrokenXML',
+ 'envCheckPHP531',
'envCheckMagicQuotes',
'envCheckMagicSybase',
'envCheckMbstring',
}
}
+ /**
+ * Some versions of libxml+PHP break < and > encoding horribly
+ */
+ public function envCheckBrokenXML() {
+ $test = new PhpXmlBugTester();
+ if ( !$test->ok ) {
+ $this->showMessage( 'config-brokenlibxml' );
+ return false;
+ }
+ }
+
+ /**
+ * Test PHP (probably 5.3.1, but it could regress again) to make sure that
+ * reference parameters to __call() are not converted to null
+ */
+ public function envCheckPHP531() {
+ $test = new PhpRefCallBugTester;
+ $test->execute();
+ if ( !$test->ok ) {
+ $this->showMessage( 'config-using531' );
+ return false;
+ }
+ }
+
/**
* Environment check for magic_quotes_runtime.
*/
*
* @return Array
*/
- protected function getPossibleBinPaths() {
+ protected static function getPossibleBinPaths() {
return array_merge(
array( '/usr/bin', '/usr/local/bin', '/opt/csw/bin',
'/usr/gnu/bin', '/usr/sfw/bin', '/sw/bin', '/opt/local/bin' ),
* If $versionInfo is not false, only executables with a version
* matching $versionInfo[1] will be returned.
*/
- protected function locateExecutable( $path, $names, $versionInfo = false ) {
+ public static function locateExecutable( $path, $names, $versionInfo = false ) {
if ( !is_array( $names ) ) {
$names = array( $names );
}
* Same as locateExecutable(), but checks in getPossibleBinPaths() by default
* @see locateExecutable()
*/
- protected function locateExecutableInDefaultPaths( $names, $versionInfo = false ) {
- foreach( $this->getPossibleBinPaths() as $path ) {
- $exe = $this->locateExecutable( $path, $names, $versionInfo );
+ public static function locateExecutableInDefaultPaths( $names, $versionInfo = false ) {
+ foreach( self::getPossibleBinPaths() as $path ) {
+ $exe = self::locateExecutable( $path, $names, $versionInfo );
if( $exe !== false ) {
return $exe;
}
--- /dev/null
+<?php
+/**
+ * Classes for self-contained tests for known bugs in PHP.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
+ */
+
+/**
+ * Test for PHP+libxml2 bug which breaks XML input subtly with certain versions.
+ * Known fixed with PHP 5.2.9 + libxml2-2.7.3
+ * @see http://bugs.php.net/bug.php?id=45996
+ */
+class PhpXmlBugTester {
+ private $parsedData = '';
+ public $ok = false;
+ public function __construct() {
+ $charData = '<b>c</b>';
+ $xml = '<a>' . htmlspecialchars( $charData ) . '</a>';
+
+ $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 );
+ }
+ public function chardata( $parser, $data ) {
+ $this->parsedData .= $data;
+ }
+}
+
+/**
+ * Test for PHP bug #50394 (PHP 5.3.x conversion to null only, not 5.2.x)
+ * @see http://bugs.php.net/bug.php?id=45996
+ */
+class PhpRefCallBugTester {
+ public $ok = false;
+
+ function __call( $name, $args ) {
+ $old = error_reporting( E_ALL & ~E_WARNING );
+ call_user_func_array( array( $this, 'checkForBrokenRef' ), $args );
+ error_reporting( $old );
+ }
+
+ function checkForBrokenRef( &$var ) {
+ if ( $var ) {
+ $this->ok = true;
+ }
+ }
+
+ function execute() {
+ $var = true;
+ call_user_func_array( array( $this, 'foo' ), array( &$var ) );
+ }
+}
"administrator.\n" );
}
+// Wrapper for posix_isatty()
+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;
+ }
+}
+
/**
* Abstract maintenance class for quickly writing and churning out
* maintenance scripts with minimal effort. All that _must_ be defined
return $title;
}
+ /**
+ * Prompt the console for input
+ * @param $prompt String what to begin the line with, like '> '
+ * @return String response
+ */
+ public static function readconsole( $prompt = '> ' ) {
+ static $isatty = null;
+ if ( is_null( $isatty ) ) {
+ if ( posix_isatty( 0 /*STDIN*/ ) ) {
+ $isatty = true;
+ } else {
+ $isatty = false;
+ }
+ }
+
+ if ( $isatty && function_exists( 'readline' ) ) {
+ return readline( $prompt );
+ } else {
+ if ( $isatty ) {
+ $st = readlineEmulation( $prompt );
+ } else {
+ if ( feof( STDIN ) ) {
+ $st = false;
+ } else {
+ $st = fgets( STDIN, 1024 );
+ }
+ }
+ if ( $st === false ) return false;
+ $resp = trim( $st );
+ return $resp;
+ }
+ }
+
+ /**
+ * Emulate readline()
+ * @param $prompt String what to begin the line with, like '> '
+ * @return String
+ */
+ private static function readlineEmulation( $prompt ) {
+ $bash = array( 'bash' );
+ if ( !wfIsWindows() && Installer::locateExecutableInDefaultPaths( $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 ) {
+ return $line;
+ } 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()...
+ } else {
+ // EOF/ctrl+D
+ return false;
+ }
+ }
+
+ // Fallback... we'll have no editing controls, EWWW
+ if ( feof( STDIN ) ) {
+ return false;
+ }
+ print $prompt;
+ return fgets( STDIN, 1024 );
+ }
}
class FakeMaintenance extends Maintenance {
readline_read_history( $historyFile );
}
-while ( ( $line = readconsole( '> ' ) ) !== false ) {
+while ( ( $line = Maintenance::readconsole() ) !== false ) {
if ( $useReadline ) {
readline_add_history( $line );
readline_write_history( $historyFile );
<?php
-
/**
- * This file contains functions used by the install script (config/index.php)
- * and maintenance scripts. It is not loaded in normal web requests.
+ * This file contains ancient db-related functions that have been deprecated. Do
+ * not use them. Please find the appropriate replacements.
*
* @file
*/
-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
- 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.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 <a href=\"index.php5\">index.php5</a> \n" .
- "to continue installation. ABORTING.\n";
- die( 1 );
- }
-
- $test = new PhpXmlBugTester();
- 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" .
- "ABORTING (http://bugs.php.net/bug.php?id=45996 for details).\n";
- die( 1 );
- }
-
- $test = new PhpRefCallBugTester;
- $test->execute();
- if ( !$test->ok ) {
- echo "PHP 5.3.1 is not compatible with MediaWiki due to a bug involving\n" .
- "reference parameters to __call. Upgrade to PHP 5.3.2 or higher, or \n" .
- "downgrade to PHP 5.3.0 to fix this.\n" .
- "ABORTING (see http://bugs.php.net/bug.php?id=50394 for details)\n";
- die( 1 );
- }
-
- global $wgCommandLineMode;
- $wgCommandLineMode = true;
- umask( 000 );
- @set_time_limit( 0 );
-}
-
/**
- * Test for PHP+libxml2 bug which breaks XML input subtly with certain versions.
- * http://bugs.php.net/bug.php?id=45996
- * Known fixed with PHP 5.2.9 + libxml2-2.7.3
+ * @deprecated Use DatabaseBase::sourceFile(). Will probably be removed in 1.19
*/
-class PhpXmlBugTester {
- private $parsedData = '';
- public $ok = false;
- public function __construct() {
- $charData = '<b>c</b>';
- $xml = '<a>' . htmlspecialchars( $charData ) . '</a>';
-
- $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 );
- }
- public function chardata( $parser, $data ) {
- $this->parsedData .= $data;
- }
-}
-
-/**
- * Test for PHP bug #50394 (PHP 5.3.x conversion to null only, not 5.2.x)
- */
-class PhpRefCallBugTester {
- public $ok = false;
-
- function __call( $name, $args ) {
- $old = error_reporting( E_ALL & ~E_WARNING );
- call_user_func_array( array( $this, 'checkForBrokenRef' ), $args );
- error_reporting( $old );
- }
-
- function checkForBrokenRef( &$var ) {
- if ( $var ) {
- $this->ok = true;
- }
- }
-
- function execute() {
- $var = true;
- call_user_func_array( array( $this, 'foo' ), array( &$var ) );
- }
-}
-
-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 ( posix_isatty( 0 /*STDIN*/ ) ) {
- $isatty = true;
- } else {
- $isatty = false;
- }
- }
-
- if ( $isatty && function_exists( 'readline' ) ) {
- return readline( $prompt );
- } else {
- if ( $isatty ) {
- $st = readlineEmulation( $prompt );
- } else {
- if ( feof( STDIN ) ) {
- $st = false;
- } else {
- $st = fgets( STDIN, 1024 );
- }
- }
- if ( $st === false ) return false;
- $resp = trim( $st );
- return $resp;
- }
-}
-
-function findExecutable( $name ) {
- $paths = explode( PATH_SEPARATOR, getenv( "PATH" ) );
- foreach ( $paths as $path ) {
- $full = $path . DIRECTORY_SEPARATOR . $name;
- if ( file_exists( $full ) ) {
- if ( wfIsWindows() || is_executable( $full ) ) {
- return $full;
- }
- }
- }
- return false;
-}
-
-function readlineEmulation( $prompt ) {
- $bash = "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 ) {
- return $line;
- } 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()...
- } else {
- // EOF/ctrl+D
- return false;
- }
- }
-
- // Fallback... we'll have no editing controls, EWWW
- if ( feof( STDIN ) ) {
- return false;
- }
- print $prompt;
- return fgets( STDIN, 1024 );
-}
-
-
-#
-# Read and execute SQL commands from a file
-#
function dbsource( $fname, $db = false ) {
wfDeprecated( __METHOD__ );
if ( !$db ) {
}
}
+/**
+ * @deprecated Use DatabaseBase::patchPath(). Will probably be removed in 1.18
+ */
function archive( $name ) {
wfDeprecated( __METHOD__ );
$dbr = wfGetDB( DB_SLAVE );
return $dbr->patchPath( $name );
}
-
-/**
- * Get the value of session.save_path
- *
- * Per http://www.php.net/manual/en/ref.session.php#ini.session.save-path,
- * this might have some additional preceding parts which need to be
- * ditched
- *
- * @return string
- */
-function mw_get_session_save_path() {
- $path = ini_get( 'session.save_path' );
- $path = substr( $path, strrpos( $path, ';' ) );
- return $path;
-}
-
-/**
- * Is dl() available to us?
- *
- * According to http://www.php.net/manual/en/function.dl.php, dl()
- * is *not* available when `enable_dl` is off, or under `safe_mode`
- *
- * @return bool
- */
-function mw_have_dl() {
- return function_exists( 'dl' )
- && is_callable( 'dl' )
- && wfIniGetBool( 'enable_dl' )
- && !wfIniGetBool( 'safe_mode' );
-}
$showhelp = false;
$quit = false;
- $line = readconsole( '> ' );
+ $line = Maintenance::readconsole();
if ( $line === false ) exit;
$args = explode( ' ', $line );
return 2 /* Maintenance::DB_ADMIN */;
}
+ private function compatChecks() {
+ $test = new PhpXmlBugTester();
+ if ( !$test->ok ) {
+ $this->error(
+ "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" .
+ "ABORTING (see http://bugs.php.net/bug.php?id=45996).\n",
+ true );
+ }
+
+ $test = new PhpRefCallBugTester;
+ $test->execute();
+ if ( !$test->ok ) {
+ $ver = phpversion();
+ $this->error(
+ "PHP $ver is not compatible with MediaWiki due to a bug involving\n" .
+ "reference parameters to __call. Upgrade to PHP 5.3.2 or higher, or \n" .
+ "downgrade to PHP 5.3.0 to fix this.\n" .
+ "ABORTING (see http://bugs.php.net/bug.php?id=50394 for details)\n",
+ true );
+ }
+ }
+
function execute() {
global $wgVersion, $wgTitle, $wgLang;
$this->output( "MediaWiki {$wgVersion} Updater\n\n" );
if ( !$this->hasOption( 'skip-compat-checks' ) ) {
- install_version_checks();
+ $this->compatChecks();
} else {
$this->output( "Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n" );
wfCountdown( 5 );