From 521198d10760a29aeaf58a82b5e5a05093d7132e Mon Sep 17 00:00:00 2001
From: Pieter Frenssen <pieter@frenssen.be>
Date: Wed, 16 Jan 2013 16:50:35 +0100
Subject: [PATCH] Issue #1878942 by pfrenssen: Remove the domain_node variable
 when a content type is deleted.

---
 domain.install | 16 ++++++++++++++++
 domain.module  |  7 +++++++
 2 files changed, 23 insertions(+)

diff --git a/domain.install b/domain.install
index f474f16..23eb310 100644
--- a/domain.install
+++ b/domain.install
@@ -427,3 +427,19 @@ function domain_update_7309(&$sandbox) {
 function domain_update_7310(&$sandbox) {
   node_access_rebuild(TRUE);
 }
+
+/**
+ * Remove stale domain_node_{bundle} variables.
+ */
+function domain_update_7311(&$sandbox) {
+  if (function_exists('node_type_get_types')) {
+    $variable_names = array();
+    foreach (node_type_get_types() as $key => $type) {
+      $variable_names[] = 'domain_node_' . $key;
+    }
+    db_delete('variable')
+      ->condition('name', 'domain_node_%', 'LIKE')
+      ->condition('name', $variable_names, 'NOT IN')
+      ->execute();
+  }
+}
diff --git a/domain.module b/domain.module
index 3f2d162..a66defd 100644
--- a/domain.module
+++ b/domain.module
@@ -1807,6 +1807,13 @@ function domain_node_update($node) {
 }
 
 /**
+ * Implements hook_node_type_delete().
+ */
+function domain_node_type_delete($info) {
+  variable_del('domain_node_' . $info->type);
+}
+
+/**
  * Get the best matching domain for a node link.
  *
  * @param $nid
-- 
1.8.1

