|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
innocenzo Smarty n00b
Joined: 04 Mar 2010 Posts: 4
|
Posted: Thu Mar 04, 2010 1:22 pm Post subject: BUG? $resource_type = strtolower($resource_type); |
|
|
There seems to be a problem loading resources with uppercase characters in its name, for example 'mysqlDB'.
If you register the resource 'mysqlDB' it gets stored as $smarty->_plugins['resource']['mysqlDB'].
But in this function the name gets lowercased:
Code: |
private function getResourceTypeName ($template_resource, &$resource_type, &$resource_name)
{
if (strpos($template_resource, ':') === false) {
// no resource given, use default
$resource_type = $this->smarty->default_resource_type;
$resource_name = $template_resource;
} else {
// get type and name from path
list($resource_type, $resource_name) = explode(':', $template_resource, 2);
if (strlen($resource_type) == 1) {
// 1 char is not resource type, but part of filepath
$resource_type = 'file';
$resource_name = $template_resource;
} else {
$resource_type = strtolower($resource_type);
}
}
}
|
Loading the handler fails because $resource_type is now lowercase. It now tries to load $smarty->_plugins['resource']['mysqldb'].
Code: |
$resource_handler = $this->loadTemplateResourceHandler($resource_type);
|
Or is there a reason why it has to be lowercase?
Regards,
Inno |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Mar 04, 2010 3:05 pm Post subject: |
|
|
I know the autoloader requires filenames to be lower case. The classname can be any case. Is your resource loaded from a plugin file? |
|
Back to top |
|
innocenzo Smarty n00b
Joined: 04 Mar 2010 Posts: 4
|
Posted: Thu Mar 04, 2010 3:20 pm Post subject: |
|
|
I use the Smarty2 $smarty->register_resource() function.
Code: |
$smarty->register_resource('mysqlDB', array(
'db_get_template',
'db_get_timestamp',
'db_get_secure',
'db_get_trusted')
);
|
After the Smarty 3 object called the internal method getResourceTypeName() the variable $resource_type is set to lowercase. A few lines later the method loadTemplateResourceHandler() uses $resource_type to lookup the handler. He doesn't find it because array keys are case sensitive.
Inno |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Mar 04, 2010 3:30 pm Post subject: |
|
|
ok looks like a bug. we'll take a look. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Mar 04, 2010 3:48 pm Post subject: |
|
|
The fix is in the SVN now |
|
Back to top |
|
innocenzo Smarty n00b
Joined: 04 Mar 2010 Posts: 4
|
Posted: Thu Mar 04, 2010 4:30 pm Post subject: |
|
|
Thanks!
Inno |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|