Re: [SMARTY-DEV] Bug found in file function.config_load.php
| From: | Monte Ohrt | Date: | Fri, 12 Dec 2003 14:38:57 +0000 |
| Subject: | Re: [SMARTY-DEV] Bug found in file function.config_load.php | ||
| References: | 1 2 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1980@lists.php.net to get a copy of this message | ||
fixed in CVS, thanks.
Monte
On Thu, 2003-12-11 at 19:52, bac wrote:
> i found a bug in function smarty_function_config_load () ;
>
> the function is congealing the variable $smarty->config_dir,
> generating a great problem when object is used the same $smarty,
> to generate two templates different with two config files in localization different,
>
> it follows below an example of use with bug reported:
>
> <?
> require('./Smarty-2.6.0/libs/Smarty.class.php');
> $smarty = new smarty;
> $smarty->compile_check = true;
>
> // first template...
>
> $smarty->template_dir='./template_dir1';
> $smarty->compile_dir='./compile_dir';
> $smarty->config_dir='./template_dir1/config';
> $smarty->assign('test','testeok');
> $smarty->display('test.tpl');
>
>
> // is ok ...
> // output is:
>
> $test = testeok
> #CONFIG_TEST = Test OK!
>
> // second template ..
>
> $smarty->template_dir='./template_dir2';
> $smarty->compile_dir='./compile_dir';
> $smarty->config_dir='./template_dir2/config';
> $smarty->assign('test2','testeok2');
> $smarty->display('test2.tpl');
>
> $smarty->clear_compiled_tpl();
>
> // is a error
> // output is:
>
> Warning: Config_File error: Could not open config file
> './template_dir1/config\test2.conf' in \Smarty-2.6.0\libs\Config_File.class.php on line
> 360
>
> Warning: Config_File error: Could not open config file
> './template_dir1/config\test2.conf' in \Smarty-2.6.0\libs\Config_File.class.php on line
> 360
>
> $test2 = testeok2
> #CONFIG_TEST2 =
>
>
> ?>
>
> it sees that in first template no error does not occur,
> to put in as template, the variable $smarty->config_dir although
> to be modified with the new directory ($smarty->config_dir='.\template_dir2\config
> ';)
> smarty looked test2.conf in the first directory.
>
> the problem is in the file Smarty-2.6.0\libs\plugins\function.config_load.php on line 84
> to correct the problem the following alteration must be made
>
> diff -r Smarty-2.6.0/libs/plugins/function.config_load.php
> Smarty-2.6.0-bac/libs/plugins/function.config_load.php
> 83,84c83
> < $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;
> < $smarty->_conf_obj->set_path = $_config_dir;
> ---
> > $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;
> 85a85
> > $smarty->_conf_obj->set_path ( $_config_dir );
>
>
> yours truly,
> bac@oops.com.br
> Marc Victor C Cabadas
>
>