mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Keep compatibility with Icinga DB mysql v6 & pgsql v4
This commit is contained in:
parent
d4f69516a2
commit
dd744395c7
8 changed files with 31 additions and 10 deletions
|
|
@ -54,7 +54,7 @@ class ServiceController extends Controller
|
|||
Filter::equal('host.name', $hostName)
|
||||
));
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
if (Backend::supportsDependencies()) {
|
||||
$query->withColumns(['has_problematic_parent']);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ final class Backend
|
|||
/** @var ?IcingaRedis */
|
||||
private static $redis;
|
||||
|
||||
/** @var ?bool Whether the current Icinga DB version supports dependencies */
|
||||
private static $supportsDependencies;
|
||||
|
||||
/**
|
||||
* Set the connection to the Icinga DB
|
||||
*
|
||||
|
|
@ -165,4 +168,22 @@ final class Backend
|
|||
|
||||
return self::$redis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the current Icinga DB version supports dependencies
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function supportsDependencies(): bool
|
||||
{
|
||||
if (self::$supportsDependencies === null) {
|
||||
if (self::getDb()->getAdapter() instanceof Pgsql) {
|
||||
self::$supportsDependencies = self::getDbSchemaVersion() >= 5;
|
||||
} else {
|
||||
self::$supportsDependencies = self::getDbSchemaVersion() >= 7;
|
||||
}
|
||||
}
|
||||
|
||||
return self::$supportsDependencies;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class Host extends Model
|
|||
'command_endpoint_id'
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
if (Backend::supportsDependencies()) {
|
||||
$columns[] = 'affected_children';
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +166,7 @@ class Host extends Model
|
|||
'command_endpoint_id' => t('Endpoint Id')
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
if (Backend::supportsDependencies()) {
|
||||
$columns['affected_children'] = t('Affected Children');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class HostState extends State
|
|||
'next_update' => t('Host Next Update')
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
if (Backend::supportsDependencies()) {
|
||||
$columns['affects_children'] = t('Host Affects Children');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class Service extends Model
|
|||
'command_endpoint_id'
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
if (Backend::supportsDependencies()) {
|
||||
$columns[] = 'affected_children';
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ class Service extends Model
|
|||
'command_endpoint_id' => t('Endpoint Id'),
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
if (Backend::supportsDependencies()) {
|
||||
$columns['affected_children'] = t('Affected Children');
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ class Service extends Model
|
|||
'command_endpoint_id'
|
||||
]));
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
if (Backend::supportsDependencies()) {
|
||||
$behaviors->add(new HasProblematicParent());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class ServiceState extends State
|
|||
'next_update' => t('Service Next Update')
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
if (Backend::supportsDependencies()) {
|
||||
$columns['affects_children'] = t('Service Affects Children');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ abstract class State extends Model
|
|||
'next_update'
|
||||
];
|
||||
|
||||
if (Backend::getDbSchemaVersion() >= 6) {
|
||||
if (Backend::supportsDependencies()) {
|
||||
$columns[] = 'affects_children';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ class ObjectDetail extends BaseHtmlElement
|
|||
*/
|
||||
protected function createRootProblems(): ?array
|
||||
{
|
||||
if (Backend::getDbSchemaVersion() < 6) {
|
||||
if (! Backend::supportsDependencies()) {
|
||||
if ($this->object->state->is_reachable) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue