summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bosviel2011-04-14 00:24:47 (GMT)
committerThomas Bosviel2011-04-14 00:24:47 (GMT)
commit8834a5543f007f12f60efe27c9622e44fc0cfa54 (patch)
tree2e40d2705e4fecda692d15f66b4739161f372ecd
parent51f9f5faf0fbe071936ec8a3ecf46be35147e7ea (diff)
Adds the ability to manage multiple configuration files of the same class for a service.dev-dns_alias_records-1074966
-rw-r--r--dns/dns.drush.inc38
-rw-r--r--provision.service.inc19
2 files changed, 38 insertions, 19 deletions
diff --git a/dns/dns.drush.inc b/dns/dns.drush.inc
index 4b18b65..225921b 100644
--- a/dns/dns.drush.inc
+++ b/dns/dns.drush.inc
@@ -345,15 +345,15 @@ class provisionService_dns extends provisionService {
$zones[$zone] = $zone;
foreach ($aliases as $alias) {
- $zone_alias = $this->guess_zone($alias);
- $sub_alias = $this->guess_zone($alias, 'subdomain');
- if ($zone_alias == $zone) {
- $this->config('zone', $zone)->record_set($sub_alias, array('CNAME' => array($zone . '.')));
- } else {
- $this->config('zone', $zone_alias)->record_set($sub_alias, array('A' => $ips));
- // If multiple aliases have the same zone, the zone should be created only once
- $zones[$zone_alias] = $zone_alias;
- }
+ $zone_alias = $this->guess_zone($alias);
+ $sub_alias = $this->guess_zone($alias, 'subdomain');
+ if ($zone_alias == $zone) {
+ $this->config('zone', $zone)->record_set($sub_alias, array('CNAME' => array($zone . '.')));
+ } else {
+ $this->config('zone', $zone_alias)->record_set($sub_alias, array('A' => $ips));
+ // If multiple aliases have the same zone, the zone should be created only once
+ $zones[$zone_alias] = $zone_alias;
+ }
}
foreach ($zones as $zone) {
@@ -388,13 +388,23 @@ class provisionService_dns extends provisionService {
// remove the records from the zone store
$this->config('zone', $zone)->record_set($sub, array('A' => NULL));
+ $zones[$zone] = $zone;
+
foreach ($aliases as $alias) {
- if ($this->guess_zone($alias) == $zone) {
- $this->config('zone', $zone)->record_set($this->guess_zone($alias, 'subdomain'),
- array('CNAME' => NULL));
- }
+ $zone_alias = $this->guess_zone($alias);
+ $sub_alias = $this->guess_zone($alias, 'subdomain');
+ if ($zone_alias == $zone) {
+ $this->config('zone', $zone)->record_set($sub_alias, array('CNAME' => NULL));
+ } else {
+ $this->config('zone', $zone_alias)->record_set($sub_alias, array('A' => NULL));
+ // If multiple aliases have the same zone, the zone should be created only once
+ $zones[$zone_alias] = $zone_alias;
+ }
+ }
+
+ foreach ($zones as $zone) {
+ $this->config('zone', $zone)->write();
}
- $this->config('zone', $zone)->write();
}
}
diff --git a/provision.service.inc b/provision.service.inc
index 41f7e22..eafb7b0 100644
--- a/provision.service.inc
+++ b/provision.service.inc
@@ -108,14 +108,23 @@ class provisionService extends provisionChainedState {
$data = array('name' => $data);
}
- if (!isset($this->config_cache[$this->context->name][$config])) {
- foreach ((array) $this->configs[$config] as $class) {
+ // Calculates the cache ID
+ $cid = sha1(serialize($data));
+
+ if (!isset($this->config_cache[$this->context->name][$config][$cid])) {
+ // XXX: All services use multidimensional arrays to store class name config file
+ // but that's useless because only the last class is cached.
+ // ex: $this->configs['zone'][] = 'provisionConfig_bind_zone';
+ /*foreach ((array) $this->configs[$config] as $class) {
$this->config_cache[$this->context->name][$config] = new $class($this->context, array_merge($this->config_data($config), $data));
- }
+ }*/
+ $class = $this->configs[$config][0]; // backward compatibility ??
+ $data = array_merge($this->config_data($config), $data);
+ $this->config_cache[$this->context->name][$config][$cid] = new $class($this->context, $data);
}
- if (isset($this->config_cache[$this->context->name][$config])) {
- $this->_config = $this->config_cache[$this->context->name][$config];
+ if (isset($this->config_cache[$this->context->name][$config][$cid])) {
+ $this->_config = $this->config_cache[$this->context->name][$config][$cid];
}
return $this;