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

new bug in smarty (_ problem in calling method of object)

 
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
sm@rty
Smarty Regular


Joined: 01 Oct 2014
Posts: 65

PostPosted: Wed Mar 11, 2015 7:27 pm    Post subject: new bug in smarty (_ problem in calling method of object) Reply with quote

hi

please only run this smarty code :

Code:
{$a->_s()}


smarty error :

Syntax error on line 1 "{$a->_s()}" Security error: Call to private object member not allowed

$a not defined !

smarty can not proccess on _(underline)
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Mar 11, 2015 9:04 pm    Post subject: Reply with quote

You're trying to access private method, the error clearly states that.
This has nothing to do with Smarty.
Back to top
View user's profile Send private message
sm@rty
Smarty Regular


Joined: 01 Oct 2014
Posts: 65

PostPosted: Thu Mar 12, 2015 7:28 am    Post subject: Reply with quote

ooops AnrDaemon please look carefully at post !

$a is not defined !!!!!!!

$a no object !

$a no exists !

There is no method !

for example :

Code:
{$a->_asdadwqiudiuqou9du()}
{$a->_lkkkkkskkkksksksksksksksksksksksksk()}


this is a bug ! ok ?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Mar 12, 2015 3:41 pm    Post subject: Reply with quote

Then this is a bug in your code.
Smarty is not a PHP interpreter. It doesn't care what you write, it merely arrange the vars and templates to a code that is then executed by PHP.
If you use variable incorrectly, PHP yell at you.
If you know a variable can be unset, then test for it explicitly.
Back to top
View user's profile Send private message
sm@rty
Smarty Regular


Joined: 01 Oct 2014
Posts: 65

PostPosted: Thu Mar 12, 2015 4:37 pm    Post subject: Reply with quote

ok !

please write this code in php :
Code:

class test{
   public function _myPublicMethod()
      {
         return 'ok';
      }
}
function test(){
   return new test;
}

and in smarty template :
Code:
{$obj = test()}
{$obj->_myPublicMethod()}


now give me result.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sat Mar 14, 2015 5:23 am    Post subject: Reply with quote

It's not a bug, it's a feature

Quote:
If security is enabled, no private methods or functions can be accessed (beginningwith '_').


See http://www.smarty.net/docs/en/advanced.features.objects.tpl
Back to top
View user's profile Send private message
sm@rty
Smarty Regular


Joined: 01 Oct 2014
Posts: 65

PostPosted: Sat Mar 14, 2015 7:08 am    Post subject: Reply with quote

ok.

thanks.
Back to top
View user's profile Send private message
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