IcingaConfig: separate modification check from store

This commit is contained in:
Thomas Gelf 2015-11-03 09:10:34 +01:00
parent bf7001510f
commit e02e61abd4
1 changed files with 16 additions and 3 deletions

View File

@ -89,17 +89,30 @@ class IcingaConfig
return $config->storeIfModified();
}
protected function storeIfModified()
protected function hasBeenModified()
{
$this->generateFromDb();
$this->collectExtraFiles();
$checksum = $this->calculateChecksum();
$exists = $this->db->fetchOne(
$this->db->select()->from(self::$table, 'COUNT(*)')->where('checksum = ?', $this->dbBin($checksum))
$this->db->select()->from(
self::$table,
'COUNT(*)'
)->where(
'checksum = ?',
$this->dbBin($checksum)
)
);
if ((int) $exists === 0) {
return (int) $exists === 0;
}
protected function storeIfModified()
{
if ($this->hasBeenModified()) {
$this->store();
}
return $this;
}