Page 1 of 2

[4.2.0] Error "Trying to get property of non-object"

Posted: 04 Aug 2015, 10:12
by jb80
Just updated Phoca Gallery from v4.1.2 to v4.2.0 and upon doing so, it has broken my photo website.

The following frontend display errors are returned;

# Gallery category view error #
Notice: Trying to get property of non-object in <domainname>/administrator/components/com_phocagallery/libraries/phocagallery/path/route.php on line 22

Code: Select all

$activeId 	= $active->id;
# Tree module error #
Notice: Trying to get property of non-object in <domainname>/administrator/components/com_phocagallery/libraries/phocagallery/path/route.php on line 115

Code: Select all

$activeId 	= $active->id;
Both errors relate to
$activeId = $active->id;
I have since returned back to Gallery v4.1.2 and these issues are resolved. It would appear the issue is related to the V4.2.0 changes... more than happy with v4.1.2 so I'll be staying on this version for the time being.

Re: [4.2.0] Error "Trying to get property of non-object"

Posted: 05 Aug 2015, 17:06
by Jan
Hi, did you create a menu link to Phoca Gallery, on which site do you get it (the url without SEF)

Try to change the line 22:

FROM:

Code: Select all

$activeId 	= $active->id;
TO:

Code: Select all

$activeId	= 0;
		if (isset($active->id)){
			$activeId 	= $active->id;
		}
The same for line 115

And let me know.

Thank you Jan

Re: [4.2.0] Error "Trying to get property of non-object"

Posted: 06 Aug 2015, 00:21
by jb80
By changing the code as suggested this has overcome the reported display errors.

However I have noticed the URL redirection behaviour of the "Phoca Gallery Image Module" is working differently. My site configuration is that I have positioned the "Phoca Gallery Image Module" to randomly display categories on the home page. The Image Module is configured to "Module Link" as "Link to Category View". i.e. by clicking on the displayed image on the homepage it navigates to the respective category and displays the list of images. By using the "Phoca Gallery Image Module" instead of a menu link this is probably why the respective ID is not set and the root cause of the previous error message. ?

Previous URL redirect using v4.1.2
<domain name>/<site>/<first menu item>/category/<category name>

New redirection using v4.2.0
<domain name>/<site>/component/phocagallery/category/<category name>

Note the previous behaviour is that the first menu item is used (not configured it just works this way). Where the new behaviour references against the "component" itself. I am not sure why in v4.2.0 the behaviour is different however I suggest the issue is related to this behaviour.

Re: [4.2.0] Error "Trying to get property of non-object"

Posted: 08 Aug 2015, 11:22
by Jan
Hi, in your case, (4.2.0) the SEF link (Menu item id) will be not found. I need to look at it.

The change in 4.2.0 is to try to find the right menu link when going through the tree - categories - category - detail and back (when there are two menu links, there is a problem to find the right menu link - where you started to preview the gallery) - so the change in 4.2.0 solved this problem but seems some additional conditions need to be added because of modules and plugins.

I will test it and let you know if I get the same problem, If yes, I will try to find some additional solution for this. Thank you for this info.

Jan

Re: [4.2.0] Error "Trying to get property of non-object"

Posted: 13 Aug 2015, 11:43
by Jan
Hi, testing now:

- without SEF enabled ... OK
- with SEF enabled ... OK
- without creating a menu link to Phoca Gallery ... OK
- with creating a menu link to Phoca Gallery ... OK

The problem is, you should normally get the ID from $active->id variable.

Do you run the latest Joomla! 3? Are you able to send me login to administration (per PM or email) so I can take a look at it. For now I am testing it on 3 different sites without any problem :idea:

Jan

Re: [4.2.0] Error "Trying to get property of non-object"

Posted: 13 Aug 2015, 12:04
by Jan
EDIT:

I have found the reason to this:
Notice: Trying to get property of non-object in <domainname>/administrator/components/com_phocagallery/libraries/phocagallery/path/route.php on line 115

This happen in case, Joomla! does not return menu link site - for example component /component/search - when there is no link to Search component in Joomla! it does not create menu link search output site and then the activeid is null. But testing the solution set in previous post:

Code: Select all

$activeId   = 0;
      if (isset($active->id)){
         $activeId    = $active->id;
      }
and it is working right. It can prevent from running this error, because it manages missing activeid. But all this does not have any influence on the link to images - they are build by menu link rules (menu link to Phoca Gallery).

So if there is a menu link to gallery (e.g. to categories view), then all the links to images get the right SEF link :idea:

Jan

Re: [4.2.0] Error "Trying to get property of non-object"

Posted: 14 Aug 2015, 10:25
by jb80
The validation code prevents the display errors and loads the gallery as expected however because the ID is not set it causes unusual behaviour with the associated Joomla article. For example, the configured "options" associated to the menu ID, i.e. "show title", etc, do not get used as it doesn't link the menu, therefore the Joomla coded defaults are used. Annoying more than anything (however this is not a problem in previous release).

More than willing to give you site access, please PM me as this function is not enabled for me.

Re: [4.2.0] Error "Trying to get property of non-object"

Posted: 14 Aug 2015, 20:47
by seitzinger
Hallo,
on my production site i get the same error. I didn't want to change the code on the production site, so i decided to make a test on my computer.
The weird thing is: On my XAMPP installation i didn't get the error, everything works fine. So i'm a little bit confused.

My production site runs unter PHP 5.3.29, my test system runs on PHP 5.4.27.

Is it possible, that the error depends on the installed version of PHP?

Re: [4.2.0] Error "Trying to get property of non-object"

Posted: 15 Aug 2015, 11:50
by jb80
My setup is:
- Phoca Gallery v.4.1.2 (working without issue)
- Phoca Gallery Finder Plugin v4.0.3
- Phoca Gallery Image Module v4.0.0
- Phoca Gallery Search Plugin v4.0.2
- Phoca Gallery Tree Module v4.0.2
- PHP v5.5.26
- Joomla v3.4.3
- SEF: Enabled

Issue is found when upgrading to:
- Phoca Gallery v.4.2.0

Re: [4.2.0] Error "Trying to get property of non-object"

Posted: 27 Aug 2015, 12:38
by Jan
Hi, thank you very much for the info, confirmed, there is a problem with active id and module - this will be fixed in version 4.2.2

Thank you, Jan