Skip to content

Commit 6cc5967

Browse files
authored
Merge pull request #80 from mundry/version-detection-fix
fix version detection for backwards compatability
2 parents 8e22bf0 + 5c1a2d3 commit 6cc5967

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

Plugin.php

+15-9
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,28 @@ public function initialize()
4646
$this->helper->register('newTaskHelper', '\Kanboard\Plugin\Group_assign\Helper\NewTaskHelper');
4747
$this->helper->register('sizeAvatarHelperExtend', '\Kanboard\Plugin\Group_assign\Helper\SizeAvatarHelperExtend');
4848

49-
5049
//Models and backward compatibility
50+
$load_new_classes = true;
5151
$applications_version = str_replace('v', '', APP_VERSION);
52-
if ((strpos(APP_VERSION, 'master') !== false || strpos(APP_VERSION, 'main') !== false) && file_exists('ChangeLog')) {
53-
$applications_version = trim(file_get_contents('ChangeLog', false, null, 8, 6), ' ');
52+
53+
if (strpos(APP_VERSION, 'master') !== false || strpos(APP_VERSION, 'main') !== false) {
54+
if (file_exists('ChangeLog')) {
55+
$applications_version = trim(file_get_contents('ChangeLog', false, null, 8, 6), ' ');
56+
$clean_appversion = preg_replace('/\s+/', '', $applications_version);
57+
$load_new_classes = version_compare($clean_appversion, '1.2.6', '<');
58+
}
59+
} else {
60+
$load_new_classes = version_compare($applications_version, '1.2.5', '>');
5461
}
55-
$clean_appversion = preg_replace('/\s+/', '', $applications_version);
5662

57-
if (version_compare($clean_appversion, '1.2.6', '<')) {
63+
if ($load_new_classes) {
5864
if (file_exists('plugins/MetaMagik')) {
5965
$this->container['taskFinderModel'] = $this->container->factory(function ($c) {
60-
return new OldMetaMagikSubquery($c);
66+
return new NewMetaMagikSubquery($c);
6167
});
6268
} else {
6369
$this->container['taskFinderModel'] = $this->container->factory(function ($c) {
64-
return new OldTaskFinderModel($c);
70+
return new NewTaskFinderModel($c);
6571
});
6672
}
6773
$this->container['taskDuplicationModel'] = $this->container->factory(function ($c) {
@@ -79,11 +85,11 @@ public function initialize()
7985
} else {
8086
if (file_exists('plugins/MetaMagik')) {
8187
$this->container['taskFinderModel'] = $this->container->factory(function ($c) {
82-
return new NewMetaMagikSubquery($c);
88+
return new OldMetaMagikSubquery($c);
8389
});
8490
} else {
8591
$this->container['taskFinderModel'] = $this->container->factory(function ($c) {
86-
return new NewTaskFinderModel($c);
92+
return new OldTaskFinderModel($c);
8793
});
8894
}
8995
$this->container['taskDuplicationModel'] = $this->container->factory(function ($c) {

0 commit comments

Comments
 (0)