installer: Don't generate $wgDefaultSkin='' when no skins are present during installation
authorBartosz Dziewoński <matma.rex@gmail.com>
Sat, 10 Jan 2015 02:55:38 +0000 (03:55 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 13 Jan 2015 22:47:24 +0000 (22:47 +0000)
The bug only affects people installing from Git, not tarball releases.

* Make sure getDefaultSkin() never returns null and just uses 'vector'
  when no skins are available (so the user just has to install it).
* Produce a hidden input field to pass the generated value to the next
  installer page.

Change-Id: I025f1aeb182a818de59a42df01591e01fc9e6236

includes/installer/Installer.php
includes/installer/WebInstallerPage.php

index 4159c1d..f2e417d 100644 (file)
@@ -1469,15 +1469,16 @@ abstract class Installer {
        }
 
        /**
-        * Returns a default value to be used for $wgDefaultSkin: the preferred skin, if available among
-        * the installed skins, or any other one otherwise.
+        * Returns a default value to be used for $wgDefaultSkin: normally the one set in DefaultSettings,
+        * but will fall back to another if the default skin is missing and some other one is present
+        * instead.
         *
         * @param string[] $skinNames Names of installed skins.
         * @return string
         */
        public function getDefaultSkin( array $skinNames ) {
                $defaultSkin = $GLOBALS['wgDefaultSkin'];
-               if ( in_array( $defaultSkin, $skinNames ) ) {
+               if ( !$skinNames || in_array( $defaultSkin, $skinNames ) ) {
                        return $defaultSkin;
                } else {
                        return $skinNames[0];
index 9ecb24b..038c2be 100644 (file)
@@ -1033,14 +1033,15 @@ class WebInstallerOptions extends WebInstallerPage {
                $skins = $this->parent->findExtensions( 'skins' );
                $skinHtml = $this->getFieldSetStart( 'config-skins' );
 
-               if ( $skins ) {
-                       $skinNames = array_map( 'strtolower', $skins );
+               $skinNames = array_map( 'strtolower', $skins );
+               $chosenSkinName = $this->getVar( 'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) );
 
+               if ( $skins ) {
                        $radioButtons = $this->parent->getRadioElements( array(
                                'var' => 'wgDefaultSkin',
                                'itemLabels' => array_fill_keys( $skinNames, 'config-skins-use-as-default' ),
                                'values' => $skinNames,
-                               'value' => $this->getVar( 'wgDefaultSkin', $this->parent->getDefaultSkin( $skinNames ) ),
+                               'value' => $chosenSkinName,
                        ) );
 
                        foreach ( $skins as $skin ) {
@@ -1055,7 +1056,9 @@ class WebInstallerOptions extends WebInstallerPage {
                                        '</div>';
                        }
                } else {
-                       $skinHtml .= $this->parent->getWarningBox( wfMessage( 'config-skins-missing' )->plain() );
+                       $skinHtml .=
+                               $this->parent->getWarningBox( wfMessage( 'config-skins-missing' )->plain() ) .
+                               Html::hidden( 'config_wgDefaultSkin', $chosenSkinName );
                }
 
                $skinHtml .= $this->parent->getHelpBox( 'config-skins-help' ) .