}
/**
- * 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];
$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 ) {
'</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' ) .