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

Wondering about this error

 
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 -> General
View previous topic :: View next topic  
Author Message
appel
Smarty Rookie


Joined: 27 May 2003
Posts: 29

PostPosted: Mon Jun 23, 2003 4:56 pm    Post subject: Wondering about this error Reply with quote

I get the following error when I do:
Code:
$smarty->display("index.tpl");


assigned template variables:
{$system} Array (1)
error => Array (4)
msg => Undefined offset: 0
code => 8
file => /usr/local/share/smarty/Smarty_Compil...
line => 1266


However, when I do:
Code:
$smarty->fetch("index.tpl");

The error goes away.

I have a {$system.module.name} variables in my template, but I process all those variables in PHP before I do the display() part with register_prefilter().
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Jun 25, 2003 5:24 am    Post subject: Reply with quote

What happens if you clear out your compiled templates and run the test the other way -- first do the fetch test then do the display test. Same thing or has the error sequence been swapped?
Back to top
View user's profile Send private message
appel
Smarty Rookie


Joined: 27 May 2003
Posts: 29

PostPosted: Thu Jun 26, 2003 2:06 pm    Post subject: Reply with quote

boots wrote:
What happens if you clear out your compiled templates and run the test the other way -- first do the fetch test then do the display test. Same thing or has the error sequence been swapped?


No, that's not it. This error only occurs when display() is used. I have managed to re-produce this error using this code:

index.php
Code:
<?
include("Smarty.class.php");
$smarty = new Smarty;

// Raise an error and kill script.
function RaiseError($errno, $errstr, $errfile, $errline) {
   // Define array to assign to smarty.
   $arrSystem["error"]["msg"] = $errstr;
   $arrSystem["error"]["code"] = $errno;
   $arrSystem["error"]["file"] = $errfile;
   $arrSystem["error"]["line"] = $errline;

   // Assign smarty variables.
   $GLOBALS["smarty"]->assign("system",$arrSystem);

   // Display the template.
   $GLOBALS["smarty"]->display("error.tpl");

   // Kill execution of script.
   exit;
}

set_error_handler("RaiseError");



$smarty->force_compile = true;
$smarty->debugging = true;
$system["module"]["test"] = "whatever";
$smarty->assign("system",$system);
$smarty->display("index.tpl");
?>


templates/index.tpl
Code:
<html>
<body>
this is {$system.module.test}
</body>
</html>


templates/error.tpl
Code:
<table border="1" cellpadding="4" cellspacing="0">
<tr bgcolor="#c0c0c0">
<td align="center"><big><b>An error has occured!</b></big></td>
</tr>

<tr bgcolor="#efefef">
<td>
The following error was found while processing this page:<br /><br />
<b>Error message:</b> {$system.error.msg}<br />
<b>Error code:</b> {$system.error.code}<br />
<b>In file:</b> {$system.error.file}<br />
<b>On line:</b> {$system.error.line}<br />
<br />
Please report this error to the system administrator.
</td>
</tr>
</table>



The errors I get are:

In debug pop-up window I get:
Code:
assigned template variables:
{$SCRIPT_NAME} /test/index.php
{$system} Array (1)
error => Array (4)
  msg => Undefined offset: 0
  code => 8
  file => /usr/local/share/smarty/Smarty_Compil...
  line => 1266


From the default error handler I get:
Code:

An error has occured!
The following error was found while processing this page:

Error message: Undefined offset: 0
Error code: 8
In file: /usr/local/share/smarty/Smarty_Compiler.class.php
On line: 1266

Please report this error to the system administrator
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 -> General 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