|
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 |
nzsmarty Smarty Rookie
Joined: 03 Jul 2004 Posts: 15 Location: New Zealand
|
Posted: Fri Jul 09, 2004 2:51 am Post subject: smartyValidate won't connect (PHP 5.0.0RC2/Win32) |
|
|
I'm keen to start using smartyValidate, but I can't even get off first base.
I'm running
- PHP 5.0.0 RC2
- Smarty 2.6.3
- smartyValidate 2.2-b1
on Win32 (XP SP1) / Apache 1.3.29
I have smarty working fine, but when I add
Code: |
session_start();
$testSmarty =& new Smarty;
require('./SmartyValidate.class.php');
SmartyValidate::connect($testSmarty);
|
which pretty much copies the code from the README,
I get this
Quote: |
Notice: SmartyValidate: [connect] I need a valid Smarty object. in c:\www\projects\wa\SmartyValidate.class.php on line 48
|
I can confirm that the session gets started and smarty works (another template gets processed without error).
php_errormsg gives me:
Quote: |
Non-static method SmartyValidate::connect() should not be called statically
|
I'm not a PHP expert, but as of today, I am certainly a smartyValidate newbie
So... is it me, or have I tripped something up here? Is this a PHP5 thing?
It seems to fail this line
Code: |
if(is_object($smarty) && ((get_class($smarty) == strtolower('smarty')) || is_subclass_of($smarty, strtolower('smarty')))) {
|
So to discover which of these tests failed, I added this before that line
Code: |
if(is_object($smarty)) { echo "is an object<br>"; }
echo 'strtolower(class name) ' . strtolower(get_class($smarty)) . '<br>';
echo 'subclass of ' . print_r(is_subclass_of($smarty, strtolower('smarty'))) . '<br>';
|
and the output of that is:
Quote: |
is an object
strtolower(class name) smarty
subclass of 1
|
How perplexing... it is an object, it is a Smarty object (and not a subclass), yet it fails the IF statement....
heeeeeeeeeeeeeelp.
Update:
I have patched the code with an: if (TRUE || .... and the rest now seems to work for me with a default form having criteria and transform as registered functions, and is_error is FALSE...
Last edited by nzsmarty on Wed May 05, 2010 10:39 pm; edited 1 time in total |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Jul 09, 2004 5:37 am Post subject: |
|
|
hmmmmm. Must be a PHP5 thing. Have you tried with RC3? I haven't tested against PHP5 yet. Technically, PHP5 shouldn't require the =& since it uses references by default. See if the following makes any difference...
$testSmarty = new Smarty();
I'll test this monday unless someone else gets to it first You may also want to use the latest CVS snapshot of SmartyValidate, though it shouldn't differ in this particular regard...
update:
should probably be:
Code: | if(is_object($smarty) && ((strtolower(get_class($smarty)) == 'smarty') || is_subclass_of($smarty, 'smarty'))) {
|
I updated this in CVS -- please test! |
|
Back to top |
|
nzsmarty Smarty Rookie
Joined: 03 Jul 2004 Posts: 15 Location: New Zealand
|
Posted: Fri Jul 09, 2004 6:40 am Post subject: |
|
|
No, I haven't tried PHP5RC3.
Now that I look at it after dinner (new fuel - new perspective)
this:
Code: |
get_class($smarty) == strtolower('smarty')
|
was always going to fail with get_class() returning "Smarty"
To be honest, I read over that and didn't see it either.
So the (somewhat rhetorical) question is, did PHP4 return get_class() as "smarty"? Must have done if this hadn't been an issue until now?
This suggested change
$testsmarty =& new Smarty;
to
$testsmarty = new Smarty();
either worked after the fix on that ::connect if() statement
Thanks for your help - easy one in the end
________
Herbalaire vaporizer |
|
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
|