After php update: “Using $this when not in object context” in joomla, Hotfix

For a riding stable, i run and administrate a website since many years with joomla. So, i did this until a few days ago until joomla update assistant said, that my php 5.x is too old. i have contacted the provider and they moved it to a server with php 7.4.15.

Unfortunately, the frontend of the site was offline:

The error was: “Using $this when not in object context”.

The kind of the error is not joomla-like, more it is php-like as you will see Fortunately, the backend was still online. At first, i logged on to the backend and switched on (from: Nein->Ja means from No -> Yes) the debugging mode in the server settings in global configurations (the german word “Fehlersuche” means “Debugging”), dont forget to save the new configuration:

The Debugging-Mode gives more informative data to the frontend. I changed to the frontend and pressed F5 for refreshing and i have got this site:

The special error information is this:

It seems so, that the file CMSApplication.php occurs problems and with the information in the line after, the SiteApplication.php seems also is to be involved.

I copied booth and found following code:



The line “return parent::getMenu($name, $options)” in the SiteApplication calls the function getMenu(…) in the CMSApplication. The original error points to the kind of calling the function: “using $this when not in object” means, that parent::getMenu is a static call. But the function getMenu in the CMSApplication is prepared to work with classes and objects and so you need an object orientated codeset for this kind of view.

I think, this error is ther since a long time (joomla version 3.3 in comments) and php 5.x was not configured to spill out error messages like this. rest assure: the error was there before, too. As a hotfix, you can comment out this line.

Type in an reason for this. Then, do a backup of the old file or rename it at serverside. Do an upload of the changed file to the server (e.g. via ftp and change the ftp-password then) and deactivate the debugging mode. Just try to click through the website frontend for seeking an further error and contact the developer (e.g.