Upgrading to Joomla4

The admin menu with CSS is back after our changes in the database and phpMyAdmin and this gives us hope to proceed with the fixing. The Menu is almost empty, with no modules whatsoever, and by trying to add a new one an error will appear referring to the extension attachments with an error message Call to undefined method Joomla\CMS\Factory::getURI(). The problem is now causing the extension since it contains a code Factory::getURI() that does not exist anymore in Joomla 4.

Call to undefined method Joomla\CMS\Factory::getURI()

From the debug window we know that the problematic file is located here:   JROOT\plugins\content\attachments\attachments.php:51, and thus we will try to fix this. This will actually solve the error and we can start to add modules within the administration panel. However, straight after I found another issue Class "JResponse" was not found in, and again, the attachment extension. Since "JResponse" was replaced by "JFactory" we need to alter this as well, as below. After this, I have got most of the Back End functions ready, as I see although I am still missing the template menu.

#At first you need to define something at the beginning of the document to
#load the appropriate functions
#Add after defined('_JEXEC') or die('Restricted access');
#
use Joomla\CMS\Uri\Uri;
#
#Then find the issue and replace
$uri= JFactory::getURI();
#change to
$$uri = Uri::getInstance();
$body = JResponse::getBody();
#change to
$body = JFactory::getApplication()->getBody();
JResponse::setBody($body);
#change to
JFactory::getApplication()->setBody($body);

It seems that even after all we had done there are still some errors and most likely within the database. Remember that you can access certain menu links using a link and you don't need a button for it, look below. Joomla 4 has built tools to check the database structure and as well the option to reinstall the core. Let's try both options to see if that will help us to resolve the problem. However, at first, let's uninstall the non-supported extensions to avoid more errors during the database check and update of the core. Use the link below to access the menu and uninstall what was unsupported. I have started with attachments which during the uninstall returned Call to the undefined method Joomla\Database\Mysqli\MysqliDriver::query(). Well, let's fix this to continue.

#Access the manage extension menu  
administrator/index.php?option=com_installer&view=manage
Call to undefined method Joomla\Database\Mysqli\MysqliDriver::query()
$db->query(); 
#change to
by $db->execute();

Popular