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

smarty 2.6.3 problem

 
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
s!e
Smarty Rookie


Joined: 27 Jan 2004
Posts: 5

PostPosted: Tue Jun 29, 2004 2:55 am    Post subject: smarty 2.6.3 problem Reply with quote

Hi,

I am running my dev server on winxp + php 4.3.7 + iis (isapi) / apache. After upgraded smarty from 2.6.2. to 2.6.3 I see blank pages. compiled page in templates_c is 0 bytes long.

Not even simple...

require($site_root_path. 'libs/smarty/Smarty.class.php');
$smarty = new Smarty;
$smarty->caching = false;
$smarty->compile_check = true;
$smarty->debugging = false;
$smarty->template_dir = '.';
$smarty->compile_dir = './templates_c/';
$smarty->cache_dir = './cache/';

$smarty->display('test.html')

...works.


I'we read in FAQ something that describes this behaviour. Hm. but this is kinda old entry.. don't know what changed so much from 2.6.2 to 2.6.3...

any feedback on this issue?


-- cut --

Q: I'm running Windows 2000 and I get blank content. My compiled PHP files are
also zero length.
A: There seems to be a problem with some W2k machines and exclusive file
locking. Comment out the flock() call in _write_file to get around this,
although be aware this could possibly cause a problem with simultaneous
writes to a file, especially with caching turned on. NOTE: As of Smarty
1.4.0, a workaround was put in place that should solve this.
_________________
---
seven | the witchdoctor
Back to top
View user's profile Send private message
s!e
Smarty Rookie


Joined: 27 Jan 2004
Posts: 5

PostPosted: Wed Jul 07, 2004 1:02 am    Post subject: Reply with quote

hnmm... I had very good opinion about smarty and community around him, but after few days without ANY answer to my bug report, I am starting to have some doubts.

ok, can anybody confirm that smarty 2.6.3 doesn't work on win/php?
_________________
---
seven | the witchdoctor
Back to top
View user's profile Send private message
boots
Administrator


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

PostPosted: Wed Jul 07, 2004 1:13 am    Post subject: Reply with quote

I can confirm that Smarty-2.6.3 works on w2k-sp4/apache-1.3.31/php-4.3.4.

Did you remember to clear out your template_c and cache directories after upgrading? BTW, it is recommended over and over again (especially on windows) to use absolute paths in your setup.

Don't be surprised that the world isn't running to try and fix your problem based on the error you reported. You need to provide more details since the stock installation you provided isn't helpful to people who aren't having your problem.

Another thing, you haven't pin-pointed the problem and we can't be sure yet that this is a Smarty bug--just because it doesn't work for you doesn't mean it is a bug. If anything, this seems (so far) like an installation issue--so please, be patient and try to show that you exhausted all posibilities, especially when posting as a bug report.

Best Regards.
Back to top
View user's profile Send private message
StuWilson
Smarty n00b


Joined: 06 Aug 2004
Posts: 2

PostPosted: Fri Aug 06, 2004 11:35 am    Post subject: Reply with quote

Same issue - but brand new install (PHP 4.3.4, under IIS as ISAPI on WinXp Pro Sp1)

i am a new user of Smarty, never used it before today. The issue that I see is the same, balnk pages and the files created in the cache directory are of 0 byte length.

I've done everything that I've seen suggested in these forums, error_logging is on (always is as a dev system) and no-errors are reported at all, file permsisions are correct, ownership is not an issue.

Either way I am seeing the same issue. Please let me know of any other things to try to give you the information you need to replicate or resolve the isdsue.
Back to top
View user's profile Send private message
StuWilson
Smarty n00b


Joined: 06 Aug 2004
Posts: 2

PostPosted: Fri Aug 06, 2004 11:47 am    Post subject: Reply with quote

backed out to 2.6.2 and the Smarty demo works right out the box,so there would appear to be some issue between 2.6.2 and 2.6.3
Back to top
View user's profile Send private message
messju
Administrator


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

PostPosted: Fri Aug 06, 2004 1:53 pm    Post subject: Reply with quote

see here: http://www.phpinsider.com/smarty-forum/viewtopic.php?p=12790#12790

Smarty-2.6.3 uses tempnam() (http://php.net/tempnam) to create temp-files' names, where Smarty-2.6.2 used uniqid().
Back to top
View user's profile Send private message Send e-mail Visit poster's website
s!e
Smarty Rookie


Joined: 27 Jan 2004
Posts: 5

PostPosted: Fri Aug 06, 2004 2:24 pm    Post subject: Reply with quote

oh my god! i haven't been here for a while. can't believe that it took 4 months to find out where the problem was.

setting iusr account writing perms to windows\temp folder did the trick.

is smarty community falling apart? Crying or Very sad
_________________
---
seven | the witchdoctor
Back to top
View user's profile Send private message
messju
Administrator


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

PostPosted: Fri Aug 06, 2004 3:11 pm    Post subject: Reply with quote

s!e wrote:
is smarty community falling apart? Crying or Very sad


yes, of course it is. please port everything you have to .net immediately Wink


[EDIT: n.b.: your post was from 20040629 - that's 40days not 4 months. stop trolling, please]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Aug 06, 2004 7:31 pm    Post subject: Reply with quote

s!e wrote:
oh my god! i haven't been here for a while. can't believe that it took 4 months to find out where the problem was.


I think you answered your own question right there.
Back to top
View user's profile Send private message Visit poster's website
s!e
Smarty Rookie


Joined: 27 Jan 2004
Posts: 5

PostPosted: Sun Aug 08, 2004 10:44 am    Post subject: Reply with quote

messju wrote:
s!e wrote:
is smarty community falling apart? Crying or Very sad


yes, of course it is. please port everything you have to .net immediately Wink


[EDIT: n.b.: your post was from 20040629 - that's 40days not 4 months. stop trolling, please]



erm .. allright. problem solved. if somebody wrote quick note in 2.6.3 readme file, this conversation would never happened. Laughing


anyhow, I saw the other day on sourceforge 'smarty-lite' library. Anybody from here connected to developement of it?
_________________
---
seven | the witchdoctor
Back to top
View user's profile Send private message
canoramix
Smarty Rookie


Joined: 12 Oct 2003
Posts: 9

PostPosted: Sat Aug 21, 2004 3:19 pm    Post subject: Reply with quote

HI,

I had exactly the same problem in Win2k3/IIS 6.0/PHP 4.3.8: with Smarty 2.6.2 the demo that comes with Smarty works OK, with Smarty 2.6.3 the demo does not work.

I follow the suggestion from messju regarding the tempnam() php function and replace with the uniqid() from 2.6.2 version and it worked OK.

File: Smarty\libs\core\core.write_file.php
The code in version 2.6.3
Code:
Line 28: $_tmp_file = tempnam($_dirname, 'write_');

Replaced by the code from version 2.6.2
Code:
Line 28: $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('');


Now, everything works OK.

BTW, is it possible to reconsider the use of tempnam() in Smarty 2.6.4?

Regards,
Canoramix
Back to top
View user's profile Send private message
messju
Administrator


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

PostPosted: Sat Aug 21, 2004 8:19 pm    Post subject: Reply with quote

someone else on the forum suggested: make sure C:\TEMP is writeable by the webserver user. http://php.net/tempnam says, that the TMP environment variable overrides the dir-parameter of tempnam(). so i guess the pointing TMP to a writable directory (maybe to $smarty->compile_dir) may also help.

canoramix wrote:
BTW, is it possible to reconsider the use of tempnam() in Smarty 2.6.4?


it's neither smarty nor tempnam() that's broken, it's the setup of the users that's broken. i wouldn't resurrect the inferior uniqid() to workaround this.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Gordo
Smarty n00b


Joined: 27 Aug 2004
Posts: 1

PostPosted: Fri Aug 27, 2004 9:29 pm    Post subject: Reply with quote

Question: With regards to using the tempnam function. What about ISP's which have safe_mode or open_base_dir restrictions in effect? Won't this make the usage of Smarty pretty much impossible?

I understand the reasoning behind using the tempnam() function and agree with it. In regards to the suggestion though by messju:

Quote:
i guess the pointing TMP to a writable directory (maybe to $smarty->compile_dir) may also help


Great, so why doesn't this just become the default in Smarty? Create a new variable in Smarty similar to the $smarty->compile_dir variable that users can use to set the directory that the tempnam function will use? For example:

Code:
$smarty->temp_dir = '/web/www.mydomain.com/smarty/guestbook/temp/';


Seems like it would be fairly easy to implement and would allow users that do not have control over thier own servers a little bit more control over this opertation of Smarty while still allowing the usage of the tempnam() function and preventing the race condition.

Just my 2 cents

EDIT: I am working on adding this functionality to Smarty right now and will submit the changes to the Smarty developers when they are complete.

PROBLEM FIXED
---------------------
Ok, I have fixed this problem (AFAIK)... I have added the following code to Smarty_Compiler.class.php right after line 92:

Code:

    /**
     * The directory where temp files will be created.
     *
     * @var string
     */
    var $temp_dir        =  'temp';



Then I also changed line 28 in core.write_file.php to:

Code:

   $_tmp_file = tempnam(realpath($smarty->temp_dir), 'write_');



Then I created a directory called temp in the same directory where my templates, templates_c, cache and config directories are and now everything appears to be working fine even with safe_mode and open_base_dir restrictions turned on.

If you want to move the temp directory to some other location you can call:

Code:
$smarty->temp_dir = 'some_other_dir';


I haven't submitted this simple patch officially to the Smarty developers yet, if everyone thinks I should then I will. Also, I have only tested this on Windows XP and not Linux as my Linux box is at home. I did notice one interesting thing though on my Windows box and I have found posts related to this on php.net. On Windows the tempnam() function will only use the first three characters of the filename parameter so therefore the code:

Code:

   $_tmp_file = tempnam(realpath($smarty->temp_dir), 'write_');



works fine on Windows, but the extra three characters te_ will not be used when creating the temporary files. Regardless of this though everything does appear to be working correctly.

All comments are welcome...

Cheers,
Gordo
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 -> 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