Fatal error: Call to a member function getGUID() on a non-object

I appreciate some assistance on a fix.

When checking the messages on the top left of the page i got this  ===>

Fatal error: Call to a member function getGUID() on a non-object in /home/www/examplesite.com/mod/metatags/views/default/metatagsgen/metatags.php on line 128. <===.

--> this is the line 128 in that file:  'relationship_guid' => $owner->getGUID(),

What do i have to do with the mod plugin called "metatags" in order for the users never getting this error?

I have Elgg version 1.97 and the plugin is metatags 1.9, Thank You.

  • The $owner variable is not assigned any value. Before the use in line 128 you would need to assign the currently logged in user or the page owner entity to the variable:

    $owner = elgg_get_logged_in_user_entity();

    or

    $owner = elgg_get_page_owner_entity();

    Most likely, the second possibility is the correct one (intended one) and the variable that was intented to be used is $user instead of $owner, because that's the variable name used everywhere else. Additionally, $user is already assigned the page owner entity (which falls back to logged in user if the page has no owner).

    I don't know if this is the only bug in this plugin. I've never used it but just looked briefly at the code just now.

  • iionly ,

    I went ahead and use the second choice right on the file named "metatags.php "

     To see what happens. $owner = elgg_get_page_owner_entity(); I post this right before line 128.

    The result was another weird error:

    "Parse error: syntax error, unexpected ';', expecting ')' in /home/www/mywebsitename.com/mod/metatags/views/default/metatagsgen/metatags.php on line 128"

    Then I used the second and another error: Parse error: syntax error, unexpected ';', expecting ')' in /home/www/mywebsitename.com/mod/metatags/views/default/metatagsgen/metatags.php on line 128.

    If you got another idea, let me know, I deeply appreciate your help.
    Thank You so much.

  • You can't add it right before line 128 because you would add it within the options array then. Try it with

    case 'friends':
        $owner = elgg_get_logged_in_user_entity();
        $options = array(
            'relationship' => 'friend',
            'relationship_guid' => $owner->getGUID(),
            'inverse_relationship' => FALSE,
            'limit' => false,
            'type' => 'user',
            'full_view' => FALSE
        );

  • The way I fixed it in the original plugin is to change line 128 and replaced $owner with $user, which is defined.But what iionly suggest also works fine.

    I do prefer declaring global variables in the beginning, so you will not enter in similar issues somewhere else in the program.

  • Thank you! Now the plugin works correct and the site doesn't putout errors because of that.

    I appreciate your knowledge one more time.


     

Performance and Scalability

Performance and Scalability

If you've got a need for speed, this group is for you.