Installer: remove dependency on JSON extension
authorKevin Israel <pleasestand@live.com>
Mon, 30 Sep 2013 17:36:59 +0000 (13:36 -0400)
committerKevin Israel <pleasestand@live.com>
Mon, 30 Sep 2013 17:59:42 +0000 (13:59 -0400)
* Remove one of the two uses of Xml::encodeJsVar(): to encode an
  unused JS variable dbTypes. The remaining use is only after
  installation is complete.
* Add an environmental check to ensure the JSON functions are
  available before attempting installation.

Bug: 54774
Change-Id: Ifb8859026b853ef3f328b796945a973c4add7eeb

includes/installer/Installer.i18n.php
includes/installer/Installer.php
includes/installer/WebInstallerOutput.php

index 190ecba..1d5bb28 100644 (file)
@@ -134,6 +134,10 @@ MediaWiki requires UTF-8 support to function correctly.",
 This is probably too low.
 The installation may fail!",
        'config-ctype'                    => "'''Fatal:''' PHP must be compiled with support for the [http://www.php.net/manual/en/ctype.installation.php Ctype extension].",
+       'config-json'                     => "'''Fatal:''' PHP was compiled without JSON support.
+You must install either the PHP JSON extension or the [http://pecl.php.net/package/jsonc PECL jsonc] extension before installing MediaWiki.
+* The PHP extension is included in Red Hat Enterprise Linux (CentOS) 5 and 6, though must be enabled in <code>/etc/php.ini</code> or <code>/etc/php.d/json.ini</code>.
+* Some Linux distributions released after May 2013 omit the PHP extension, instead packaging the PECL extension as <code>php5-json</code> or <code>php-pecl-jsonc</code>.",
        'config-xcache'                   => '[http://xcache.lighttpd.net/ XCache] is installed',
        'config-apc'                      => '[http://www.php.net/apc APC] is installed',
        'config-wincache'                 => '[http://www.iis.net/download/WinCacheForPhp WinCache] is installed',
@@ -656,6 +660,10 @@ Parameters:
        'config-memory-bad' => 'Parameters:
 * $1 is the configured <code>memory_limit</code>.',
        'config-ctype' => 'Message if support for [http://www.php.net/manual/en/ctype.installation.php Ctype] is missing from PHP',
+       'config-json' => 'Message if support for [[wikipedia:JSON|JSON]] is missing from PHP.
+* "[[wikipedia:Red Hat Enterprise Linux|Red Hat Enterprise Linux]]" (RHEL) and "[[wikipedia:CentOS|CentOS]]" refer to two almost-identical Linux distributions. "5 and 6" refers to version 5 or 6 of either distribution. Because RHEL 7 likely will not include the PHP extension, do not translate as "5 or newer".
+* "The [http://www.php.net/json PHP extension]" is the JSON extension included with PHP 5.2 and newer.
+* "The [http://pecl.php.net/package/jsonc PECL extension]" is based on the PHP extension, though excludes code some distributions have found unacceptable (see [[bugzilla:47431]]).',
        'config-xcache' => 'Message indicates if this program is available',
        'config-apc' => 'Message indicates if this program is available',
        'config-wincache' => 'Message indicates if this program is available',
index afd2e3d..1044f18 100644 (file)
@@ -131,6 +131,7 @@ abstract class Installer {
                'envCheckLibicu',
                'envCheckSuhosinMaxValueLength',
                'envCheckCtype',
+               'envCheckJSON',
        );
 
        /**
@@ -1181,6 +1182,17 @@ abstract class Installer {
                return true;
        }
 
+       /**
+        * @return bool
+        */
+       protected function envCheckJSON() {
+               if ( !function_exists( 'json_decode' ) ) {
+                       $this->showError( 'config-json' );
+                       return false;
+               }
+               return true;
+       }
+
        /**
         * Get an array of likely places we can find executables. Check a bunch
         * of known Unix-like defaults, as well as the PATH environment variable
index 3e65eae..77e9a2c 100644 (file)
@@ -239,7 +239,6 @@ class WebInstallerOutput {
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <title><?php $this->outputTitle(); ?></title>
        <?php echo $this->getCssUrl() . "\n"; ?>
-       <?php echo Html::inlineScript( "var dbTypes = " . Xml::encodeJsVar( $dbTypes ) ) . "\n"; ?>
        <?php echo $this->getJQuery() . "\n"; ?>
        <?php echo Html::linkedScript( '../skins/common/config.js' ) . "\n"; ?>
 </head>