I’ve finally repaired my website, including EB (with ChatGPT). It was using a lot of code that’s no longer allowed in Joomla 5.
Here’s a step-by-step guide I’ve put together.
🧩 Fixing EasyBlog on Joomla 5 — Complete Technical Guide
Problem:
After upgrading Joomla 4 → 5, the EasyBlog component throws fatal errors such as:
Compile Error: Cannot redeclare EasyBlogDbCompat::query()
TypeError: Table::getDatabase() must return DatabaseInterface, EasyBlogDbCompat returned
Call to undefined method Joomla\Database\Mysqli\MysqliDriver::nameQuote()
Call to undefined method Joomla\Database\Mysqli\MysqliDriver::getErrorNum()
A query must be a string or QueryInterface, array given
These happen because EasyBlog versions prior to Joomla 5 compatibility still use legacy database helpers that are no longer supported in J5.
🧰 Environment
Joomla 5.x
EasyBlog ≤ 6.0.x
PHP 8.1–8.3
Linux host with SSH or file access (PuTTY / Visual Studio Code)
🧾 1. Identify the root cause
Why it breaks
Joomla 5 completely removed its old JDatabase layer.
EasyBlog still calls methods such as:
$db = new EasyBlogDbJoomla();
$db->query();
$db->getErrorNum();
$db->getErrorMsg();
$db->stderr();
$db->nameQuote();
Those no longer exist under the new Joomla\Database namespace.
🧩 2. Fix the EasyBlog database driver
File:
administrator/components/com_easyblog/includes/easyblog.php
Before:
$db = new EasyBlogDbJoomla();
After:
use Joomla\CMS\Factory;
use Joomla\Database\DatabaseInterface;
if (version_compare(JVERSION, '5.0', '>=')) {
// Use Joomla 5 native database driver
$db = Factory::getContainer()->get(DatabaseInterface::class);
} else {
// Fallback for older Joomla versions
$db = new EasyBlogDbJoomla();
}
This ensures EasyBlog retrieves the native J5 database connection.
🧮 3. Replace removed database methods
Search recursively inside EasyBlog:
cd /path/to/joomla/root
grep -Rni -- "getErrorNum" administrator/components/com_easyblog components/com_easyblog
grep -Rni -- "getErrorMsg" administrator/components/com_easyblog components/com_easyblog
grep -Rni -- "stderr" administrator/components/com_easyblog components/com_easyblog
grep -Rni -- "nameQuote" administrator/components/com_easyblog components/com_easyblog
grep -Rni -- "loadResultArray" administrator/components/com_easyblog components/com_easyblog
Replace each legacy call as follows:
Legacy call (old) Modern replacement (Joomla 5)
$db->query(); $db->setQuery($sql)->execute();
$db->nameQuote($col); $db->quoteName($col);
$rows = $db->loadResultArray(); $rows = $db->loadColumn();
if ($db->getErrorNum() > 0) use a try { ... } catch (\RuntimeException $e) block
$db->stderr() / $db->getErrorMsg() $e->getMessage() inside catch
Example fix:
try {
$db->setQuery($query);
$result = $db->loadObjectList();
} catch (\RuntimeException $e) {
throw EB::exception($e->getMessage(), $e->getCode() ?: 500);
}
🧠 4. Remove or rename duplicated methods
If you see:
Cannot redeclare EasyBlogDbCompat::query()
open administrator/components/com_easyblog/includes/easyblog.php
and delete or comment out the duplicate public function query($sql) definition.
Joomla 5 drivers already provide query() via the native API.
⚙️ 5. Fix array queries
Some old code built queries as arrays:
$query = [];
$query[] = 'SELECT * FROM ...';
$query[] = 'WHERE ...';
$db->setQuery($query); // ❌ Fatal in J5
Fix:
if (is_array($query)) {
$query = implode(' ', $query);
}
$db->setQuery($query);
$rows = $db->loadObjectList();
🧼 6. Clear Joomla caches
After every change:
rm -rf administrator/cache/
rm -rf cache/
Then reload the front-end and admin side.
🧪 7. Verify component and plugins
Re-enable all EasyBlog plugins (System → Manage → Plugins → EasyBlog *).
Check blog front-end (index.php?option=com_easyblog).
Check back-end dashboard.
Review browser console & PHP error logs — they should be clean.
✅ 8. Summary of modern Joomla 5 equivalents
Joomla 3/4 Legacy Joomla 5 Modern API
$db->query() $db->setQuery($sql)->execute()
$db->loadResultArray() $db->loadColumn()
$db->nameQuote('col') $db->quoteName('col')
$db->getErrorNum() / $db->getErrorMsg() try { ... } catch (RuntimeException $e)
$db = new EasyBlogDbJoomla() $db = Factory::getContainer()->get(DatabaseInterface::class)
$query = [] arrays $query = implode(' ', $query)
💡 Tips for debugging
use Joomla\CMS\Factory;
$db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);
Factory::getApplication()->enqueueMessage('SQL: ' . $db->replacePrefix($query));
or enable Joomla debug mode (Global Configuration → System → Debug System).
🚀 Result
After these adjustments:
No more EasyBlogDbCompat redeclarations
No missing nameQuote(), getErrorNum(), or query() methods
Front-end & back-end fully functional under Joomla 5