Search engine error and "Using $this when not in object context" Topic is solved

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
kkllii99
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Sep 10, 2018 6:46 pm

Search engine error and "Using $this when not in object context"

Post by kkllii99 » Mon Sep 10, 2018 7:05 pm

This happened a few days after a) PHP version was updated to 7.2, b) I added items to the main menu and c) switched the position of Search module in the template. So far I haven't found any resolution to this from the this forum or figured it out myself, so I must ask.

When I try to search for something on the site (not in the administrator side), it gives an Error 0 message with this line: "Using $this when not in object context". No other explanation/description is given.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2899
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Search engine error and "Using $this when not in object context"

Post by SharkyKZ » Mon Sep 10, 2018 7:15 pm

Enable debug to see where it's coming from.

kkllii99
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Sep 10, 2018 6:46 pm

Re: Search engine error and "Using $this when not in object context"

Post by kkllii99 » Mon Sep 10, 2018 7:28 pm

I did, but it doesn't show anything additional on the error page, just the same.

kkllii99
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Sep 10, 2018 6:46 pm

Re: Search engine error and "Using $this when not in object context"

Post by kkllii99 » Mon Sep 10, 2018 7:54 pm

Oddly enough, if you search for only two characters, it will display the search results and tell you to search for at least 3 characters. But then it doesn't work when you do.

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 24975
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: Search engine error and "Using $this when not in object context"

Post by pe7er » Mon Sep 10, 2018 8:15 pm

This issue appeared in the random image module of Joomla 3.8.8 (and was solved with Joomla 3.8.9 with https://github.com/joomla/joomla-cms/pull/20533 ). However, some 3rd party extensions might also cause this problem.

Make sure that you have the latest Joomla version (currently 3.8.12) and that you have updated all your 3rd party extensions.

Do you use a template override for the com_search component?
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

kkllii99
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Sep 10, 2018 6:46 pm

Re: Search engine error and "Using $this when not in object context"

Post by kkllii99 » Mon Sep 10, 2018 8:18 pm

How can I check if I do use template override for it? (English is not my first language, so something might be lost in translation).

I tried to update all the 3rd party extensions, they should be up to date. Random image module is not in use (unpublished).

Thanks very much!

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 24975
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: Search engine error and "Using $this when not in object context"

Post by pe7er » Mon Sep 10, 2018 8:22 pm

Check your /templates/your-template/html/ folder if it contains a folder /com_search/
If it does, then it might have a template override for the search component.

A background article about template overrides: https://docs.joomla.org/How_to_override ... omla!_core
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

kkllii99
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Sep 10, 2018 6:46 pm

Re: Search engine error and "Using $this when not in object context"

Post by kkllii99 » Mon Sep 10, 2018 9:14 pm

There is no such folder...

kkllii99
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Sep 10, 2018 6:46 pm

Re: Search engine error and "Using $this when not in object context"

Post by kkllii99 » Wed Sep 12, 2018 7:37 am

So it seems that the search might work for once after doing some changes to the main menu (for example, unpublishing a menu item). And after that it stops working again. No idea of how to fix this.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2899
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Search engine error and "Using $this when not in object context"

Post by SharkyKZ » Wed Sep 12, 2018 7:49 am

Are you sure you have correctly enabled debug? With debug enabled error page should show a backtrace. Are you using default template?

kkllii99
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Sep 10, 2018 6:46 pm

Re: Search engine error and "Using $this when not in object context"

Post by kkllii99 » Wed Sep 12, 2018 7:59 am

Yes, I enabled debug from control panel. Then if I use the search, the error page won't give any more information than it does when debug is not in use.

kkllii99
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Sep 10, 2018 6:46 pm

Re: Search engine error and "Using $this when not in object context"

Post by kkllii99 » Wed Sep 12, 2018 8:04 am

But on the other pages, the debug shows that there are multiple database inquiries, for example:

"SELECT m.*,e.element

FROM mmp_j25_menu AS m

LEFT JOIN mmp_j25_extensions AS e
ON m.component_id = e.extension_id

WHERE m.menutype = 'main'
AND m.client_id = 1
AND m.id > 1
AND (e.enabled = 1 OR e.enabled IS NULL)

ORDER BY m.lft

Selite
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE m ref PRIMARY,idx_client_id_parent_id_alias_language,idx_menutype idx_client_id_parent_id_alias_language 1 const 32 100.00 Using index condition; Using where; Using filesort
1 SIMPLE e eq_ref PRIMARY PRIMARY 4 int48126_uusi.m.component_id 1 100.00 Using where"

kkllii99
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Mon Sep 10, 2018 6:46 pm

Re: Search engine error and "Using $this when not in object context"

Post by kkllii99 » Wed Sep 12, 2018 8:40 am

Well, somehow it seems to be working now. I also installed AJAX Search plugin which also is working now, at first it couldn't load any results.

PekkaK
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Dec 04, 2013 6:34 am

Re: Search engine error and "Using $this when not in object context"

Post by PekkaK » Fri Oct 19, 2018 12:11 pm

I have the same issue with search module after upgrading from PHP 5.6 to PHP 7.1/7.2. Everything else seems to work fine. It looks like this happens when the search has no results, otherwise the results are displayed just fine. Any update on this issue?

PekkaK
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Dec 04, 2013 6:34 am

Re: Search engine error and "Using $this when not in object context"

Post by PekkaK » Fri Oct 19, 2018 2:24 pm

I noticed that problem was failing search components e.g. MijoPolls. After disabling a few search components, everything works fine.


Locked

Return to “Administration Joomla! 3.x”