Skip to content

Commit 8eadd7d

Browse files
committed
fix(install): fresh installation does not saves current schema version
see #794
1 parent 86893f4 commit 8eadd7d

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

install/install.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public function install(Migration $migration) {
2121
$this->createDefaultDisplayPreferences();
2222
$this->createNotifications();
2323

24+
Config::setConfigurationValues('formcreator', ['schema_version' => PLUGIN_FORMCREATOR_SCHEMA_VERSION]);
25+
2426
return true;
2527
}
2628

@@ -371,10 +373,13 @@ protected function deleteTicketRelation() {
371373
PluginFormcreatorCommon::setNotification($use_mailing);
372374
}
373375

376+
/**
377+
* Cleanups the database from plugin's itemtypes (tables and relations)
378+
*/
374379
protected function deleteTables() {
375380
global $DB;
376381

377-
// Drop tables
382+
// Keep these itemtypes as string because classes might be not avaiable (if plugin is inactive)
378383
$itemtypes = [
379384
'PluginFormcreatorAnswer',
380385
'PluginFormcreatorCategory',

tests/0000_Install/PluginInstallTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ public function testInstallPlugin() {
8484
$PluginDBTest = new PluginDB();
8585
$PluginDBTest->checkInstall("formcreator", "install");
8686

87+
$config = Config::getConfigurationValues('formcreator');
88+
$this->assertArrayHasKey('schema_version', $config);
89+
$this->assertEquals($config['schema_version'], PLUGIN_FORMCREATOR_SCHEMA_VERSION);
90+
8791
// Enable the plugin
8892
$plugin->activate($plugin->fields['id']);
8993
$this->assertTrue($plugin->isActivated("formcreator"), "Cannot enable the plugin");

tests/9000_Uninstall/PluginUninstallTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ public function testUninstall() {
6464
$rows = $template->find("`itemtype` = 'PluginFormcreatorForm_Answer'");
6565
$this->assertCount(0, $rows);
6666

67-
// TODO: need to find a r eliable way to detect not clenaed
67+
$config = Config::getConfigurationValues('formcreator');
68+
$this->assertArrayNotHasKey('schema_version', $config);
69+
70+
// TODO: need to find a reliable way to detect not clenaed
6871
// - NotificationTemplateTranslation
6972
// - Notification_NotificationTemplate
7073
}

0 commit comments

Comments
 (0)