Skip to content

Commit

Permalink
catch exception for module activation
Browse files Browse the repository at this point in the history
- and compare versions to only run updates for new module versions
  • Loading branch information
keywan-ghadami-oxid committed Jul 10, 2018
1 parent 5f76804 commit 300ac3c
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions Core/ConfigImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,19 @@ protected function importConfigValues($aConfigValues)
$notLoadedModules = [];
foreach ($aModuleVersions as $sModuleId => $sVersion) {
$oldVersion = $modulesKnownBeforeImport[$sModuleId];
$newVersion = $aModuleVersions[$sModuleId];
if ($oldVersion != $newVersion) {
$versionToImport = $aModuleVersions[$sModuleId];


$gt = version_compare($versionToImport, $oldVersion,'>');
if ($gt) {
$updatedModules[$sModuleId] = $sModuleId;
if (isset($oldVersion)) {
$this->output->writeLn(
"[INFO] {$sModuleId} has a different version ($oldVersion vs $newVersion) disabling it, so it can do updates"
"[INFO] {$sModuleId} has a different version (db:$oldVersion vs import:$versionToImport) disabling it, so it can do updates"
);
} else {
$this->output->writeLn(
"[NOTE] {$sModuleId} $newVersion is new"
"[NOTE] {$sModuleId} $versionToImport is new"
);
}
if (!$oModule->load($sModuleId)) {
Expand All @@ -261,6 +264,11 @@ protected function importConfigValues($aConfigValues)
//later we will check if there is anything left that can still not be loaded
$notLoadedModules[] = $sModuleId;
continue;
} else {
//$cv = $oModule->getInfo('version');
//$this->output->writeLn(
// "[NOTE] {$sModuleId} current version is $cv"
//);
}
$disabledModulesBeforeImport[$sModuleId] = 'disabledByUpdate';
$oModuleStateFixer->deactivate($oModule);
Expand Down Expand Up @@ -322,7 +330,13 @@ protected function importConfigValues($aConfigValues)
$this->output->writeLn(
"[INFO] activating module $sModuleId"
);
$oModuleStateFixer->activate($oModule);
try {
/** Support for the key 'controllers' was added in MetaData version 2.0 */
$oModuleStateFixer->activate($oModule);
} catch (\Exception $exception) {
print "[ERROR] $sModuleId was NOT activated again.";
}

}
}

Expand Down Expand Up @@ -610,29 +624,29 @@ protected function restoreGeneralShopSettings($aConfigValues)
}
return $aModuleVersions;
}

protected function saveThemeDisplayVars($sVarName, $mVarValue, $sModule)
{
$oConfig = $this->oConfig;

$oDb = \oxDb::getDb();
$sModuleQuoted = $oDb->quote($sModule);
$sVarNameQuoted = $oDb->quote($sVarName);
$sVarConstraintsQuoted = isset($mVarValue['constraints']) ? $oDb->quote($mVarValue['constraints']) : '\'\'';
$sVarGroupingQuoted = isset($mVarValue['grouping']) ? $oDb->quote($mVarValue['grouping']) : '\'\'';
$sVarPosQuoted = isset($mVarValue['pos']) ? $oDb->quote($mVarValue['pos']) : '\'\'';

$sNewOXIDdQuoted = $oDb->quote(\oxUtilsObject::getInstance()->generateUID());

$sQ = "delete from oxconfigdisplay WHERE OXCFGVARNAME = $sVarNameQuoted and OXCFGMODULE = $sModuleQuoted";
$oDb->execute($sQ);

$sQ = "insert into oxconfigdisplay (oxid, oxcfgmodule, oxcfgvarname, oxgrouping, oxvarconstraint, oxpos )
values($sNewOXIDdQuoted, $sModuleQuoted, $sVarNameQuoted, $sVarGroupingQuoted, $sVarConstraintsQuoted, $sVarPosQuoted)";
$oDb->execute($sQ);

$oConfig->executeDependencyEvent($sVarName);

}

}

0 comments on commit 300ac3c

Please sign in to comment.