mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
parent
5a0c0481b4
commit
bb6530e9f9
@ -47,6 +47,10 @@ class KickstartForm extends DirectorForm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->hasBeenSent() && !$this->tryDbConnection()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->migrations()->hasSchema()) {
|
if (!$this->migrations()->hasSchema()) {
|
||||||
$this->addHtmlHint($this->translate(
|
$this->addHtmlHint($this->translate(
|
||||||
'No database schema has been created yet'
|
'No database schema has been created yet'
|
||||||
@ -194,35 +198,8 @@ class KickstartForm extends DirectorForm
|
|||||||
// Do not hinder the form from being stored
|
// Do not hinder the form from being stored
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($resourceName = $this->getResourceName()) {
|
|
||||||
$resourceConfig = ResourceFactory::getResourceConfig($resourceName);
|
|
||||||
if (! isset($resourceConfig->charset)
|
|
||||||
|| ! in_array($resourceConfig->charset, array('utf8', 'utf8mb4', 'UTF8', 'UTF-8'))
|
|
||||||
) {
|
|
||||||
if ($resource = $this->getElement('resource')) {
|
|
||||||
$resource->addError('Please change the encoding for the director database to utf8');
|
|
||||||
} else {
|
|
||||||
$this->addError('Please change the encoding for the director database to utf8');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$resource = $this->getResource();
|
$this->tryDbConnection();
|
||||||
$db = $resource->getDbAdapter();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$db->fetchOne('SELECT 1');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->getElement('resource')
|
|
||||||
->addError('Could not connect to database: ' . $e->getMessage());
|
|
||||||
|
|
||||||
$hint = $this->translate(
|
|
||||||
'Please make sure that your database exists and your user has'
|
|
||||||
. ' been granted enough permissions'
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->addHtmlHint($hint, array('name' => 'HINT_db_perms'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -466,4 +443,40 @@ class KickstartForm extends DirectorForm
|
|||||||
|
|
||||||
return $resources;
|
return $resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function tryDbConnection()
|
||||||
|
{
|
||||||
|
if ($resourceName = $this->getResourceName()) {
|
||||||
|
$resourceConfig = ResourceFactory::getResourceConfig($resourceName);
|
||||||
|
if (!isset($resourceConfig->charset)
|
||||||
|
|| !in_array($resourceConfig->charset, array('utf8', 'utf8mb4', 'UTF8', 'UTF-8'))
|
||||||
|
) {
|
||||||
|
if ($resource = $this->getElement('resource')) {
|
||||||
|
$resource->addError('Please change the encoding for the director database to utf8');
|
||||||
|
} else {
|
||||||
|
$this->addError('Please change the encoding for the director database to utf8');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$resource = $this->getResource();
|
||||||
|
$db = $resource->getDbAdapter();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$db->fetchOne('SELECT 1');
|
||||||
|
return true;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->getElement('resource')
|
||||||
|
->addError('Could not connect to database: ' . $e->getMessage());
|
||||||
|
|
||||||
|
$hint = $this->translate(
|
||||||
|
'Please make sure that your database exists and your user has'
|
||||||
|
. ' been granted enough permissions'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addHtmlHint($hint, array('name' => 'HINT_db_perms'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,9 @@ next (will be 1.9.0)
|
|||||||
### Import and Sync
|
### Import and Sync
|
||||||
* FEATURE: introduce 'disable' as your purge action on Sync (#2285)
|
* FEATURE: introduce 'disable' as your purge action on Sync (#2285)
|
||||||
|
|
||||||
|
### User Interface
|
||||||
|
* FIX: allow switching DB config while connection is failing (#2300)
|
||||||
|
|
||||||
next patch release (will be 1.8.1)
|
next patch release (will be 1.8.1)
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user