Author: as
Date: Mon Jan 7 13:27:30 2008
New Revision: 7086
Log:
- Fixed issue #12323: Using {cache_template} inside a block will now throw an
exception.
Added:
trunk/Template/tests/templates/cache_template_in_block.tpl (with props)
Modified:
trunk/Template/ChangeLog
trunk/Template/src/syntax_trees/tst/nodes/cache.php
trunk/Template/tests/cache_test.php
Modified: trunk/Template/ChangeLog
==============================================================================
--- trunk/Template/ChangeLog [iso-8859-1] (original)
+++ trunk/Template/ChangeLog [iso-8859-1] Mon Jan 7 13:27:30 2008
@@ -8,6 +8,8 @@
- Made named parameters work with PHP 5.1.6.
- Fixed issue #12289: String function str_last_index documented, but not
defined.
+- Fixed issue #12323: Using {cache_template} inside a block will now throw an
+ exception.
1.2 - Monday 02 July 2007
Modified: trunk/Template/src/syntax_trees/tst/nodes/cache.php
==============================================================================
--- trunk/Template/src/syntax_trees/tst/nodes/cache.php [iso-8859-1] (original)
+++ trunk/Template/src/syntax_trees/tst/nodes/cache.php [iso-8859-1] Mon Jan 7
13:27:30 2008
@@ -45,5 +45,25 @@
{
return array( 'templateCache' => $this->templateCache);
}
+
+ /**
+ * Checks if the given node can be attached to its parent.
+ *
+ * @throws ezcTemplateParserException if the node cannot be attached.
+ * @param ezcTemplateTstNode $parentElement
+ * @return void
+ */
+ public function canAttachToParent( $parentElement )
+ {
+ // Must be TYPE_CACHE_TEMPLATE and in the root, not in a template block
+
+ $p = $parentElement;
+
+ if ( $this->type === self::TYPE_CACHE_TEMPLATE && !$p instanceof
ezcTemplateProgramTstNode )
+ {
+ throw new ezcTemplateParserException( $this->source,
$this->startCursor, $this->startCursor,
+ "{cache_template} cannot be declared inside a template block."
);
+ }
+ }
}
?>
Modified: trunk/Template/tests/cache_test.php
==============================================================================
--- trunk/Template/tests/cache_test.php [iso-8859-1] (original)
+++ trunk/Template/tests/cache_test.php [iso-8859-1] Mon Jan 7 13:27:30 2008
@@ -446,6 +446,22 @@
}
catch ( Exception $e)
{
+ }
+ }
+
+ public function testCacheTemplateInBlock()
+ {
+ $t = new ezcTemplate( );
+ $t->send->user = new TestUser( "Bernard", "Black" );
+
+ try
+ {
+ $out = $t->process( "cache_template_in_block.tpl");
+ $this->fail("Expected an exception");
+ }
+ catch ( Exception $e )
+ {
+ $this->assertNotEquals( false, strpos( $e->getMessage(),
'{cache_template} cannot be declared inside a template block' ) );
}
}
Added: trunk/Template/tests/templates/cache_template_in_block.tpl
==============================================================================
--- trunk/Template/tests/templates/cache_template_in_block.tpl (added)
+++ trunk/Template/tests/templates/cache_template_in_block.tpl [iso-8859-1] Mon
Jan 7 13:27:30 2008
@@ -1,0 +1,7 @@
+{use $user}
+
+{if true}
+{cache_template keys $user}
+{/if}
+
+{$user->name}
Propchange: trunk/Template/tests/templates/cache_template_in_block.tpl
------------------------------------------------------------------------------
svn:eol-style = native
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components