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

register_object breaks on methods ending with number

 
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
joelgriffiths
Smarty n00b


Joined: 29 Aug 2004
Posts: 3
Location: Phoenix, AZ

PostPosted: Sun Aug 29, 2004 3:11 pm    Post subject: register_object breaks on methods ending with number Reply with quote

Apache: 1.3.31
PHP: 5.0.1
Smarty: 2.6.3

I downloaded the most recent stable version of smarty 2-3 days ago (smarty newbie). While trying to use the register_object function, I noticed that methods ending with numbers (eg. function test1()) did not execute properly. Instead, they echoed the method name back to the browser.

For instance, the code below produced the following output:
TEST
testmethod->test2
testmethod->test3

// test.php
<?php

Class test {
function test() {
return("TEST");
}

function test2() {
return("TEST2");
}

function test3() {
return("TEST3");
}
}

require('Smarty.class.php');

$smarty = new Smarty;
$testObject = new test;

$smarty->register_object("testmethod",$testObject);

$smarty->display('registerbug.tpl');
?>

// registerbug.tpl
<pre>
{testmethod->test}
{testmethod->test2}
{testmethod->test3}
</pre>
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Sun Aug 29, 2004 3:37 pm    Post subject: Re: register_object breaks on methods ending with number Reply with quote

joelgriffiths wrote:
<pre>
{testmethod->test}
{testmethod->test2}
{testmethod->test3}
</pre>


That is invalid template synatax. There are two ways to use objects in the template, either register the object or assign it like any other variable. See the docs on the correct syntax for each.
Back to top
View user's profile Send private message Visit poster's website
joelgriffiths
Smarty n00b


Joined: 29 Aug 2004
Posts: 3
Location: Phoenix, AZ

PostPosted: Sun Aug 29, 2004 3:48 pm    Post subject: Reply with quote

I guess I should have called the registered object testObject (not testMethod).. That was more of a naming convention problem than a bug though. testmethod was a registered object. Did I misunderstand your comment?
Back to top
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Aug 29, 2004 5:15 pm    Post subject: Reply with quote

@joelgriffiths:

this is a bug in Smarty-2.6.3 that affects methodnames and other identifiers containing digits.

it was fixed in cvs on jul 1 2004.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Aug 30, 2004 3:20 pm    Post subject: Reply with quote

nm, that syntax is fine. listen to messju instead Smile
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