Fix Joomla Migration Errors: A Step-by-Step Guide

Author:

Migrating your Joomla website to a new version is a great way to improve security, and performance, and access new features. However, encountering errors during the process can be frustrating. In this tutorial, you will learn how to fix migration errors step by step.  You can read our guide, Joomla Troubleshooting: Common Issues and Solutions. Here we are exploring complicated errors generated after Joomla Version migrations.

Troubleshoot and fix Joomla migration Errors.

Before you start Joomla Migration:

  • Always Back Up: This is very risky!  Create a full backup of your website’s files and database before starting the Joomla migration into the next version.
  • Identify Your Migration: Knowing the source and target Joomla versions (e.g., 2.5 to 3.x, 3.10 to 4.x or Joomla 4 to Joomla 5) will help pinpoint potential issues.
  • Apply on the Staging Site: we recommended that the Joomla migration process always be performed on a staging server. So your live website traffic will not be interrupted. and if any error occurs, then the website will not go down.

For Common errors and troubleshooting in the Joomla version upgrade process, please follow our tutorial.

NOTE: once you are getting errors, and if you can access the Joomla administrator panel, go to your Joomla Global Configuration by the steps below –

  • Login to administrator
  • Click on System=>Global Configuration
  • Click on System Tab
  • Enable the Debug System (Choose Yes)
  • Now Click on the Server Tab

If you are not able to access the Joomla Administrator panel, use cpanel or FTP and open configuration.php file. search for “error_reporting” and then replace the value as  below:

$error_reporting = 'default';

with
$error_reporting = 'maximum';

Also, search “debug” and replace the value as below:
$debug = false;
with
$debug = true;

Fixed errors after upgrading Joomla 3 to 4

Let’s start with the critical errors that I face after upgrading the Joomla 3 to 4 version.

Error 1:  Class ‘JRequest’ not found in Joomla 4

Solution: This is the most common error after Joomla migration from 3 to 4. because some Joomla built-in functions have changed, and this error is caused by JRequest() which is discontinued. So you have to replace the following:

$data   =  JRequest::get('data');

Replace with
$jinput = JFactory::getApplication()->input;
$data   = $jinput->get('data');

Error 2: Joomla\Database\Mysqli\MysqliDriver::getErrorMsg()

Solution:  This error is related to MySQL query methods, which have been replaced with new methods.  In this error, you have to replace it carefully. Comment on your error message method (code) and use the try and catch statement and MySQL query code insert into try{} and error message code in the catch.

try
{
$db->setQuery($query);
$result = $db->loadResult();
}
catch (RuntimeException $e)
{
echo $e->getMessage();
}

Error 3: Uncaught TypeError: Cannot read property ‘top’ of undefined (JS)

Solution: This is a javascript error so replace 2 lines of code with existing code and the rest of the code will be the same.

var nav = $('.content-nav');

if (nav.length) {
var contentNav = nav.offset().top;
...continue to set up the menu
}

Error 4: Call to undefined method Joomla\CMS\Filesystem\File::read()

Solution: In the new Joomla version, the old file read() function has been deprecated so find that function using the error line number.

Replace with: file_get_contents()

Error 5:  Call to undefined method Joomla\Database\Mysqli\MysqliDriver::query()

Solution: In Joomla 4 the query() function has been deprecated.

replace query()

with execute()

How do you fix a 404 error in Joomla

Error 6: File Upload and get file detail

Solution: include the file library at the top of the page.
use Joomla\CMS\Filesystem\File;

/****This code retrieve file data****/
$input = Factory::getApplication()->input;
$file = $input->files->get('file_upload');
$filename = File::makeSafe($file['name']);
$ext = File::getExt($filename);

Error 7: Class ‘JArrayHelper’ not found

Solution: In Joomla 4 toInteger() function has been deprecated so you need to replace the new function Intval().

Replace below line

JArrayHelper::toInteger($cid);

With

Intval($cid)

Error 8: 0 – Class ‘JDispatcher’ not found

Solution: Disable the plugin and comment on the code that contains JDispatcher.

To Include jQuery into Joomla 4

use Joomla\CMS\HTML\HTMLHelper;

HTMLHelper::_(‘jquery.framework’);

ERROR 9: 0 – Call to undefined method GpoViewRegion::assign()

ERROR 10:0 – Call to undefined method GpoViewRegion::assignRef()

Solution: Replace the below code:

$view->assign('datapageUrl', $datapageUrl;
With
$view->datapageUrl = $datapageUrl;

Error 11: Page not found

…/libraries/src/Router/Router.php:157

Solution: There is not an accurate solution, but I found the below code so just comment it. then your website will work again.

// if (\strlen($uri->getPath()) > 0) {

// throw new RouteNotFoundException(Text::_(‘JERROR_PAGE_NOT_FOUND’));

// }

How to change the default temp folder in Joomla

Error 12: Compile Error: Cannot redeclare bf_gdata_startsWith() (previously declared in /home/vintage/public_html/plugins/breezingforms_addons/gdata/gdata.php:14)

Solution:

// function bf_gdata_startsWith($haystack, $needle) {

Search backwards, starting from haystack-length characters from the end

//     return $needle === “” || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;

//

Error 13: 0 Call to a member function get() on bool (Administrator)

JROOT/administrator/components/com_templates/tmpl/templates/default.php:99

Solution: commented all xml field in the template/default.php

Error 14: Class “Sh404sefClassConfig” not found

Solution: Activate all SH404 extensions, then uninstall.

Error  15: 0 Call to undefined method Joomla\CMS\Application\AdministratorApplication::isAdmin()

Solution: Replace below

$this->app->system->application->isAdmin()
with:
$this->app->system->application->isClient('administrator')
OR
$app->isClient('administrator')

Error  16: 0 Call to undefined method GdImage::load()

Solution: comment on the code and use the custom image code of php.

Error 17: 0 Class “JError” not found

Solution: JFactory::getApplication()->enqueueMessage(JText::_($this->text_prefix.’_NO_ITEM_SELECTED’), ‘error’);

Error 18: Class “JEventDispatcher” not found

Solution: For the search component in Joomla 4 not find the exact file. So the solution is to replace the menu type with the Smart Search component and click on the index button.

After that, remove the current search module and create a smart search module.

Error 19: 0 – Class “JError” not found

Solutions:

if (APP_VERSION == ‘1.5’){     JError::raiseError( $code, $msg);  }else{     throw new Exception($msg, $code);  }

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

Solution: Replace
$uri = JFactory::getURI();
with
use Joomla\CMS\Uri\Uri;
$uri = Uri::getInstance();

Error 21: Class ‘JString not found Joomla 4.0

Solution: root languages folder modified below code.

File Path: /web/language/nl-NL/ nl-NL.localise.php

 //$str = JString::strtolower($string);

Replace with

 $str = strtolower($string);

 Error 22: Unsupported Oprand ‘strtring + string.

Solutions: This was coming After PHP version upgrade from 7.4 to 8.2

I found code in template/theme/includes/index.php like this SO I converted it into an integer value.

$mainContentWidth = 12 – (intval($aside_left_width) + intval($aside_right_width));

Error 23: 0 – Call to undefined method Joomla\Database\Mysqli\MysqliDriver::getErrorNum()

Solutions: I searched for the getErrorNum() function in all site (front end) folders on sublime and found “fof” folder files and one module file  “mod_vvisit_counter/” So I removed the “fof” folder because fof has been removed from Joomla 4.

Then fix the code of the module like this:
try
{
$db->setquery($query);
$result = $db->loadresult();
}
catch (runtimeexception $e)
{
echo $e->getmessage();

Error 24: 0 – Failed opening required ‘public_html/components/com_content/helpers/route.php’ (include_path=’.:/opt/phpbuilds/php-8.2/pear’)

Solution: Create a route.php file in the given location path: ‘public_html/components/com_content/helpers/route.php

Just leave it empty.

 Error 25: 0 – Class “JSite” not found

Solution: Search in the Site (front end) folder to get a file list in any file editor (I used Sublime Text).

Please ignore the language constant “JSITE” This is not the correct word.

In my case, I found this in

modules\mod_as_menu\helper.php

//$router = JSite::getRouter();  //comment this line and add below line.
$config = JFactory::getConfig();
$sef = $config->get('sef');
//if ($router->getMode() == JROUTER_MODE_SEF) {  //comment code and replace with below code
if ($sef == 0) {

Error 26: 0 – Cannot access protected property Joomla\CMS\Menu\MenuItem::$params

$item->params->get(‘secure’)

Solution: Replace this code $item->params->get(‘secure’)

by the below code

$params = $item->getParams();

$params->get(‘secure’)

/web/modules/mod_as_menu/helper.php

 Error 27: 500 – behavior:: tooltip not found.

Solution: Comment below with a code

//JHtml::_(‘behavior. tooltip);

Error 28: 500 – behavior::framework not found.

Solution: Comment below with a code

//JHtml::_(‘behavior.framework’);

Error 29: 0 – Call to undefined method Joomla\CMS\Pagination\Pagination::get()

 Solutions: Comment on this code

<?php //if (($this->params->def(‘show_pagination’, 1) == 1  || ($this->params->get(‘show_pagination’) == 2)) && ($this->pagination->get(‘pages.total’) > 1)) : ?>

<?php  //endif; ?>

 Error 30: script.js:70 Uncaught TypeError: Cannot read properties of undefined (reading ‘msie’)

if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)

Solution: Just comment on this line like

// if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)

Error 31: Uncaught TypeError: Cannot read properties of undefined (reading ‘msie’)

if (as.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);

Solution: Just comment this line like

//if (as.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);

Error 32: Uncaught TypeError: Cannot read properties of undefined (reading ‘opera’)

 transformsEnabled: !b.browser.opera,

Solution: Just comment on it

// transformsEnabled: !b.browser.opera,

Error 33: Iframe is not displaying content

Solutions: Install source plugin

Error 33: 0 – Class “JApplication” not found

Solution:  Just replace this line

$app      = JApplication::getInstance(‘site’, array(), ‘J’);

with below

$app = JFactory::getApplication();

 Error 34: 0 Class “Akeeba\Plugin\System\AdminTools\Extension\AdminTools” not found

Solution: remove or rename the below plugin

/plugins/system/admintools

 Error 35: How to access the Joomla functions out of the Joomla framework

Answer:

define('_JEXEC', 1);
define('JPATH_BASE', dirname(__FILE__));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
require_once JPATH_BASE . '/includes/app.php';
use Joomla\CMS\Factory;
$mainframe = Factory::getApplication('site');
// GET using JInput
$jinput = Factory::getApplication()->input;
$ModelId = $jinput->get('s', '', 'INT');
$db = Factory::getDBO();

 

JERROR36: How to Start Session on Joomla 4 in custom file

// Boot the DI container

$container = \Joomla\CMS\Factory::getContainer();

 

$container->alias(‘session.web’, ‘session.web.site’)

->alias(‘session’, ‘session.web.site’)

->alias(‘JSession’, ‘session.web.site’)

->alias(\Joomla\CMS\Session\Session::class, ‘session.web.site’)

->alias(\Joomla\Session\Session::class, ‘session.web.site’)

->alias(\Joomla\Session\SessionInterface::class, ‘session.web.site’);

 

// Instantiate the application.

$app = $container->get(\Joomla\CMS\Application\SiteApplication::class);

 

// Set the application as global app

\Joomla\CMS\Factory::$application = $app;

 

$userInfo = \Joomla\CMS\Factory::getApplication()->getSession()->get(‘user’);

$userSession = \Joomla\CMS\Factory::getApplication()->getSession();

Leave a Reply