Skip to content

Commit

Permalink
Fix issue where incorrect elements would be used.
Browse files Browse the repository at this point in the history
If your view is using an alternate extension and you have elements
that share filenames, the incorrect element would be used.
Fixes #2082
  • Loading branch information
markstory committed Oct 11, 2011
1 parent bc6de18 commit 049d6e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cake/libs/view/view.php
Expand Up @@ -380,6 +380,9 @@ function element($name, $params = array(), $loadHelpers = false) {
break;
}
}
if ($file) {
break;
}
}

if (is_file($file)) {
Expand Down
11 changes: 11 additions & 0 deletions cake/tests/cases/libs/view/view.test.php
Expand Up @@ -487,6 +487,17 @@ function testElement() {
$this->assertPattern('/non_existant_element/', $result);
}

/**
* Test that alternate extensions work with duplicated elements.
*
* @return void
*/
function testElementExtensions() {
$this->View->ext = '.xml';
$result = $this->View->element('test_element');
$this->assertEqual(trim($result), '<p>test element</p>');
}

/**
* test that additional element viewVars don't get overwritten with helpers.
*
Expand Down
1 change: 1 addition & 0 deletions cake/tests/test_app/views/elements/test_element.xml
@@ -0,0 +1 @@
<p>test element</p>

0 comments on commit 049d6e4

Please sign in to comment.