dns/ddclient - refactor setInternalIsVirtual() to volatile fields to make sure these exist in the index

This commit is contained in:
Ad Schellevis
2025-07-25 18:57:48 +02:00
parent d752990dfa
commit 4550a74e67
2 changed files with 6 additions and 11 deletions
@@ -204,6 +204,8 @@
<Mask>/^(.){1,255}$/u</Mask>
<ValidationMessage>Description should be a string between 1 and 255 characters</ValidationMessage>
</description>
<current_ip type="TextField" volatile="true"/>
<current_mtime type="TextField" volatile="true"/>
</account>
</accounts>
</items>
@@ -40,29 +40,22 @@ class AccountField extends ArrayField
private function addStatsFields($node)
{
// generate new unattached fields, which are only usable to read data from (not synched to config.xml)
$current_ip = new TextField();
$current_ip->setInternalIsVirtual();
$current_mtime = new TextField();
$current_mtime->setInternalIsVirtual();
if (isset(self::$current_stats[$node->getAttribute('uuid')])) {
$stats = self::$current_stats[$node->getAttribute('uuid')];
if (!empty($stats)) {
$current_ip->setValue($stats['ip']);
$current_mtime->setValue(date('c', (int)$stats['mtime']));
$node->current_ip->setValue($stats['ip']);
$node->current_mtime->setValue(date('c', (int)$stats['mtime']));
}
} elseif (!empty((string)$node->hostnames)) {
foreach (explode(",", (string)$node->hostnames) as $hostname) {
if (!empty(self::$current_stats[$hostname]) && !empty(self::$current_stats[$hostname]['ip'])) {
$stats = self::$current_stats[$hostname];
$current_ip->setValue($stats['ip']);
$current_mtime->setValue(date('c', $stats['mtime']));
$node->current_ip->setValue($stats['ip']);
$node->current_mtime->setValue(date('c', $stats['mtime']));
break;
}
}
}
$node->addChildNode('current_ip', $current_ip);
$node->addChildNode('current_mtime', $current_mtime);
}
protected function actionPostLoadingEvent()