nrueckmann / smarty-php

Automatically exported from code.google.com/p/smarty-php
0 stars 0 forks source link

Template resource in blocks gets invalid if default_resource_type is not 'file' #202

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've registered an own resource type which was then set as standard by changing 
default_resource_type. When I however fetch a template with 'file:' prefix that 
extends another template without prefix, my resource handling gets corrupt.
The problem is in Smarty_Internal_Compile_Private_Child_Block::compile(). From 
the second line following:
   // update template with original template resource of {block}
   if (trim($_attr['type'], "'") == 'file') {
      $compiler->template->template_resource = realpath(trim($_attr['file'], "'"));
   } else {
      $compiler->template->template_resource = trim($_attr['resource'], "'");
   }
But the problem is that realpath trims the 'file:' prefix that is given in 
$_attr['file']. This does not cause problems when default_resource_type is set 
to 'file', but does when it differs. This means that the template then has a 
wrong resource type, which will eventually lead to problems in any custom 
resource handler.
The fix is very simple:
   $compiler->template->template_resource = 'file:' . realpath(trim($_attr['file'], "'"));
You might only want to add the prefix if default_resource_type is not 'file', 
but the above way should not cause problems.

Original issue reported on code.google.com by bde...@gmail.com on 23 Sep 2014 at 1:14

GoogleCodeExporter commented 8 years ago
This bug is now fix in the SVN trunk.
The fix will later be included in the next release 3.1.20

Original comment by Uwe.Tews@googlemail.com on 30 Sep 2014 at 11:22