mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Throw an exception when a view extends itself.
This commit is contained in:
parent
047e93e285
commit
70981d05ca
3 changed files with 16 additions and 0 deletions
|
@ -1147,6 +1147,17 @@ TEXT;
|
|||
$this->assertEquals($expected, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
2
lib/Cake/Test/test_app/View/Posts/extend_self.ctp
Normal file
2
lib/Cake/Test/test_app/View/Posts/extend_self.ctp
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?php $this->extend('extend_self'); ?>
|
||||
To infinifty and beyond.
|
|
@ -633,6 +633,9 @@ class View extends Object {
|
|||
break;
|
||||
|
||||
}
|
||||
if ($parent == $this->_current) {
|
||||
throw new LogicException(__d('cake_dev', 'You cannot have views extend themselves.'));
|
||||
}
|
||||
$this->_parents[$this->_current] = $parent;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue