Page 1 of 1

Missing $serendipity['smarty']?

Posted: Sun Jan 23, 2011 10:15 pm
by greenwayg
Hi,

I am occasionally getting an error in my s9y installation. The error log says:

Code: Select all

[Sun Jan 23 14:50:13 2011] [error] [client 1.2.3.4] PHP Fatal error:  Call to a member function assign() on a non-object in /var/www/htdocs/vhost/mydomain/serendipity/plugins/serendipity_event_picasa/serendipity_event_picasa.php on line 485, referer: http://www.mydomain.com/serendipity/index.php?/archives/2011/01/22/429-pagetitle.html
The offending line is:

Code: Select all

$serendipity['smarty']->assign(get_class($this).'_albumName',      $albumName);
This fatal error causes a blank page to show up in my web browser. But if I refresh, it works fine, the page loads correctly, and there is no error in the log. Is this a bug in the plugin? Can $serendipity['smarty'] sometimes not exist? Is there something I need to do to cause it to exist before using it in the plugin?

thanks,
greg

Re: Missing $serendipity['smarty']?

Posted: Mon Jan 24, 2011 8:43 am
by garvinhicking
Hi!

Do you use any cachcing plugins, and/or PHP bytecode caches like APC?

Your problems to me sounds a bit like some misbehaving cache...

Regards,
Garvin

Re: Missing $serendipity['smarty']?

Posted: Mon Jan 24, 2011 4:43 pm
by greenwayg
Nope, no caches that I'm aware of. Just a stock php5/apache server. It's very low-traffic, so I've never given a second thought to performance.

Re: Missing $serendipity['smarty']?

Posted: Mon Jan 24, 2011 4:52 pm
by Timbalu
I remember having this sometimes in special functions in event plugins too and I solved it adding a

Code: Select all

        if (!is_object($serendipity['smarty'])) { 
            serendipity_smarty_init(); // if not set to avoid member function assign() on a non-object error, start Smarty templating
        }
just at the start of that function.

Ian

Re: Missing $serendipity['smarty']?

Posted: Mon Jan 24, 2011 7:54 pm
by greenwayg
Timbalu wrote:I remember having this sometimes in special functions in event plugins too and I solved it adding a

Code: Select all

        if (!is_object($serendipity['smarty'])) { 
            serendipity_smarty_init(); // if not set to avoid member function assign() on a non-object error, start Smarty templating
        }
just at the start of that function.

Ian
I was wondering if it was something along those lines. I'll give that snippet a try and see if that fixes it. I never figured out exactly what the reproduce case is for the bug, so I'll just go with this for a few days/weeks and see if I run into the problem again.

Thanks!
greg