Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove warnings and fix empty module export #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 59 additions & 52 deletions Core/ConfigExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ protected function getConfigValues($aConfigFields, $blIncludeMode)
protected function filternestedExcludes($values){
$excludeDeep = $this->aConfiguration['excludeDeep'];
$moduleValues = &$values['module'];

if ($moduleValues === null) {
return $values;
}

foreach ($moduleValues as $moduleId => &$moduleSettings) {
foreach ($moduleSettings as $sVarName => &$aVarValue) {
if (is_array($aVarValue)) {
Expand Down Expand Up @@ -194,71 +199,73 @@ protected function withoutDefaults(&$aGroupedValues)
foreach ($aGroupedValues as $sShopId => &$aShopConfig) {
$aGeneralConfig = &$aShopConfig[$this->sNameForGeneralShopSettings];

if (isset($aShopConfig['module'])) {
$aModuleConfigs = &$aShopConfig['module'];
if (!isset($aShopConfig['module'])) {
$aShopConfig['module'] = [];
}
$aModuleConfigs = &$aShopConfig['module'];

/** @var \oxModule $oModule */
$oModule = oxNew('oxModule');
/** @var \oxModule $oModule */
$oModule = oxNew('oxModule');

foreach ($aModuleConfigs as $sModuleId => &$aModuleConfig) {
foreach ($aModuleConfigs as $sModuleId => &$aModuleConfig) {

if (!$oModule->load($sModuleId)) {
$this->handleModuleOnError($sModuleId);
unset ($aModuleConfigs[$sModuleId]);
continue;
if (!$oModule->load($sModuleId)) {
$this->handleModuleOnError($sModuleId);
unset ($aModuleConfigs[$sModuleId]);
continue;
}
$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
$this->output->writeLn(
"$sVarName from module $sModuleId is also configured in global namespace in shop $sShopId"
);
unset($aGeneralConfig[$sVarName]);
}
$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
$this->output->writeLn(
"$sVarName from module $sModuleId is also configured in global namespace in shop $sShopId"
);
unset($aGeneralConfig[$sVarName]);
}
$sDefaultType = $aConfigValue['type'];
$mDefaultValue = $aConfigValue['value'];
$sDefaultType = $aConfigValue['type'];
$mDefaultValue = $aConfigValue['value'];


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

if (! isset($aModuleConfig[$sVarName])) {
//TODO warning about not set module config value
//this happens if the module was installed fresh and config was never saved in admin
$mCurrentValue = $mDefaultValue;
} else {
$mCurrentValue = $aModuleConfig[$sVarName];
}
if ($sDefaultType == 'bool') {
$mDefaultValue = $this->convertToBool($mDefaultValue);
}

if ($sDefaultType == 'bool') {
$mCurrentValue = $this->convertToBool($mCurrentValue);
}
if (! isset($aModuleConfig[$sVarName])) {
//TODO warning about not set module config value
//this happens if the module was installed fresh and config was never saved in admin
$mCurrentValue = $mDefaultValue;
} else {
$mCurrentValue = $aModuleConfig[$sVarName];
}

if ($mCurrentValue === $mDefaultValue) {
unset($aModuleConfig[$sVarName]);
}
if ($sDefaultType == 'bool') {
$mCurrentValue = $this->convertToBool($mCurrentValue);
}
foreach ($aModuleConfig as $aConfigKey => $Value) {
if (!isset($known[$aConfigKey])) {
$this->output->writeLn(
"$sVarName from module $sModuleId is ignored because it is not defined in metadata.php anymore"
);
unset($aModuleConfig[$aConfigKey]);
}

if ($mCurrentValue === $mDefaultValue) {
unset($aModuleConfig[$sVarName]);
}
if (count($aModuleConfig) == 0) {
unset($aModuleConfigs[$sModuleId]);
}
foreach ($aModuleConfig as $aConfigKey => $Value) {
if (!isset($known[$aConfigKey])) {
$this->output->writeLn(
"$sVarName from module $sModuleId is ignored because it is not defined in metadata.php anymore"
);
unset($aModuleConfig[$aConfigKey]);
}
}
if (count($aModuleConfig) == 0) {
unset($aModuleConfigs[$sModuleId]);
}
}

$aDefaultGeneralConfig = $this->aDefaultConfig[$this->sNameForGeneralShopSettings];
foreach ($aGeneralConfig as $sVarName => $mCurrentValue) {
$mDefaultValue = isset($aDefaultGeneralConfig[$sVarName]) ? $aDefaultGeneralConfig[$sVarName] : null;
Expand Down