From a80cfe3425eaf7aca7d73a1041de21bdb558e266 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Wed, 27 Apr 2011 18:22:01 +0000 Subject: [PATCH] Bug 28039 - Boldface all fatals. Moved showError() from WebInstaller to base class, added its call to all env checks wherever appropriate. Also fixed a fatal in CLI installer when no DB drivers are present. --- includes/installer/CliInstaller.php | 25 +++++++++++++++++++++---- includes/installer/Installer.php | 27 ++++++++++++++++----------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php index 710823aae7..0a9993770c 100644 --- a/includes/installer/CliInstaller.php +++ b/includes/installer/CliInstaller.php @@ -121,14 +121,31 @@ class CliInstaller extends Installer { } public function showMessage( $msg /*, ... */ ) { - $params = func_get_args(); - array_shift( $params ); + echo $this->getMessageText( func_get_args() ) . "\n"; + flush(); + } + + public function showError( $msg /*, ... */ ) { + echo "***{$this->getMessageText( func_get_args() )}***\n"; + flush(); + } + + /** + * @return string + */ + protected function getMessageText( $params ) { + $msg = array_shift( $params ); $text = wfMsgExt( $msg, array( 'parseinline' ), $params ); $text = preg_replace( '/(.*?)<\/a>/', '$2 <$1>', $text ); - echo html_entity_decode( strip_tags( $text ), ENT_QUOTES ) . "\n"; - flush(); + return html_entity_decode( strip_tags( $text ), ENT_QUOTES ); + } + + /** + * Dummy + */ + public function showHelpBox( $msg /*, ... */ ) { } public function showStatusMessage( Status $status ) { diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 4c488832ca..dc9767e25e 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -295,6 +295,11 @@ abstract class Installer { */ public abstract function showMessage( $msg /*, ... */ ); + /** + * Same as showMessage(), but for displaying errors + */ + public abstract function showError( $msg /*, ... */ ); + /** * Show a message to the installing user by using a Status object * @param $status Status @@ -617,7 +622,7 @@ abstract class Installer { $this->setVar( '_CompiledDBs', $compiledDBs ); if ( !$compiledDBs ) { - $this->showMessage( 'config-no-db' ); + $this->showError( 'config-no-db' ); // FIXME: this only works for the web installer! $this->showHelpBox( 'config-no-db-help', $wgLang->commaList( $allNames ) ); return false; @@ -647,7 +652,7 @@ abstract class Installer { protected function envCheckBrokenXML() { $test = new PhpXmlBugTester(); if ( !$test->ok ) { - $this->showMessage( 'config-brokenlibxml' ); + $this->showError( 'config-brokenlibxml' ); return false; } } @@ -660,7 +665,7 @@ abstract class Installer { $test = new PhpRefCallBugTester; $test->execute(); if ( !$test->ok ) { - $this->showMessage( 'config-using531', phpversion() ); + $this->showError( 'config-using531', phpversion() ); return false; } } @@ -670,7 +675,7 @@ abstract class Installer { */ protected function envCheckMagicQuotes() { if( wfIniGetBool( "magic_quotes_runtime" ) ) { - $this->showMessage( 'config-magic-quotes-runtime' ); + $this->showError( 'config-magic-quotes-runtime' ); return false; } } @@ -680,7 +685,7 @@ abstract class Installer { */ protected function envCheckMagicSybase() { if ( wfIniGetBool( 'magic_quotes_sybase' ) ) { - $this->showMessage( 'config-magic-quotes-sybase' ); + $this->showError( 'config-magic-quotes-sybase' ); return false; } } @@ -690,7 +695,7 @@ abstract class Installer { */ protected function envCheckMbstring() { if ( wfIniGetBool( 'mbstring.func_overload' ) ) { - $this->showMessage( 'config-mbstring' ); + $this->showError( 'config-mbstring' ); return false; } } @@ -700,7 +705,7 @@ abstract class Installer { */ protected function envCheckZE1() { if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) { - $this->showMessage( 'config-ze1' ); + $this->showError( 'config-ze1' ); return false; } } @@ -720,7 +725,7 @@ abstract class Installer { */ protected function envCheckXML() { if ( !function_exists( "utf8_encode" ) ) { - $this->showMessage( 'config-xml-bad' ); + $this->showError( 'config-xml-bad' ); return false; } } @@ -730,14 +735,14 @@ abstract class Installer { */ protected function envCheckPCRE() { if ( !function_exists( 'preg_match' ) ) { - $this->showMessage( 'config-pcre' ); + $this->showError( 'config-pcre' ); return false; } wfSuppressWarnings(); $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' ); wfRestoreWarnings(); if ( $regexd != '--' ) { - $this->showMessage( 'config-pcre-no-utf8' ); + $this->showError( 'config-pcre-no-utf8' ); return false; } } @@ -843,7 +848,7 @@ abstract class Installer { // Some kind soul has set it for us already (e.g. debconf) return true; } else { - $this->showMessage( 'config-no-uri' ); + $this->showError( 'config-no-uri' ); return false; } -- 2.20.1