File tree Expand file tree Collapse file tree 8 files changed +31
-10
lines changed Expand file tree Collapse file tree 8 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ public function init()
54
54
Filter::equal ('host.name ' , $ hostName )
55
55
));
56
56
57
- if (Backend::getDbSchemaVersion () >= 6 ) {
57
+ if (Backend::supportsDependencies () ) {
58
58
$ query ->withColumns (['has_problematic_parent ' ]);
59
59
}
60
60
Original file line number Diff line number Diff line change @@ -29,6 +29,9 @@ final class Backend
29
29
/** @var ?IcingaRedis */
30
30
private static $ redis ;
31
31
32
+ /** @var ?bool Whether the current Icinga DB version supports dependencies */
33
+ private static $ supportsDependencies ;
34
+
32
35
/**
33
36
* Set the connection to the Icinga DB
34
37
*
@@ -165,4 +168,22 @@ public static function getRedis(): IcingaRedis
165
168
166
169
return self ::$ redis ;
167
170
}
171
+
172
+ /**
173
+ * Whether the current Icinga DB version supports dependencies
174
+ *
175
+ * @return bool
176
+ */
177
+ public static function supportsDependencies (): bool
178
+ {
179
+ if (self ::$ supportsDependencies === null ) {
180
+ if (self ::getDb ()->getAdapter () instanceof Pgsql) {
181
+ self ::$ supportsDependencies = self ::getDbSchemaVersion () >= 5 ;
182
+ } else {
183
+ self ::$ supportsDependencies = self ::getDbSchemaVersion () >= 7 ;
184
+ }
185
+ }
186
+
187
+ return self ::$ supportsDependencies ;
188
+ }
168
189
}
Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ public function getColumns()
116
116
'command_endpoint_id '
117
117
];
118
118
119
- if (Backend::getDbSchemaVersion () >= 6 ) {
119
+ if (Backend::supportsDependencies () ) {
120
120
$ columns [] = 'affected_children ' ;
121
121
}
122
122
@@ -166,7 +166,7 @@ public function getColumnDefinitions()
166
166
'command_endpoint_id ' => t ('Endpoint Id ' )
167
167
];
168
168
169
- if (Backend::getDbSchemaVersion () >= 6 ) {
169
+ if (Backend::supportsDependencies () ) {
170
170
$ columns ['affected_children ' ] = t ('Affected Children ' );
171
171
}
172
172
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public function getColumnDefinitions()
57
57
'next_update ' => t ('Host Next Update ' )
58
58
];
59
59
60
- if (Backend::getDbSchemaVersion () >= 6 ) {
60
+ if (Backend::supportsDependencies () ) {
61
61
$ columns ['affects_children ' ] = t ('Host Affects Children ' );
62
62
}
63
63
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ public function getColumns()
109
109
'command_endpoint_id '
110
110
];
111
111
112
- if (Backend::getDbSchemaVersion () >= 6 ) {
112
+ if (Backend::supportsDependencies () ) {
113
113
$ columns [] = 'affected_children ' ;
114
114
}
115
115
@@ -156,7 +156,7 @@ public function getColumnDefinitions()
156
156
'command_endpoint_id ' => t ('Endpoint Id ' ),
157
157
];
158
158
159
- if (Backend::getDbSchemaVersion () >= 6 ) {
159
+ if (Backend::supportsDependencies () ) {
160
160
$ columns ['affected_children ' ] = t ('Affected Children ' );
161
161
}
162
162
@@ -207,7 +207,7 @@ public function createBehaviors(Behaviors $behaviors)
207
207
'command_endpoint_id '
208
208
]));
209
209
210
- if (Backend::getDbSchemaVersion () >= 6 ) {
210
+ if (Backend::supportsDependencies () ) {
211
211
$ behaviors ->add (new HasProblematicParent ());
212
212
}
213
213
}
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ public function getColumnDefinitions()
59
59
'next_update ' => t ('Service Next Update ' )
60
60
];
61
61
62
- if (Backend::getDbSchemaVersion () >= 6 ) {
62
+ if (Backend::supportsDependencies () ) {
63
63
$ columns ['affects_children ' ] = t ('Service Affects Children ' );
64
64
}
65
65
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ public function getColumns()
103
103
'next_update '
104
104
];
105
105
106
- if (Backend::getDbSchemaVersion () >= 6 ) {
106
+ if (Backend::supportsDependencies () ) {
107
107
$ columns [] = 'affects_children ' ;
108
108
}
109
109
Original file line number Diff line number Diff line change @@ -619,7 +619,7 @@ protected function fetchCustomVars()
619
619
*/
620
620
protected function createRootProblems (): ?array
621
621
{
622
- if (Backend::getDbSchemaVersion () < 6 ) {
622
+ if (! Backend::supportsDependencies () ) {
623
623
if ($ this ->object ->state ->is_reachable ) {
624
624
return null ;
625
625
}
You can’t perform that action at this time.
0 commit comments