Search engine error and "Using $this when not in object context" Topic is solved
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.
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.
-
- Joomla! Apprentice
- Posts: 13
- Joined: Mon Sep 10, 2018 6:46 pm
Search engine error and "Using $this when not in object context"
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.
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.
-
- 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"
Enable debug to see where it's coming from.
-
- Joomla! Apprentice
- Posts: 13
- Joined: Mon Sep 10, 2018 6:46 pm
Re: Search engine error and "Using $this when not in object context"
I did, but it doesn't show anything additional on the error page, just the same.
-
- Joomla! Apprentice
- Posts: 13
- Joined: Mon Sep 10, 2018 6:46 pm
Re: Search engine error and "Using $this when not in object context"
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.
- pe7er
- 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"
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?
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
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com
-
- Joomla! Apprentice
- Posts: 13
- Joined: Mon Sep 10, 2018 6:46 pm
Re: Search engine error and "Using $this when not in object context"
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!
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!
- pe7er
- 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"
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
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
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com
-
- Joomla! Apprentice
- Posts: 13
- Joined: Mon Sep 10, 2018 6:46 pm
Re: Search engine error and "Using $this when not in object context"
There is no such folder...
-
- Joomla! Apprentice
- Posts: 13
- Joined: Mon Sep 10, 2018 6:46 pm
Re: Search engine error and "Using $this when not in object context"
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.
-
- 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"
Are you sure you have correctly enabled debug? With debug enabled error page should show a backtrace. Are you using default template?
-
- Joomla! Apprentice
- Posts: 13
- Joined: Mon Sep 10, 2018 6:46 pm
Re: Search engine error and "Using $this when not in object context"
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.
-
- Joomla! Apprentice
- Posts: 13
- Joined: Mon Sep 10, 2018 6:46 pm
Re: Search engine error and "Using $this when not in object context"
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"
"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"
-
- Joomla! Apprentice
- Posts: 13
- Joined: Mon Sep 10, 2018 6:46 pm
Re: Search engine error and "Using $this when not in object context"
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.
-
- Joomla! Fledgling
- Posts: 3
- Joined: Wed Dec 04, 2013 6:34 am
Re: Search engine error and "Using $this when not in object context"
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?
-
- Joomla! Fledgling
- Posts: 3
- Joined: Wed Dec 04, 2013 6:34 am
Re: Search engine error and "Using $this when not in object context"
I noticed that problem was failing search components e.g. MijoPolls. After disabling a few search components, everything works fine.