View previous topic :: View next topic |
Author |
Message |
xilentxage Smarty Rookie
Joined: 25 Oct 2010 Posts: 15
|
Posted: Mon Feb 06, 2012 8:42 pm Post subject: Fatal error: Class '_smarty_template_buffer' not found |
|
|
Hi,
I try to upgrade from version 2.x to the newest one. I noticed some function names were changed so I had to make some minor adjustments. However now I'm stuck with this error:
Fatal error: Class '_smarty_template_buffer' not found in ...
This happens when after I use the fetch()-method. I use my own wrapper to handle Smarty, but apart from that nothing special.
Of course I did some googling and everything that comes up has to do with the autoloader. But I do not use autoloaders anywhere in my code at all, and I do not use any other 3rd party code that might interfere. I do use multiple instances of Smarty but I guess that shouldnt be a problem. I use PHP 5.3.8.
Code: |
#start template engine
$_incl->incl_once("_functions/template_handler/Smarty-3.1.7/libs/Smarty.class.php");
$this->tpl = new Smarty();
#parse template engine settings
$_debug->add_debuglog("Applying Smarty settings");
$this->tpl->compile_dir = $_paths['web_root'] . "_cache/smarty_compile/";
$this->tpl->cache_dir = $_paths['web_root'] . "_cache/smarty_cache/";
if ( $this->settings['smarty_force_compile'] == "1" ) { $this->tpl->force_compile = true; }
else { $this->tpl->force_compile = false; }
if ( $this->settings['smarty_use_cache'] == "1" ) { $this->tpl->caching = true; }
else { $this->tpl->caching = false; }
if ( $this->settings['smarty_compile_check'] == "1" ) { $this->tpl->compile_check = true; }
else { $this->tpl->compile_check = false; }
$this->tpl->cache_lifetime = $this->settings['smarty_cache_lifetime'];
$this->tpl->php_handling = $this->settings['smarty_php_handling'];
#assign
if ( isset($this->template_vars) ) {
$_debug->add_debuglog("Assigning template vars");
foreach ( $this->template_vars as $k_tv=>$v_tv ) {
if ( !isset($needsparsing) && !is_array($v_tv) && strpos($v_tv, "{") !== FALSE ) { $needsparsing = true; }
$this->tpl->assign($k_tv, $v_tv);
}
if ( isset($needsparsing) ) {
$_debug->add_debuglog("Parsing template vars");
foreach ( $this->template_vars as $k_tv=>$v_tv ) { if ( !is_array($v_tv) && strpos($v_tv, "{") !== FALSE ) { $this->tpl->assign($k_tv, $this->tpl->fetch("string:" . $v_tv)); }}
}
}
#lookup template
if ( !isset($this->template) ) { trigger_error("No template defined"); }
else { $_debug->add_debuglog("Looking up tpl file " . $this->template); }
$templatefile = $_incl->lookup($this->template);
#smarty
$_debug->add_debuglog("Found tpl " . $templatefile);
$_debug->add_debuglog("Template-engine parsing for " . $templatefile);
$content = $this->tpl->fetch($templatefile);
|
Any help would be greatly appreciated! |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Feb 06, 2012 9:31 pm Post subject: |
|
|
This is strange
Quote: | Fatal error: Class '_smarty_template_buffer' not found in ... |
Please provide the complete traceback information of the error message.
Looks like that file smarty_internal_parsetree.php was not loaded for some reasion. Check the PHP errorlog if you find a message there.
Other topic:
In Smarty3 you should not set the directory properties directly.
Use the new setter metods like
Code: | $this->tpl->setCompileDir( $_paths['web_root'] . "_cache/smarty_compile/");
$this->tpl->setCacheDir( $_paths['web_root'] . "_cache/smarty_cache/");
|
|
|
Back to top |
|
xilentxage Smarty Rookie
Joined: 25 Oct 2010 Posts: 15
|
Posted: Tue Feb 07, 2012 7:28 am Post subject: |
|
|
U.Tews wrote: | This is strange
Please provide the complete traceback information of the error message.
|
Fatal error: Class '_smarty_template_buffer' not found in [...]/Smarty-3.1.7/libs/sysplugins/smarty_internal_templateparser.php on line 117
U.Tews wrote: |
Other topic:
In Smarty3 you should not set the directory properties directly.
|
Fixed, thanks! Doesnt help though, still same error... |
|
Back to top |
|
xilentxage Smarty Rookie
Joined: 25 Oct 2010 Posts: 15
|
Posted: Tue Feb 07, 2012 8:38 am Post subject: |
|
|
Maybe this helps?
Smarty Installation test...
Testing template directory...
FAILED: ./templates/ does not exist.
Testing compile directory...
*****/smarty_compile is OK.
Testing plugins directory...
*****/Smarty-3.1.7/libs/plugins is OK.
Testing cache directory...
*****/smarty_cache is OK.
Testing configs directory...
FAILED: ./configs/ does not exist.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.
PS I use my own methods to set templates so I dont need a templates dir. But maybe this is required? |
|
Back to top |
|
rodneyrehm Administrator
Joined: 30 Mar 2007 Posts: 674 Location: Germany, border to Switzerland
|
Posted: Tue Feb 07, 2012 8:58 am Post subject: |
|
|
How do you set your own templates? _________________ Twitter |
|
Back to top |
|
xilentxage Smarty Rookie
Joined: 25 Oct 2010 Posts: 15
|
Posted: Tue Feb 07, 2012 9:15 am Post subject: |
|
|
rodneyrehm wrote: | How do you set your own templates? |
please see my code above. It uses a cascade to find the template. It first checks if a custom template exists in the pagedir, then it checks if it exists in the theme dir, then the domain dir and if all else fails it uses a default template.
I have checked and made sure it specifies a valid TPL file (including full path). This template file is located outside the smarty dir btw. |
|
Back to top |
|
xilentxage Smarty Rookie
Joined: 25 Oct 2010 Posts: 15
|
Posted: Tue Feb 07, 2012 7:00 pm Post subject: |
|
|
Ok I switched to the most basic example in the documentation:
Code: |
require_once("Smarty-3.1.7/libs/Smarty.class.php");
$smarty = new Smarty;
$smarty->setCaching(true);
// set a separate cache_id for each unique URL
$cache_id = md5($_SERVER['REQUEST_URI']);
// capture the output
if ( !is_readable("structure.tpl") ) { echo "not readable"; }
$output = $smarty->fetch('structure.tpl', $cache_id);
// do something with $output here
echo $output;
|
It still gives the same error:
"Fatal error: Class '_smarty_template_buffer' not found in [...]Smarty-3.1.7/libs/sysplugins/smarty_internal_templateparser.php on line 117
No other errors are shown (which means in this case that smarty is loaded succesfully and template is readable).
Please help!
[/code] |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Feb 07, 2012 7:34 pm Post subject: |
|
|
I have still no glue what is ging on.
Class '_smarty_template_buffer' is defined in file smarty_internal_parsetree.php which is included in file smarty_internal_smartytemplatecompiler.php line 15.
smarty_internal_smartytemplatecompiler.php is the same file which calls the template parser which drops the error.
For a test include the following code after line 15 in smarty_internal_smartytemplatecompiler.php
Quote: | if (class_exists('_smarty_template_buffer')) {
echo 'class defined ';
} else {
echo 'class not defined ';
} |
It should output 'class defined'. |
|
Back to top |
|
xilentxage Smarty Rookie
Joined: 25 Oct 2010 Posts: 15
|
Posted: Tue Feb 07, 2012 8:17 pm Post subject: |
|
|
U.Tews wrote: | It should output 'class defined'. |
it does |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Feb 07, 2012 8:41 pm Post subject: |
|
|
why should same class be unknown a bit later in the parser, no glue... |
|
Back to top |
|
xilentxage Smarty Rookie
Joined: 25 Oct 2010 Posts: 15
|
Posted: Tue Feb 07, 2012 9:17 pm Post subject: |
|
|
U.Tews wrote: | why should same class be unknown a bit later in the parser, no glue... |
I do. I guess because caching was on it still gave the same error with the example code. But what I didnt notice last time is that under "class defined" no error appeared.
In other words: When I use the example code Smarty works fine. When I switch back the error is back, and it also says "class not defined". I guess by replacing example code with my own code step by step I should be able to pinpoint the problem. I'll reply when I find it. thnx so far! |
|
Back to top |
|
xilentxage Smarty Rookie
Joined: 25 Oct 2010 Posts: 15
|
Posted: Tue Feb 07, 2012 9:24 pm Post subject: |
|
|
Examplecode from http://www.smarty.net/docs/en/api.fetch.tpl
Code: |
include('Smarty.class.php');
$smarty = new Smarty;
$smarty->setCaching(true);
// set a separate cache_id for each unique URL
$cache_id = md5($_SERVER['REQUEST_URI']);
// capture the output
$output = $smarty->fetch('index.tpl', $cache_id);
// do something with $output here
echo $output;
|
When I change setCaching to false the error occurs. Any clues now? [/b] |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Feb 07, 2012 9:40 pm Post subject: |
|
|
You should once delete all existing compiled and cache files to start with a clean system. Maybe the error message got into these files as output somehow.
Do you see same error if you set $smarty->force_compile = true? |
|
Back to top |
|
xilentxage Smarty Rookie
Joined: 25 Oct 2010 Posts: 15
|
Posted: Tue Feb 07, 2012 10:02 pm Post subject: |
|
|
deleted both compile- and cache dir. Now using the following code:
Code: |
include('Smarty.class.php');
$smarty = new Smarty;
$smarty->setCaching(false);
$smarty->force_compile = true;
// set a separate cache_id for each unique URL
$cache_id = md5($_SERVER['REQUEST_URI']);
// capture the output
$output = $smarty->fetch('index.tpl', $cache_id);
// do something with $output here
echo $output;
|
Still gives:
class not defined
Fatal error: Class '_smarty_template_buffer' not found in /[...]/Smarty-3.1.7/libs/sysplugins/smarty_internal_templateparser.php on line 117 |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Feb 07, 2012 10:40 pm Post subject: |
|
|
We have never seen such problem before. Something must be screwed up in your system.
Try a complete new installation of Smarty. I have no other idea.... |
|
Back to top |
|
|