From 80ee385965ea642fbe871bab9c1e7b19f02b1b89 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Mon, 3 Aug 2015 22:32:09 +0200 Subject: [PATCH] - improve getIncludePath() to return directory i --- change_log.txt | 1 + .../smarty_internal_get_include_path.php | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/change_log.txt b/change_log.txt index f3721e28..3340af17 100644 --- a/change_log.txt +++ b/change_log.txt @@ -2,6 +2,7 @@ 03.08.2015 - rework clear cache methods - bugfix compileAllConfig() was broken since 3.1.22 because of the changes in config file processing + - improve getIncludePath() to return directory if no file was given 02.08.2015 - optimization and code cleanup of {foreach} and {section} compiler diff --git a/libs/sysplugins/smarty_internal_get_include_path.php b/libs/sysplugins/smarty_internal_get_include_path.php index 0b0da79f..9858d403 100644 --- a/libs/sysplugins/smarty_internal_get_include_path.php +++ b/libs/sysplugins/smarty_internal_get_include_path.php @@ -160,9 +160,9 @@ class Smarty_Internal_Get_Include_Path $_u_dir = self::$_user_dirs[$dir_n] = $dir; } } - $_d_path = $_u_dir . (isset($file) ? $file : ''); if (self::$_has_stream_include) { // available since PHP 5.3.2 + $_d_path = $_u_dir . (isset($file) ? $file : ''); self::$stream[$_d_path] = isset(self::$stream[$_d_path]) ? self::$stream[$_d_path] : ($path = stream_resolve_include_path($_d_path)) ? is_file($path) : false; if (self::$stream[$_d_path]) { return self::$isFile[$dir_n][$file] = self::$stream[$_d_path]; @@ -172,9 +172,17 @@ class Smarty_Internal_Get_Include_Path $path = self::$isPath[$key][$dir_n] = isset(self::$isPath[$key][$dir_n]) ? self::$isPath[$key][$dir_n] : is_dir($_i_path . $_u_dir) ? $_i_path . substr($_u_dir, 2) : false; - $_file = self::$isFile[$dir_n][$file] = ($path && is_file($path . $file)) ? $path . $file : false; - if ($_file) { - return $_file; + if ($path === false) { + continue; + } + if (isset($file)) { + $_file = self::$isFile[$dir_n][$file] = ($path && is_file($path . $file)) ? $path . $file : false; + if ($_file) { + return $_file; + } + } else { + // no file was given return directory path + return $path; } } }