Skip to content

Commit

Permalink
Merge pull request #22 from OXIDprojects/keywan-ghadami-oxid-patch-2
Browse files Browse the repository at this point in the history
fix export module config
  • Loading branch information
keywan-ghadami-oxid authored Jan 14, 2019
2 parents 482113c + 5163a01 commit 4040be7
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions Core/ConfigExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ protected function withoutDefaults(&$aGroupedValues)
$aDefaultModuleSettings = is_null($oModule->getInfo("settings")) ? array() : $oModule->getInfo(
"settings"
);
$known = [];
foreach ($aDefaultModuleSettings as $aConfigValue) {
$sVarName = $aConfigValue['name'];
$known[$sVarName] = 1;
if (array_key_exists($sVarName, $aGeneralConfig)) {
//if a module safe a value twice once in module namespace and once in general namespace only export the value from the
//modulename space because it this happens only when the config table has some corrupted data
Expand All @@ -225,11 +227,7 @@ protected function withoutDefaults(&$aGroupedValues)


if ($sDefaultType == 'bool') {
if ($mDefaultValue === 'false') {
$mDefaultValue = '';
} else {
$mDefaultValue = $mDefaultValue ? '1' : '';
}
$mDefaultValue = $this->convertToBool($mDefaultValue);
}

if (! isset($aModuleConfig[$sVarName])) {
Expand All @@ -240,6 +238,10 @@ protected function withoutDefaults(&$aGroupedValues)
$mCurrentValue = $aModuleConfig[$sVarName];
}

if ($sDefaultType == 'bool') {
$mCurrentValue = $this->convertToBool($mCurrentValue);
}

if ($mCurrentValue === $mDefaultValue) {
unset($aModuleConfig[$sVarName]);
}
Expand Down Expand Up @@ -660,4 +662,18 @@ private function varValueWithThemeDisplayInfo($sVarName, $mVarValue, $sVarType,
}
return $mVarValue;
}

/**
* @param $mDefaultValue
* @return string
*/
protected function convertToBool($mDefaultValue)
{
if ($mDefaultValue === 'false') {
$mDefaultValue = '';
} else {
$mDefaultValue = $mDefaultValue ? '1' : '';
}
return $mDefaultValue;
}
}

0 comments on commit 4040be7

Please sign in to comment.