PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.smarty.general > windows problem with loads of *.tmp files
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
windows problem with loads of *.tmp files

Réponse
 
LinkBack Outils de la discussion
Vieux 30/01/2006, 11h20   #1
Jochem Maas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Re: windows problem with loads of *.tmp files - MOREinfo

Pedro wrote:
> its Smarty-2.1.12
>
> There are 6 templatess and therefore six compile files..
>
> However each time I "refresh" another 6 *.tmp files appear (as I have
> force_compile on).
>
> this is confusing !


sounds like the OS is not allowing smarty to delete it's own tmp files.

>
> pete
>
>
> Pedro wrote:
>
>> I've setting up a site using Smarty on windows/IIS/fast-cgi.
>>
>> There is a shared smartty compile dir .. However this firectory is
>> filles up with zero length files with the format wrtXXXX.tmp where
>> XXXX is a four digit number
>>
>> HAve no inkling why this is happening.. and it seems strange its in
>> the SMarty dir ??
>>
>> here's the code for the configuration
>>
>> define('SITE_KEY','bias_va');
>>
>> define('SMARTY_DIR', SITE_ROOT.'/libs/Smarty-2.6.12/libs/');
>> require_once(SMARTY_DIR.'Smarty.class.php');
>> $smarty = new Smarty();
>> $smarty->debugging = true; // only on test server
>>
>> //** smarty compile
>> $smarty->force_compile = true; //( SERVER_NAME == DEV_SERVER );
>> // only on test server
>> $smarty->compile_check = true;
>> $smarty->compile_id = SITE_KEY;
>> $smarty->compile_dir = SITE_ROOT.'/smarty_compile_dir';
>> $smarty->use_sub_dirs = false; //f&*( windows
>>
>>
>>
>> any idea
>> Pete

>
>

  Réponse avec citation
Vieux 30/01/2006, 11h54   #2
Pedro
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut windows problem with loads of *.tmp files

I've setting up a site using Smarty on windows/IIS/fast-cgi.

There is a shared smartty compile dir .. However this firectory is
filles up with zero length files with the format wrtXXXX.tmp where XXXX
is a four digit number

HAve no inkling why this is happening.. and it seems strange its in the
SMarty dir ??

here's the code for the configuration

define('SITE_KEY','bias_va');

define('SMARTY_DIR', SITE_ROOT.'/libs/Smarty-2.6.12/libs/');
require_once(SMARTY_DIR.'Smarty.class.php');
$smarty = new Smarty();
$smarty->debugging = true; // only on test server

//** smarty compile
$smarty->force_compile = true; //( SERVER_NAME == DEV_SERVER ); //
only on test server
$smarty->compile_check = true;
$smarty->compile_id = SITE_KEY;
$smarty->compile_dir = SITE_ROOT.'/smarty_compile_dir';
$smarty->use_sub_dirs = false; //f&*( windows



any idea
Pete
  Réponse avec citation
Vieux 30/01/2006, 12h04   #3
Pedro
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: windows problem with loads of *.tmp files - MORE info

its Smarty-2.1.12

There are 6 templatess and therefore six compile files..

However each time I "refresh" another 6 *.tmp files appear (as I have
force_compile on).

this is confusing !

pete


Pedro wrote:
> I've setting up a site using Smarty on windows/IIS/fast-cgi.
>
> There is a shared smartty compile dir .. However this firectory is
> filles up with zero length files with the format wrtXXXX.tmp where XXXX
> is a four digit number
>
> HAve no inkling why this is happening.. and it seems strange its in the
> SMarty dir ??
>
> here's the code for the configuration
>
> define('SITE_KEY','bias_va');
>
> define('SMARTY_DIR', SITE_ROOT.'/libs/Smarty-2.6.12/libs/');
> require_once(SMARTY_DIR.'Smarty.class.php');
> $smarty = new Smarty();
> $smarty->debugging = true; // only on test server
>
> //** smarty compile
> $smarty->force_compile = true; //( SERVER_NAME == DEV_SERVER ); //
> only on test server
> $smarty->compile_check = true;
> $smarty->compile_id = SITE_KEY;
> $smarty->compile_dir = SITE_ROOT.'/smarty_compile_dir';
> $smarty->use_sub_dirs = false; //f&*( windows
>
>
>
> any idea
> Pete

  Réponse avec citation
Vieux 30/01/2006, 14h56   #4
Jan Rosier
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Re: windows problem with loads of *.tmp files - MOREinfo

I think the problem is in the file libs/internals/core.write_file.php.
Try the patched version attached to this mail.

Here is what I think is happening:
At line 28 an temp file is created, then at line 30 this file is opened
for writing.
If opening the temp file fails Smarty will try to create a temp file
using uniqid() (line 31)
But the temp file already created at line 28 isn't removed first.

I also attached a diff to the last version that is in the cvs.

Greetings,
Jan Rosier



Jochem Maas wrote:
> Pedro wrote:
>> its Smarty-2.1.12
>>
>> There are 6 templatess and therefore six compile files..
>>
>> However each time I "refresh" another 6 *.tmp files appear (as I have
>> force_compile on).
>>
>> this is confusing !

>
> sounds like the OS is not allowing smarty to delete it's own tmp files.
>
>>
>> pete
>>
>>
>> Pedro wrote:
>>
>>> I've setting up a site using Smarty on windows/IIS/fast-cgi.
>>>
>>> There is a shared smartty compile dir .. However this firectory is
>>> filles up with zero length files with the format wrtXXXX.tmp where
>>> XXXX is a four digit number
>>>
>>> HAve no inkling why this is happening.. and it seems strange its in
>>> the SMarty dir ??
>>>
>>> here's the code for the configuration
>>>
>>> define('SITE_KEY','bias_va');
>>>
>>> define('SMARTY_DIR', SITE_ROOT.'/libs/Smarty-2.6.12/libs/');
>>> require_once(SMARTY_DIR.'Smarty.class.php');
>>> $smarty = new Smarty();
>>> $smarty->debugging = true; // only on test server
>>>
>>> //** smarty compile
>>> $smarty->force_compile = true; //( SERVER_NAME == DEV_SERVER );
>>> // only on test server
>>> $smarty->compile_check = true;
>>> $smarty->compile_id = SITE_KEY;
>>> $smarty->compile_dir = SITE_ROOT.'/smarty_compile_dir';
>>> $smarty->use_sub_dirs = false; //f&*( windows
>>>
>>>
>>>
>>> any idea
>>> Pete

>>
>>

>


30a31,33
> if (file_exists($_tmp_file)) {
> @unlink($_tmp_file);
> }


  Réponse avec citation
Vieux 30/01/2006, 16h12   #5
Jan Rosier
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Re: windows problem with loads of *.tmp files - MOREinfo

The attached php file got lost. This time the file is attached as text
file. Hope this works...

Greetings,
Jan Rosier


Jan Rosier wrote:
> I think the problem is in the file libs/internals/core.write_file.php.
> Try the patched version attached to this mail.
>
> Here is what I think is happening:
> At line 28 an temp file is created, then at line 30 this file is
> opened for writing.
> If opening the temp file fails Smarty will try to create a temp file
> using uniqid() (line 31)
> But the temp file already created at line 28 isn't removed first.
>
> I also attached a diff to the last version that is in the cvs.
>
> Greetings,
> Jan Rosier
>
>


<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/

/**
* write out a file to disk
*
* @param string $filename
* @param string $contents
* @param boolean $create_dirs
* @return boolean
*/
function smarty_core_write_file($params, &$smarty)
{
$_dirname = dirname($params['filename']);

if ($params['create_dirs']) {
$_params = array('dir' => $_dirname);
require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php');
smarty_core_create_dir_structure($_params, $smarty);
}

// write to tmp file, then rename it to avoid
// file locking race condition
$_tmp_file = tempnam($_dirname, 'wrt');

if (!($fd = @fopen($_tmp_file, 'wb'))) {
if (file_exists($_tmp_file)) {
@unlink($_tmp_file);
}
$_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
if (!($fd = @fopen($_tmp_file, 'wb'))) {
$smarty->trigger_error("problem writing temporary file '$_tmp_file'");
return false;
}
}

fwrite($fd, $params['contents']);
fclose($fd);

// Delete the file if it allready exists (this is needed on Win,
// because it cannot overwrite files with rename()
if (file_exists($params['filename'])) {
@unlink($params['filename']);
}
@rename($_tmp_file, $params['filename']);
@chmod($params['filename'], $smarty->_file_perms);

return true;
}

/* vim: set expandtab: */

?>

  Réponse avec citation
Vieux 31/01/2006, 08h41   #6
Jan Rosier
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Re: windows problem with loads of *.tmp files - MOREinfo

Try removing the @ from the code. So @fopen becomes fopen and so on.
See if PHP reports any errors after you do this.

To make sure error reporting is on you can add the following lines to
the code:

ini_set('display_errors', 1);
error_reporting(E_ALL);

Greetings,
Jan Rosier



Pedro wrote:
> Didnt make any difference .. not sure what is happening ""
>
> pete
>
> Jan Rosier wrote:
>> The attached php file got lost. This time the file is attached as
>> text file. Hope this works...
>>
>> Greetings,
>> Jan Rosier
>>
>>
>> Jan Rosier wrote:
>>
>>> I think the problem is in the file
>>> libs/internals/core.write_file.php. Try the patched version attached
>>> to this mail.
>>>
>>> Here is what I think is happening:
>>> At line 28 an temp file is created, then at line 30 this file is
>>> opened for writing.
>>> If opening the temp file fails Smarty will try to create a temp file
>>> using uniqid() (line 31)
>>> But the temp file already created at line 28 isn't removed first.
>>>
>>> I also attached a diff to the last version that is in the cvs.
>>>
>>> Greetings,
>>> Jan Rosier
>>>
>>>

>>
>> ------------------------------------------------------------------------
>>
>> <?php
>> /**
>> * Smarty plugin
>> * @package Smarty
>> * @subpackage plugins
>> */
>>
>> /**
>> * write out a file to disk
>> *
>> * @param string $filename
>> * @param string $contents
>> * @param boolean $create_dirs
>> * @return boolean
>> */
>> function smarty_core_write_file($params, &$smarty)
>> {
>> $_dirname = dirname($params['filename']);
>>
>> if ($params['create_dirs']) {
>> $_params = array('dir' => $_dirname);
>> require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php');
>> smarty_core_create_dir_structure($_params, $smarty);
>> }
>>
>> // write to tmp file, then rename it to avoid
>> // file locking race condition
>> $_tmp_file = tempnam($_dirname, 'wrt');
>>
>> if (!($fd = @fopen($_tmp_file, 'wb'))) {
>> if (file_exists($_tmp_file)) {
>> @unlink($_tmp_file);
>> }
>> $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
>> if (!($fd = @fopen($_tmp_file, 'wb'))) {
>> $smarty->trigger_error("problem writing temporary file
>> '$_tmp_file'");
>> return false;
>> }
>> }
>>
>> fwrite($fd, $params['contents']);
>> fclose($fd);
>>
>> // Delete the file if it allready exists (this is needed on Win,
>> // because it cannot overwrite files with rename()
>> if (file_exists($params['filename'])) {
>> @unlink($params['filename']);
>> }
>> @rename($_tmp_file, $params['filename']);
>> @chmod($params['filename'], $smarty->_file_perms);
>>
>> return true;
>> }
>>
>> /* vim: set expandtab: */
>>
>> ?>

>

  Réponse avec citation
Vieux 31/01/2006, 08h47   #7
Pedro
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Re: windows problem with loads of *.tmp files - MOREinfo

Didnt make any difference .. not sure what is happening ""

pete

Jan Rosier wrote:
> The attached php file got lost. This time the file is attached as text
> file. Hope this works...
>
> Greetings,
> Jan Rosier
>
>
> Jan Rosier wrote:
>
>> I think the problem is in the file libs/internals/core.write_file.php.
>> Try the patched version attached to this mail.
>>
>> Here is what I think is happening:
>> At line 28 an temp file is created, then at line 30 this file is
>> opened for writing.
>> If opening the temp file fails Smarty will try to create a temp file
>> using uniqid() (line 31)
>> But the temp file already created at line 28 isn't removed first.
>>
>> I also attached a diff to the last version that is in the cvs.
>>
>> Greetings,
>> Jan Rosier
>>
>>

>
> ------------------------------------------------------------------------
>
> <?php
> /**
> * Smarty plugin
> * @package Smarty
> * @subpackage plugins
> */
>
> /**
> * write out a file to disk
> *
> * @param string $filename
> * @param string $contents
> * @param boolean $create_dirs
> * @return boolean
> */
> function smarty_core_write_file($params, &$smarty)
> {
> $_dirname = dirname($params['filename']);
>
> if ($params['create_dirs']) {
> $_params = array('dir' => $_dirname);
> require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php');
> smarty_core_create_dir_structure($_params, $smarty);
> }
>
> // write to tmp file, then rename it to avoid
> // file locking race condition
> $_tmp_file = tempnam($_dirname, 'wrt');
>
> if (!($fd = @fopen($_tmp_file, 'wb'))) {
> if (file_exists($_tmp_file)) {
> @unlink($_tmp_file);
> }
> $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
> if (!($fd = @fopen($_tmp_file, 'wb'))) {
> $smarty->trigger_error("problem writing temporary file '$_tmp_file'");
> return false;
> }
> }
>
> fwrite($fd, $params['contents']);
> fclose($fd);
>
> // Delete the file if it allready exists (this is needed on Win,
> // because it cannot overwrite files with rename()
> if (file_exists($params['filename'])) {
> @unlink($params['filename']);
> }
> @rename($_tmp_file, $params['filename']);
> @chmod($params['filename'], $smarty->_file_perms);
>
> return true;
> }
>
> /* vim: set expandtab: */
>
> ?>

  Réponse avec citation
Vieux 02/02/2006, 12h57   #8
Pedro
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Re: windows problem with loads of *.tmp files - MOREinfo

SO php can delete the actual compiled templates..

but not any *.tmp files

notice that the path is the compile_dir ... coud this not be the
$_ENV['tmp'] directory ??

current:
$_tmp_file = tempnam($_dirname, 'wrt');
suggested
$_tmp_file = tempnam($_ENV['tmp'], 'wrt');

Still banging my head against wall !!

regards

Pete

Jan Rosier wrote:
> Try removing the @ from the code. So @fopen becomes fopen and so on.
> See if PHP reports any errors after you do this.
>
> To make sure error reporting is on you can add the following lines to
> the code:
>
> ini_set('display_errors', 1);
> error_reporting(E_ALL);
>
> Greetings,
> Jan Rosier
>
>
>
> Pedro wrote:
>
>> Didnt make any difference .. not sure what is happening ""
>>
>> pete
>>
>> Jan Rosier wrote:
>>
>>> The attached php file got lost. This time the file is attached as
>>> text file. Hope this works...
>>>
>>> Greetings,
>>> Jan Rosier
>>>
>>>
>>> Jan Rosier wrote:
>>>
>>>> I think the problem is in the file
>>>> libs/internals/core.write_file.php. Try the patched version attached
>>>> to this mail.
>>>>
>>>> Here is what I think is happening:
>>>> At line 28 an temp file is created, then at line 30 this file is
>>>> opened for writing.
>>>> If opening the temp file fails Smarty will try to create a temp file
>>>> using uniqid() (line 31)
>>>> But the temp file already created at line 28 isn't removed first.
>>>>
>>>> I also attached a diff to the last version that is in the cvs.
>>>>
>>>> Greetings,
>>>> Jan Rosier
>>>>
>>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> <?php
>>> /**
>>> * Smarty plugin
>>> * @package Smarty
>>> * @subpackage plugins
>>> */
>>>
>>> /**
>>> * write out a file to disk
>>> *
>>> * @param string $filename
>>> * @param string $contents
>>> * @param boolean $create_dirs
>>> * @return boolean
>>> */
>>> function smarty_core_write_file($params, &$smarty)
>>> {
>>> $_dirname = dirname($params['filename']);
>>>
>>> if ($params['create_dirs']) {
>>> $_params = array('dir' => $_dirname);
>>> require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php');
>>> smarty_core_create_dir_structure($_params, $smarty);
>>> }
>>>
>>> // write to tmp file, then rename it to avoid
>>> // file locking race condition
>>> $_tmp_file = tempnam($_dirname, 'wrt');
>>>
>>> if (!($fd = @fopen($_tmp_file, 'wb'))) {
>>> if (file_exists($_tmp_file)) {
>>> @unlink($_tmp_file);
>>> }
>>> $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
>>> if (!($fd = @fopen($_tmp_file, 'wb'))) {
>>> $smarty->trigger_error("problem writing temporary file
>>> '$_tmp_file'");
>>> return false;
>>> }
>>> }
>>>
>>> fwrite($fd, $params['contents']);
>>> fclose($fd);
>>>
>>> // Delete the file if it allready exists (this is needed on Win,
>>> // because it cannot overwrite files with rename()
>>> if (file_exists($params['filename'])) {
>>> @unlink($params['filename']);
>>> }
>>> @rename($_tmp_file, $params['filename']);
>>> @chmod($params['filename'], $smarty->_file_perms);
>>>
>>> return true;
>>> }
>>>
>>> /* vim: set expandtab: */
>>>
>>> ?>

>>
>>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h31.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,20251 seconds with 16 queries