Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

buildUniqueResourceName bug

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Tue Nov 15, 2011 4:43 pm    Post subject: buildUniqueResourceName bug Reply with quote

After moving to Smarty 3.1.5 I get error:

Fatal error: Call to a member function buildUniqueResourceName() on a non-object in T:\HTDOCS\CMS\third_party\smarty\sysplugins\smarty_resource.php on line 478

I have added a code that throws an exception if buildUniqueResourceName is not defined and here is a trace:

Exception "Custom" in T:\HTDOCS\CMS\third_party\smarty\sysplugins\smarty_resource.php (479), stack trace:
0: Smarty_Resource::source(object{Smarty_Internal_Template}) in T:\HTDOCS\CMS\third_party\smarty\sysplugins\smarty_internal_template.php (628)
1: Smarty_Internal_Template::__get(string{1}) in T:\HTDOCS\CMS\third_party\smarty\sysplugins\smarty_internal_templatebase.php (117)
2: Smarty_Internal_TemplateBase::fetch(string{1}, null, string{1}) in T:\HTDOCS\CMS\api\api_smarty\smarty.php (86)
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Nov 15, 2011 5:02 pm    Post subject: Reply with quote

I see two different pathes to smarty:

1. T:\HTDOCS\CMS\third_party\smarty\

2. T:\HTDOCS\CMS\api\api_smarty\

Is this correct and point both to same Smarty version?

The trace back T:\HTDOCS\CMS\api\api_smarty\smarty.php (86) does not look like to belong to version 3.1.5
Back to top
View user's profile Send private message
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Tue Nov 15, 2011 7:03 pm    Post subject: Reply with quote

Smarty is located T:\HTDOCS\CMS\third_party\smarty\ folder.

T:\HTDOCS\CMS\api\api_smarty\smarty.php file is NOT related to smarty. The line 86 contains the following code:
return $smarty->fetch($template, null, "{$cms_data['mode']}_{$cms_page['skin']}");

Also, I register custom resource:
$smarty->default_resource_type = 'custom';
$smarty->registerResource('custom', array('cms_smarty_resource_get_template',
'cms_smarty_resource_get_timestamp',
'cms_smarty_resource_get_secure',
'cms_smarty_resource_get_trusted'));
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Nov 15, 2011 7:40 pm    Post subject: Reply with quote

From which version did you move to 3.1.5?
Back to top
View user's profile Send private message
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Tue Nov 15, 2011 7:48 pm    Post subject: Reply with quote

3.1.3 or 3.1.4

in Smarty.class.php it is written:
...
* SVN: $Id: Smarty.class.php 4360 2011-10-06 14:36:30Z uwe.tews@googlemail.com $
...
* @version 3.1.3
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Nov 15, 2011 10:25 pm    Post subject: Reply with quote

We can't reproduce the problem.

Looks like that in line 477 of smarty_resource.php

$resource = Smarty_Resource::load($smarty, $type);


$resource is not filled with an object.
Back to top
View user's profile Send private message
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Wed Nov 16, 2011 1:55 am    Post subject: Reply with quote

Look at this code:

Code:
    /**
     * Load Resource Handler
     *
     * @param Smarty $smarty    smarty object
     * @param string $type      name of the resource
     * @return Smarty_Resource Resource Handler
     */
    public static function load(Smarty $smarty, $type)
    {
        // try smarty's cache
        if (isset($smarty->_resource_handlers[$type])) {
            return $smarty->_resource_handlers[$type];
        }

        // try registered resource
        if (isset($smarty->registered_resources[$type])) {
            if ($smarty->registered_resources[$type] instanceof Smarty_Resource) {
                $smarty->_resource_handlers[$type] = $smarty->registered_resources[$type];
                // note registered to smarty is not kept unique!
                return $smarty->_resource_handlers[$type];
            }
            if (!isset(self::$resources['registered'])) {
                self::$resources['registered'] = new Smarty_Internal_Resource_Registered();
                $smarty->_resource_handlers[$type] = self::$resources['registered'];
            }
            return $smarty->_resource_handlers[$type];
        }


If
self::$resources['registered']
is set and
$smarty->_resource_handlers[$type]
is not set, then the line
return $smarty->_resource_handlers[$type];
will return NULL.
Back to top
View user's profile Send private message
ilyalyu
Smarty Regular


Joined: 03 Nov 2009
Posts: 72

PostPosted: Wed Nov 16, 2011 2:03 am    Post subject: Reply with quote

Code:


$smarty = new Smarty;

$smarty->default_resource_type = 'custom';
$smarty->registerResource('custom', array('cms_smarty_resource_get_template',
                                          'cms_smarty_resource_get_timestamp',
                                          'cms_smarty_resource_get_secure',
                                          'cms_smarty_resource_get_trusted'));

$smarty->fetch('test.html');

$smarty = new Smarty;

$smarty->default_resource_type = 'custom';
$smarty->registerResource('custom', array('cms_smarty_resource_get_template',
                                          'cms_smarty_resource_get_timestamp',
                                          'cms_smarty_resource_get_secure',
                                          'cms_smarty_resource_get_trusted'));

$smarty->fetch('test.html');



Fatal error occurs on second $smarty->fetch('test.html');
Also, it only occurs after registering custom resource (see $smarty->default_resource_type and $smarty->registerResource)
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Wed Nov 16, 2011 8:26 am    Post subject: Reply with quote

I see your point. It's fixed in SVN Trunk and will be included in Smarty 3.1.6 eventually.
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP