Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Throw an exception when a view extends itself.

  • Loading branch information...
commit 70981d05ca48cf7e7c4cb1d00d19a36bac2b77a4 1 parent 047e93e
@markstory markstory authored markstory committed
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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.