Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Fail if custom {block} uses custom block

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
torkve
Smarty n00b


Joined: 01 May 2012
Posts: 2

PostPosted: Tue May 01, 2012 9:09 pm    Post subject: Fail if custom {block} uses custom block Reply with quote

The way to reproduce:
1. Create some user block in smarty/plugins/block.t.php:
Code:
<?php
function smarty_block_t($params, $text, $template, $repeat)
{
  return $text;
}

2. index.php:
Code:
<?php
define('SMARTY_DIR', dirname(realpath(__FILE__)).'/smarty/');

require_once('smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->setTemplateDir('./templates');
$smarty->setCompileDir('./cache/templates_c');
$smarty->setCacheDir('./cache/smarty');
$smarty->setCaching(smarty::CACHING_OFF);
$smarty->assign('page', 'kekeke');
$smarty->display('index.tpl');

3. templates/index.tpl
Code:
{extends file="base.tpl"}
{block name=title}{t}aaa{/t}{/block}

4. templates/base.tpl
Code:
{nocache}{block name=title}{$page}{/block}{/nocache}


During the execution first time I get:
Code:
/*%%SmartyNocache:3667015794fa05080616d78-86782824%%*/smarty; if (!is_callable('smarty_block_t')) include '.../testcase/smarty/plugins/block.t.php'; ?>/*/%%SmartyNocache:3667015794fa05080616d78-86782824%%*/aaa

Next times the output is:
Code:
/*%%SmartyNocache:3667015794fa05080616d78-86782824%%*/smarty; if (!is_callable('smarty_block_t')) include '.../testcase/smarty/plugins/block.t.php'; ?>/*/%%SmartyNocache:3667015794fa05080616d78-86782824%%*/ Fatal error: Call to undefined function smarty_block_t() in '.../testcase/cache/templates_c/c0360d049dff10f364dfc53ba2cc3958abf6ee6d.file.index.tpl.php on line 34
Back to top
View user's profile Send private message
torkve
Smarty n00b


Joined: 01 May 2012
Posts: 2

PostPosted: Wed May 02, 2012 9:44 am    Post subject: Reply with quote

Forgot to mention, reproduced on Smarty 3.1.8, and svn trunk versions.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed May 02, 2012 3:02 pm    Post subject: Reply with quote

The problem is the usage of {nocache} tags around {block} tags, when caching is disabled (smarty::CACHING_OFF).

I will try to fix this ASAP
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed May 02, 2012 5:20 pm    Post subject: Reply with quote

This bug is now fixed in the SVN trunk and will later be included in 3.1.9
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP