Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
First view/request generates unlink error

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
gzom-spam
Smarty Rookie


Joined: 06 Jul 2012
Posts: 11

PostPosted: Fri Jul 06, 2012 6:23 pm    Post subject: First view/request generates unlink error Reply with quote

Hi All,

I have a big problem with my app and smarty, but i will shorten it to example below.
My configuration is:
- smarty v 3.1.10
- xamp v 1.7.3
- php v 5.3.1
- windows xp with sp3

Like in subject when I want to display a template then on first request I have an error:
Quote:
Code:2, Message:unlink(c:\xampp\htdocs\ajax_smarty\templates_c\3b16de6736e2c828b29066610d68a9bc8ae0920e.file.abc.tpl.php) [function.unlink]: No such file or directory, File:C:\xampp\php\smarty\libs\sysplugins\smarty_internal_write_file.php, Line No:57"

And the second request is without error.
All the above also applies to Ajax POST request.

My code looks like this:
Main file: index.php
Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML>
   <HEAD>
      
      <TITLE>Ajax Smarty Test</TITLE>
      <script TYPE="text/javascript" language="JavaScript" src="http://localhost/ajax_smarty/ajax.js"></script>
</HEAD>

<BODY LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BOTTOMMARGIN="0">


<?PHP

try
{
   require_once('Smarty.class.php'); // load Smarty library
   $smarty = new Smarty();
   $smarty->template_dir = 'views/';
   $smarty->config_dir = 'config/';
   $smarty->cache_dir = 'cache/';
   $smarty->compile_dir = 'c:\\xampp\\htdocs\\ajax_smarty\\templates_c\\';

   $smarty->assign('empty', 'nothing');
   var_dump($_POST);
   if (isset($_POST['a']) && $_POST['a']==1)
   {
      echo "fetch<br>";
      $smarty->fetch('abc.tpl');
   }
   else
   {
      echo "display<br>";
      $smarty->display('abc.tpl');
   }


   $aError = error_get_last();
   if(!is_null($aError))
      throw new Exception('Error 404 for AJAX action:'.$_inducedAction.'; Code:'.$aError['type'].', Message:'.$aError['message'].', File:'.$aError['file'].', Line No:'.$aError['line']);
   unset($aError);
}
catch (Exception $e)
{
   echo "\nERROR:<br><pre>";
   var_dump($e);
   echo "</pre>";
}

?>

<INPUT TYPE="button" ID="submit_form" NAME="submit_form" VALUE="SEND" onclick="AjaxPostRequest('http://localhost/ajax_smarty/index.php', 'a=1', 'alert');">
<BODY>


Template: abc.tpl
Code:

test ajax_smarty: template abc<br>
variable = {$empty}


Sorry for my English, but it's not my mother tongue.

Best for All,
and thanks in advance for any try to help,
Gzom
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 698
Location: Germany, border to Switzerland

PostPosted: Sat Jul 07, 2012 8:17 am    Post subject: Reply with quote

Have a look at muteExpectedErrors() and possibly read Improving DIsk I/O in PHP Apps
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
gzom-spam
Smarty Rookie


Joined: 06 Jul 2012
Posts: 11

PostPosted: Sat Jul 07, 2012 8:39 am    Post subject: Reply with quote

Hi,

Thanks rodneyrehm for reply.
I'm reading those articles, but in meanwhile could you explain me why smarty deliberately generates warnings or notices?

Best,
Gzom
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 698
Location: Germany, border to Switzerland

PostPosted: Sat Jul 07, 2012 9:08 am    Post subject: Reply with quote

gzom-spam wrote:
I'm reading those articles, but in meanwhile could you explain me why smarty deliberately generates warnings or notices?


I worte Improving DIsk I/O in PHP Apps to do just that.
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
gzom-spam
Smarty Rookie


Joined: 06 Jul 2012
Posts: 11

PostPosted: Sat Jul 07, 2012 10:21 am    Post subject: Reply with quote

Hm...

Unfortunately in my case there should not be "Race Conditions".
Only I run the sample script, and only in one request/view.
Back to top
View user's profile Send private message
gzom-spam
Smarty Rookie


Joined: 06 Jul 2012
Posts: 11

PostPosted: Sat Jul 07, 2012 10:25 am    Post subject: Reply with quote

and also script is running on linux file system or NTFS.
Back to top
View user's profile Send private message
gzom-spam
Smarty Rookie


Joined: 06 Jul 2012
Posts: 11

PostPosted: Sat Jul 07, 2012 4:24 pm    Post subject: Reply with quote

Ok,

Thanks rodneyrehm for muteExpectedErrors() method (which solved my problem), and at least partial explanation what is going on.

Again Thanks Very Much.

Best,
Gzom

P.S. If you could explain why I have this errors even when I should not have race conditions, would be more than great.
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 698
Location: Germany, border to Switzerland

PostPosted: Sat Jul 07, 2012 4:26 pm    Post subject: Reply with quote

It doesn't matter if YOU are prone to race conditions RIGHT NOW. Smarty itself does everything it can to prevent them. always. regardless of your use-case. You don't have to worry about it.
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    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