J-BusinessDirectory - Joomla 5 and J-BusuinessDirectory v5.8.14 not work

Support Forum

 
 

 

HI

I tried the latest J-BusuinessDirectory v5.8.14: Joomla 5 but get some real problem "0 Class "\Joomla\CMS\Table\CompanyServiceProviders" not found

and site crashed frontend and also problem reaching JBD in backend "An error has occurred. 0 Class "\Joomla\CMS\Table\DirectoryApps" not found.

Anyone else got JBD work with Joomla 5?

I also tried the update Joomla 5.0.1 nigthly builds but same problem.

7 replies

The issue should be fixed on the Joomla 5.0.1 version.

You have to edit libraries/src/Table/Table.php and replace the getInstance function with the one below

public static function getInstance($type, $prefix = 'JTable', $config = [])
{
/**
* For B/C reasons we don't change the $prefix to \Joomla\CMS\Table\ since extensions which
* use JTable as table prefix instead of an own prefix and not adding 'JTable' as prefix will
* fail to load the table. We can't detect this situation.
* Example:
* class JTableMytable {}
* JTable::getInstance('Mytable');
* This will fail when we change the function default $prefix from JTable to \Joomla\CMS\Table\
*
* In case of $prefix is 'JTable' we make an additional check for '\Joomla\CMS\Table\' $type
*
*/

// Sanitize and prepare the table class name.
$type = preg_replace('/[^A-Z0-9_.-]/i', '', $type);

$tableClass = $prefix . ucfirst($type);
$tableClassLegacy = $tableClass;

if ($prefix === 'JTable') {
$tableClass = '\Joomla\CMS\Table\' . ucfirst($type);
}

// Only try to load the class if it doesn't already exist.
if (!class_exists($tableClass) && !class_exists($tableClassLegacy)) {
// Search for the class file in the JTable include paths.
$paths = self::addIncludePath();
$pathIndex = 0;

while (!class_exists($tableClass) && !class_exists($tableClassLegacy) && $pathIndex < count($paths)) {
if ($tryThis = Path::find($paths[$pathIndex++], strtolower($type) . '.php')) {
// Import the class file.
include_once $tryThis;
}
}
}

if (!class_exists($tableClass) && class_exists($tableClassLegacy)) {
$tableClass = $tableClassLegacy;
}

if (!class_exists($tableClass)) {
/*
* If unable to find the class file in the Table include paths. Return false.
* The warning JLIB_DATABASE_ERROR_NOT_SUPPORTED_FILE_NOT_FOUND has been removed in 3.6.3.
* In 6.0 an Exception (type to be determined) will be thrown.
* For more info see https://github.com/joomla/joomla-cms/issues/11570
*/

return false;
}

// If a database object was passed in the configuration array use it, otherwise get the global one from Factory.
$db = $config['dbo'] ?? Factory::getContainer()->get(DatabaseInterface::class);

// Check for a possible service from the container otherwise manually instantiate the class
if (Factory::getContainer()->has($tableClass)) {
return Factory::getContainer()->get($tableClass);
}

// Instantiate a new table class and return it.
return new $tableClass($db);
}

Ok thks for this. The Joomla 5.0.1 have this fix from Joomla side. I have one problem now front end instead

Call to a member function getCompaniesByNameAndCategories() on bool

All issues solved and JBD and Joomla 5 is working fine. Joomla 5 is blazing fast!

the following worked for me (there are four syntax changes):  

public static function getInstance($type, $prefix = 'JTable', $config = [])
{
/**
* For B/C reasons we don't change the $prefix to \Joomla\CMS\Table\ since extensions which
* use JTable as table prefix instead of an own prefix and not adding 'JTable' as prefix will
* fail to load the table. We can't detect this situation.
* Example:
* class JTableMytable {}
* JTable::getInstance('Mytable');
* This will fail when we change the function default $prefix from JTable to \Joomla\CMS\Table\
*
* In case of $prefix is 'JTable' we make an additional check for '\Joomla\CMS\Table\' $type
*/

// Sanitize and prepare the table class name.
$type = preg_replace('/[^A-Z0-9_.-]/i', '', $type);

$tableClass = $prefix . ucfirst($type);
$tableClassLegacy = $tableClass;

if ($prefix === 'JTable') {
$tableClass = '\\Joomla\\CMS\\Table\\' . ucfirst($type);
}

// Only try to load the class if it doesn't already exist.
if (!class_exists($tableClass) && !class_exists($tableClassLegacy)) {
// Search for the class file in the JTable include paths.
$paths = self::addIncludePath();
$pathIndex = 0;

while (!class_exists($tableClass) && !class_exists($tableClassLegacy) && $pathIndex < count($paths)) {
if ($tryThis = Path::find($paths[$pathIndex++], strtolower($type) . '.php')) {
// Import the class file.
include_once $tryThis;
}
}
}

if (!class_exists($tableClass) && class_exists($tableClassLegacy)) {
$tableClass = $tableClassLegacy;
}

if (!class_exists($tableClass)) {
/*
* If unable to find the class file in the Table include paths. Return false.
* The warning JLIB_DATABASE_ERROR_NOT_SUPPORTED_FILE_NOT_FOUND has been removed in 3.6.3.
* In 6.0 an Exception (type to be determined) will be thrown.
* For more info see https://github.com/joomla/joomla-cms/issues/11570
*/

return false;
}

// Check for a possible service from the container otherwise manually instantiate the class
if (Factory::getContainer()->has($tableClass)) {
return Factory::getContainer()->get($tableClass);
}

// Instantiate a new table class and return it.
$db = isset($config['dbo']) ? $config['dbo'] : Factory::getContainer()->get(DatabaseInterface::class);
return new $tableClass($db);
}

Thank you, was about to roll back 

My site works with Joomla 4.4.0 but not with Joomla 5.0

I am getting this error : Class "\Joomla\CMS\Table\Company" not found

what to do

Did you install Joomla 5.0.1 ? It doesnt work with Joomla 5.0 yet and Joomla 5.0.1 is released 28th of November

https://github.com/joomla/joomla-cms/milestones

What we do for testing was to download the Nightly builds..

https://developer.joomla.org/nightly-builds.html

 

 
 
 

8 Item(s)

Show per page