Skip to content

Commit

Permalink
- bugfix Smarty version was not filled in header comment of compiled …
Browse files Browse the repository at this point in the history
…and cached files
  • Loading branch information
uwetews committed Oct 26, 2017
1 parent 87f260e commit c404294
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
3 changes: 3 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
===== 3.1.32 - dev ===
26.10.2017 3.1.32-dev-28
- bugfix Smarty version was not filled in header comment of compiled and cached files

21.10.2017
- bugfix custom delimiters could fail since modification of version 3.1.32-dev-23
https://github.com/smarty-php/smarty/issues/394
Expand Down
30 changes: 12 additions & 18 deletions libs/sysplugins/smarty_internal_runtime_writefile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* @subpackage PluginsInternal
* @author Monte Ohrt
*/

/**
* Smarty Internal Write File Class
*
Expand Down Expand Up @@ -35,34 +34,30 @@ public function writeFile($_filepath, $_contents, Smarty $smarty)
if ($_file_perms !== null) {
$old_umask = umask(0);
}

$_dirpath = dirname($_filepath);

// if subdirs, create dir structure
// if subdirs, create dir structure
if ($_dirpath !== '.') {
$i=0;
$i = 0;
// loop if concurrency problem occurs
// see https://bugs.php.net/bug.php?id=35326
while (!is_dir($_dirpath)) {
if (@mkdir($_dirpath, $_dir_perms, true)) {
break;
}
clearstatcache();
if (++$i === 3) {
error_reporting($_error_reporting);
throw new SmartyException("unable to create directory {$_dirpath}");
}
sleep(1);
if (@mkdir($_dirpath, $_dir_perms, true)) {
break;
}
clearstatcache();
if (++$i === 3) {
error_reporting($_error_reporting);
throw new SmartyException("unable to create directory {$_dirpath}");
}
sleep(1);
}
}

// write to tmp file, then move to overt file lock race condition
$_tmp_file = $_dirpath . $smarty->ds . str_replace(array('.', ','), '_', uniqid('wrt', true));
$_tmp_file = $_dirpath . DIRECTORY_SEPARATOR . str_replace(array('.', ','), '_', uniqid('wrt', true));
if (!file_put_contents($_tmp_file, $_contents)) {
error_reporting($_error_reporting);
throw new SmartyException("unable to write file {$_tmp_file}");
}

/*
* Windows' rename() fails if the destination exists,
* Linux' rename() properly handles the overwrite.
Expand Down Expand Up @@ -99,7 +94,6 @@ public function writeFile($_filepath, $_contents, Smarty $smarty)
umask($old_umask);
}
error_reporting($_error_reporting);

return true;
}
}

0 comments on commit c404294

Please sign in to comment.