Skip to content
Open
Show file tree
Hide file tree
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
18 changes: 17 additions & 1 deletion core/ajax/repo.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,23 @@
if ($update->getConfiguration('doNotUpdate') == 1) {
throw new Exception(__('Mise à jour et réinstallation désactivées sur ', __FILE__) . ' ' . $repo->getLogicalId());
}
$update->setSource(init('repo'));
// Purge configuration keys not belonging to the new source to avoid orphaned data.
$newSource = init('repo');
$allSourceKeys = [
'market' => ['market'],
'github' => ['user', 'repository', 'token'],
'url' => ['url'],
'samba' => ['path'],
'file' => ['path'],
];
$keysToKeep = $allSourceKeys[$newSource] ?? [];
foreach ($allSourceKeys as $source => $sourceKeys) {
if ($source === $newSource) continue;
foreach (array_diff($sourceKeys, $keysToKeep) as $key) {
$update->setConfiguration($key, null);
}
}
$update->setSource($newSource);
$update->setLogicalId($repo->getLogicalId());
$update->setType($repo->getType());
$update->setLocalVersion($repo->getDatetime(init('version', 'stable')));
Expand Down
16 changes: 16 additions & 0 deletions core/ajax/update.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@
}
$old_update = $update;
utils::a2o($update, $update_json);
// Purge configuration keys not belonging to the new source to avoid orphaned data.
$newSource = $update->getSource();
$allSourceKeys = [
'market' => ['market'],
'github' => ['user', 'repository', 'token'],
'url' => ['url'],
'samba' => ['path'],
'file' => ['path'],
];
$keysToKeep = $allSourceKeys[$newSource] ?? [];
foreach ($allSourceKeys as $source => $sourceKeys) {
if ($source === $newSource) continue;
foreach (array_diff($sourceKeys, $keysToKeep) as $key) {
$update->setConfiguration($key, null);
}
}
$update->save();
try {
$update->doUpdate();
Expand Down
4 changes: 4 additions & 0 deletions core/php/jeecli.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
if (!is_object($update)) {
$update = new update();
}
// Purge configuration keys not belonging to market source to avoid orphaned data.
foreach (['user', 'repository', 'token', 'url', 'path'] as $key) {
$update->setConfiguration($key, null);
}
$update->setLogicalId($argv[3]);
$update->setSource('market');
$update->setConfiguration('version', 'stable');
Expand Down
5 changes: 4 additions & 1 deletion core/repo/market.repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,15 @@ public static function pullInstall() {
if (!is_object($update)) {
$update = new update();
}
// Purge configuration keys not belonging to market source to avoid orphaned data.
foreach (['user', 'repository', 'token', 'url', 'path'] as $key) {
$update->setConfiguration($key, null);
}
$update->setSource('market');
$update->setLogicalId($repo->getLogicalId());
$update->setType($repo->getType());
$update->setLocalVersion($repo->getDatetime($plugin['version']));
$update->setConfiguration('version', $plugin['version']);
$update->setConfiguration('user', null);
$update->save();
$update->doUpdate();
$nbInstall++;
Expand Down
4 changes: 2 additions & 2 deletions desktop/js/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ if (!jeeFrontEnd.update) {
default:
updClass = 'label-danger'
}
if (typeof _update.configuration.user!== 'undefined'){
tr += ' <span class="label ' + updClass + ' hidden-992">' + _update.configuration.version +' - '+ _update.configuration.user + '</span>'
if (typeof _update.configuration.user !== 'undefined' && _update.source !== 'market') {
tr += ' <span class="label ' + updClass + ' hidden-992">' + _update.configuration.version + ' - ' + _update.configuration.user + '</span>'
} else {
tr += ' <span class="label ' + updClass + ' hidden-992">' + _update.configuration.version + '</span>'
}
Expand Down
Loading