Permalink
Browse files

Throw an exception when a view extends itself.

  • Loading branch information...
1 parent 047e93e commit 70981d05ca48cf7e7c4cb1d00d19a36bac2b77a4 @markstory markstory committed with markstory Dec 24, 2011
View
11 lib/Cake/Test/Case/View/ViewTest.php
@@ -1148,6 +1148,17 @@ public function testExtendNested() {
}
/**
+ * Make sure that extending the current view with itself causes an exception
+ *
+ * @expectedException LogicException
+ * @return void
+ */
+ public function testExtendSelf() {
+ $this->View->layout = false;
+ $this->View->render('extend_self');
+ }
+
+/**
* Test extend() in an element and a view.
*
* @return void
View
2 lib/Cake/Test/test_app/View/Posts/extend_self.ctp
@@ -0,0 +1,2 @@
+<?php $this->extend('extend_self'); ?>
+To infinifty and beyond.
View
3 lib/Cake/View/View.php
@@ -633,6 +633,9 @@ public function extend($name) {
break;
}
+ if ($parent == $this->_current) {
+ throw new LogicException(__d('cake_dev', 'You cannot have views extend themselves.'));
+ }
$this->_parents[$this->_current] = $parent;
}

0 comments on commit 70981d0

Please sign in to comment.