Skip to content

Commit

Permalink
Fixed issue #15837: After upgrade plugins are duplicated
Browse files Browse the repository at this point in the history
InstalledPlugins variable had the wrong form.
  • Loading branch information
gabrieljenik committed Aug 24, 2020
1 parent 7dc7fcf commit ea06049
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -3018,21 +3018,38 @@ function db_upgrade_all($iOldDBVersion, $bSilent = false)

if ($iOldDBVersion < 424) {
$oTransaction = $oDB->beginTransaction();
$installedPlugins = $oDB->createCommand('SELECT name FROM {{plugins}}')->queryAll();
$installedPlugins = array_map(
function ($v) {
return $v['name'];
},
$oDB->createCommand('SELECT name FROM {{plugins}}')->queryAll()
);
/**
* @param string $name Name of plugin
* @param int $active
*/
$insertPlugin = function ($name, $active = 0) use ($installedPlugins, $oDB) {
if (!in_array($name, $installedPlugins)) {
$oDB->createCommand()->insert("{{plugins}}", [
'name' => $name,
'plugin_type' => 'core',
'active' => $active,
'version' => '1.0.0',
'load_error' => 0,
'load_error_message' => null
]);
$oDB->createCommand()->insert(
"{{plugins}}",
[
'name' => $name,
'plugin_type' => 'core',
'active' => $active,
'version' => '1.0.0',
'load_error' => 0,
'load_error_message' => null
]
);
} else {
$oDB->createCommand()->update(
"{{plugins}}",
[
'plugin_type' => 'core',
'version' => '1.0.0',
],
"`name`='{$name}'"

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Feb 11, 2021

Collaborator

Warning with SQL : https://bugs.limesurvey.org/view.php?id=17084 :)

Here : not needed, else App()->getDb()->quoteColumnName('name');

;)

This comment has been minimized.

Copy link
@gabrieljenik

gabrieljenik Feb 11, 2021

Author Collaborator

Why "not needed"? Sorry, not following.

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Feb 11, 2021

Collaborator

"name='{$name}'" must work.

Else
$oDB->quoteColumnName("name") ."=". $oDB->quoteValue($name} work in all condition
see quoteColumnName and quoteValue

This comment has been minimized.

Copy link
@gabrieljenik

gabrieljenik Feb 17, 2021

Author Collaborator

Seems @olleharstedt has fixed this already. Thanks!

);
}
};
$insertPlugin('AuthLDAP');
Expand Down

0 comments on commit ea06049

Please sign in to comment.