diff --git a/e107_admin/footer.php b/e107_admin/footer.php
index 87aeb17a3..b193a4666 100644
--- a/e107_admin/footer.php
+++ b/e107_admin/footer.php
@@ -373,6 +373,10 @@ if($tmp1)
$tmp['replace'][] = $tmp1;
}
+
+// Shutdown
+$e107->destruct();
+
if($tmp)
{
$page = str_replace($tmp['search'], $tmp['replace'], ob_get_clean());
diff --git a/e107_core/templates/footer_default.php b/e107_core/templates/footer_default.php
index b055f4093..c9994189e 100644
--- a/e107_core/templates/footer_default.php
+++ b/e107_core/templates/footer_default.php
@@ -324,6 +324,9 @@ echo "
{$name} = $ret;
return $ret;
}
+
+ public function destruct()
+ {
+ if(null === self::$_instance) return;
+
+ $print = defined('E107_DBG_TIMEDETAILS') && E107_DBG_TIMEDETAILS;
+ !$print || print('Destructing $e107:
');
+ $vars = get_object_vars($this);
+ foreach ($vars as $name => $value)
+ {
+ if(is_object($value))
+ {
+ if(method_exists($value, '__destruct'))
+ {
+ !$print || print('object [property] using __destruct(): '.$path.' - '.get_class($value).'
');
+ $value->__destruct();
+ }
+ else !$print || print('object [property]: '.$name.' - '.get_class($value).'
');
+ $this->$name = null;
+ }
+ }
+ foreach (self::$_registry as $path => $reg)
+ {
+ if(is_object($reg))
+ {
+ if(method_exists($reg, '__destruct'))
+ {
+ !$print || print('object [registry] using __destruct(): '.$path.' - '.get_class($reg).'
');
+ $reg->__destruct();
+ }
+ else !$print || print('object [registry]: '.$path.' - '.get_class($reg).'
');
+ unset(self::$_registry[$path]);
+ }
+
+ }
+ self::$_registry = null;
+ self::$_instance = null;
+ }
}