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

template_exists('file:foo.tpl') fails

 
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
c960657
Smarty Regular


Joined: 07 May 2003
Posts: 75
Location: Copenhagen, Denmark

PostPosted: Mon Feb 16, 2004 10:37 am    Post subject: template_exists('file:foo.tpl') fails Reply with quote

Calling $smarty_obj->template_exists('file:foo.tpl'), i.e. with an explicit 'file:' resource type, yields a PHP warning when the file foo.tpl does not exist:

Warning: filemtime(): Stat failed for /home/dr/www/xxx/templates/filter/default.tpl (errno=2 - No such file or directory) in /home/dr/www/smarty/Smarty.class.php on line 1572

In Smarty.class.php the lines 1571-1572 currently read:
Code:
  $params['resource_timestamp'] = filemtime($_resource_name);
  $_return = is_file($_resource_name);


This should be changed to something like
Code:
  $_return = is_file($_resource_name);
  $params['resource_timestamp'] = $_return ? filemtime($_resource_name) : null;

to make sure that filemtime() is only called when the file actually exists.
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Feb 24, 2004 10:23 pm    Post subject: Reply with quote

Thanks for pointing this out!

my fix looks a bit different:
Code:
Index: libs/Smarty.class.php
===================================================================
RCS file: /repository/smarty/libs/Smarty.class.php,v
retrieving revision 1.478
diff -u -r1.478 Smarty.class.php
--- libs/Smarty.class.php       23 Feb 2004 23:14:40 -0000      1.478
+++ libs/Smarty.class.php       24 Feb 2004 22:17:33 -0000
@@ -1665,6 +1665,9 @@
                     }
                 }
                 return false;
+            } else {
+                /* absolute path */
+                return file_exists($params['resource_name']);
             }
         } elseif (empty($this->_plugins['resource'][$params['resource_type']])) {
             $_params = array('type' => $params['resource_type']);


But it should fix the problem. If you like, please volunteer to test the CVS-version.

greetings
messju
Back to top
View user's profile Send private message Send e-mail Visit poster's website
c960657
Smarty Regular


Joined: 07 May 2003
Posts: 75
Location: Copenhagen, Denmark

PostPosted: Wed Feb 25, 2004 10:16 am    Post subject: Reply with quote

messju wrote:
my fix looks a bit different

It appears to solve my problem as well - thanks Smile
Back to top
View user's profile Send private message Visit poster's website
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