diff --git a/change_log.txt b/change_log.txt index 90549c0c..016322c9 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== Smarty 3.1 trunk ===== +21.09.2011 +- bugfix look for mixed case plugin file names as in 3.0 if not found try all lowercase + 20.09.2011 - bugfix removed debug echo output while compiling template inheritance - bugfix relative paths in $template_dir broke relative path resolving in {include "../foo.tpl"} diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 194cea12..9ea46041 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -1176,16 +1176,15 @@ class Smarty extends Smarty_Internal_TemplateBase { if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) return true; // Plugin name is expected to be: Smarty_[Type]_[Name] - $_plugin_name = strtolower($plugin_name); - $_name_parts = explode('_', $_plugin_name, 3); + $_name_parts = explode('_', $plugin_name, 3); // class name must have three parts to be valid plugin - if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') { + if (count($_name_parts) < 3 || strtolower($_name_parts[0]) !== 'smarty') { throw new SmartyException("plugin {$plugin_name} is not a valid name format"); return false; } // if type is "internal", get plugin from sysplugins - if ($_name_parts[1] == 'internal') { - $file = SMARTY_SYSPLUGINS_DIR . $_plugin_name . '.php'; + if (strtolower($_name_parts[1]) == 'internal') { + $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php'; if (file_exists($file)) { require_once($file); return $file; @@ -1197,17 +1196,21 @@ class Smarty extends Smarty_Internal_TemplateBase { $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php"; // loop through plugin dirs and find the plugin foreach($this->getPluginsDir() as $_plugin_dir) { - $file = $_plugin_dir . $_plugin_filename; - if (file_exists($file)) { - require_once($file); - return $file; - } - if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) { - // try PHP include_path - if (($file = Smarty_Internal_Get_Include_Path::getIncludePath($file)) !== false) { + $names = array(); + $names[] = $_plugin_dir . $_plugin_filename; + $names[] = $_plugin_dir . strtolower($_plugin_filename); + foreach ($names as $file) { + if (file_exists($file)) { require_once($file); return $file; } + if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) { + // try PHP include_path + if (($file = Smarty_Internal_Get_Include_Path::getIncludePath($file)) !== false) { + require_once($file); + return $file; + } + } } } // no plugin loaded