Skip to content

Commit

Permalink
Do not use obsolete smarty properties '_dir_perms', '_file_perms', 'p…
Browse files Browse the repository at this point in the history
…lugin_search_order' in our own code.
  • Loading branch information
wisskid committed Jul 16, 2022
1 parent 382d663 commit d17b3d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
17 changes: 5 additions & 12 deletions libs/sysplugins/smarty_internal_runtime_writefile.php
Expand Up @@ -29,20 +29,15 @@ public function writeFile($_filepath, $_contents, Smarty $smarty)
{
$_error_reporting = error_reporting();
error_reporting($_error_reporting & ~E_NOTICE & ~E_WARNING);
$_file_perms = property_exists($smarty, '_file_perms') ? $smarty->_file_perms : 0644;
$_dir_perms =
property_exists($smarty, '_dir_perms') ? (isset($smarty->_dir_perms) ? $smarty->_dir_perms : 0777) : 0771;
if ($_file_perms !== null) {
$old_umask = umask(0);
}
$old_umask = umask(0);
$_dirpath = dirname($_filepath);
// if subdirs, create dir structure
if ($_dirpath !== '.') {
$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)) {
if (@mkdir($_dirpath, 0771, true)) {
break;
}
clearstatcache();
Expand Down Expand Up @@ -89,11 +84,9 @@ public function writeFile($_filepath, $_contents, Smarty $smarty)
error_reporting($_error_reporting);
throw new SmartyException("unable to write file {$_filepath}");
}
if ($_file_perms !== null) {
// set file permissions
chmod($_filepath, $_file_perms);
umask($old_umask);
}
// set file permissions
chmod($_filepath, 0644);
umask($old_umask);
error_reporting($_error_reporting);
return true;
}
Expand Down
3 changes: 0 additions & 3 deletions libs/sysplugins/smarty_internal_templatecompilerbase.php
Expand Up @@ -422,9 +422,6 @@ public function compileTemplateSource(
try {
// save template object in compiler class
$this->template = $template;
if (property_exists($this->template->smarty, 'plugin_search_order')) {
$this->plugin_search_order = $this->template->smarty->plugin_search_order;
}
if ($this->smarty->debugging) {
if (!isset($this->smarty->_debug)) {
$this->smarty->_debug = new Smarty_Internal_Debug();
Expand Down

0 comments on commit d17b3d8

Please sign in to comment.