Page 1 of 1

[SOLVED]admin: Call member function GetURL() on a non-object

Posted: Sat Aug 04, 2012 9:02 am
by Joppybt
My problem is solved but I am posting this to maybe help others.

After I upgraded my 1.10.3 site to version 1.11 the public site worked perfectly.
However, whenever I tried to open a page for editing in the admin interface, or tried to save a template I got a 404-page and error in the logfile:

Code: Select all

Call to a member function GetURL() on a non-object in /var/www/XXXXX/tmp/templates_c/c1344001880^55f7216a49f40af311680e5c40b180e7c548bfdb.template.17.php on line 46
The apache errorlog showed a warning just before that with:

Code: Select all

Undefined index: content_obj in /var/www/XXXXX/tmp/templates_c/c1344001880^55f7216a49f40af311680e5c40b180e7c548bfdb.template.17.php on line 46
This led me to the solution. My template had a line:

Code: Select all

<link rel="canonical" href="{$content_obj->GetURL()}" />
which in the default templates is:

Code: Select all

{if isset($canonical)}
    <link rel="canonical" href="{$canonical}" />
{elseif isset($content_obj)}
    <link rel="canonical" href="{$content_obj->GetURL()}" />
{/if}
It appears you need to test for the existence of content_obj.
As I could not edit templates in the admin interface anymore I had to use phpmyadmin to change the template directly in the table cms_templates. After that the problem was gone and I could edit pages again.

I do not remember when I added the canonical part to my template and why I only added the content_obj line but I am leaving this as a warning for other people.

This does leave me with one minor question: is it logical that a template works fine in the normal published site but will throw errors in the admin interface (where a preview is generated I suppose) ?

Re: In admin: Call to a member function GetURL() on a non-ob

Posted: Fri Aug 10, 2012 9:57 am
by migrob
I had a similar problem after updating my site from 1.10.3 to version 1.11.
Also the public site worked perfectly.
But whenever I tried to open a page for editing in the admin interface, or tried to save a template I got a 404-page and fatal error:

Code: Select all

Fatal error: Call to a member function getParentNode() on a non-object in /home/lightliv/public_html/schreibmobil/plugins/function.cms_selflink.php on line 257
I then looked at my template and saw that I had 3 lines:

Code: Select all

{cms_selflink dir="start" rellink=1}
{cms_selflink dir="prev" rellink=1}
{cms_selflink dir="next" rellink=1}
As I too could not edit the template in the admin interface, i had to use phpmyadmin and change the template directly in the table 'templates'. I deleted those 3 lines and saved the changed template.

After that everything worked well.

Re: In admin: Call to a member function GetURL() on a non-ob

Posted: Fri Aug 10, 2012 10:16 pm
by carasmo
cms_selflink is buggy?

Re: In admin: Call to a member function GetURL() on a non-ob

Posted: Fri Aug 10, 2012 11:37 pm
by Dr.CSS
The canonical stuff should have look like so, not with a bunch of \ in it...

{if isset($canonical)}<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}<link rel="canonical" href="{$content_obj->GetURL()}" />{/if}

Re: In admin: Call to a member function GetURL() on a non-ob

Posted: Sat Aug 11, 2012 8:57 am
by Joppybt
Dr.CSS wrote:The canonical stuff should have look like so, not with a bunch of \ in it...

{if isset($canonical)}<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}<link rel="canonical" href="{$content_obj->GetURL()}" />{/if}
Thanks, I removed the backslashes in the opening post to prevent confusion.
They were not present in my deployed site. Somehow they got introduced with all my copy-pasting to create this post.