Joomla-cms: Update PHP to 7.1 / 7.2 creates "Fatal Error 0 Using $this when not in object context"

Created on 25 Jul 2018  Β·  4Comments  Β·  Source: joomla/joomla-cms

Steps to reproduce the issue

Update a Joomla 8.10.3 Installation from PHP 7.0 to 7.1 or 7.2
Starting the Website

Expected result

Normal Operation:

Actual result

Withe Page with
--> Fatal Error 0 Using $this when not in object context

System information (as much as possible)

Call stack

Function Location
1 ()JROOT/libraries/src/Application/CMSApplication.php:369
2 Joomla\CMS\Application\CMSApplication::getMenu() JROOT/libraries/src/Application/SiteApplication.php:275
3 Joomla\CMS\Application\SiteApplication::getMenu() JROOT/templates/aerzte_theme517/index.php:209
4 require() JROOT/libraries/src/Document/HtmlDocument.php:658
5 Joomla\CMS\Document\HtmlDocument->_loadTemplate() JROOT/libraries/src/Document/HtmlDocument.php:720
6 Joomla\CMS\Document\HtmlDocument->_fetchTemplate() JROOT/libraries/src/Document/HtmlDocument.php:535
7 Joomla\CMS\Document\HtmlDocument->parse() JROOT/libraries/src/Application/CMSApplication.php:1027
8 Joomla\CMS\Application\CMSApplication->render() JROOT/libraries/src/Application/SiteApplication.php:780
9 Joomla\CMS\Application\SiteApplication->render() JROOT/libraries/src/Application/CMSApplication.php:201
10 Joomla\CMS\Application\CMSApplication->execute() JROOT/index.php:49

Additional comments

No Code Attached Yet

Most helpful comment

Unfortunately this is an error in your template JROOT/templates/aerzte_theme517/index.php:209. Basically, it's doing something like JSite::getMenu() or Joomla\CMS\Application\SiteApplication::getMenu() which calls the getMenu method in a static context, which is the incorrect way of calling that method. The code should be JFactory::getApplication()->getMenu().

All 4 comments

Unfortunately this is an error in your template JROOT/templates/aerzte_theme517/index.php:209. Basically, it's doing something like JSite::getMenu() or Joomla\CMS\Application\SiteApplication::getMenu() which calls the getMenu method in a static context, which is the incorrect way of calling that method. The code should be JFactory::getApplication()->getMenu().

Thank you, just worked for me on a Joomla site, changed the file as specified and site returned to normal opeation on PHP 7.1. Joomla recommended the update but without your change to the index.php site would not display, much appreciated.

@mbabker I realize this is old and closed... but you just saved me a monumental amount of time. Thank you very much.

ΠŸΠΎΠ΄ΡΠΊΠ°ΠΆΠΈΡ‚Π΅, Ρƒ мСня такая ΠΆΠ΅ ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΠ°, Π½ΠΎ Ρ‚Π°ΠΊΠΎΠ³ΠΎ ΠΊΠΎΠ΄Π° Π² index Π½Π΅Ρ‚. Как Ρ€Π΅ΡˆΠΈΡ‚ΡŒ? ошибка: Error: Call to undefined method Error::get(): Using $this when not in object context

Was this page helpful?
0 / 5 - 0 ratings