ImportRunBasedPurgeStrategy: use source key pattern

fixes #12059
This commit is contained in:
Thomas Gelf 2016-07-13 20:14:35 +02:00
parent 70c4d06a42
commit 34e57d5160
1 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Import\PurgeStrategy;
use Icinga\Module\Director\Import\SyncUtils;
use Icinga\Module\Director\Objects\ImportRun;
use Icinga\Module\Director\Objects\ImportSource;
@ -48,7 +49,8 @@ class ImportRunBasedPurgeStrategy extends PurgeStrategy
public function listKeysRemovedBetween(ImportRun $runA, ImportRun $runB)
{
$db = $this->getSyncRule()->getDb();
$rule = $this->getSyncRule();
$db = $rule->getDb();
$selectA = $runA->prepareImportedObjectQuery();
$selectB = $runB->prepareImportedObjectQuery();
@ -64,6 +66,16 @@ class ImportRunBasedPurgeStrategy extends PurgeStrategy
$result = $db->fetchCol($query);
if ($rule->object_type === 'service') {
$pattern = $rule->getSourceKeyPattern();
$columns = SyncUtils::extractVariableNames($pattern);
$rows = $runA->fetchRows($columns, null, $result);
$result = array();
foreach ($rows as $row) {
$result[] = SyncUtils::fillVariables($pattern, $row);
}
}
if ($result) {
return array_combine($result, $result);
} else {