I'm actually not sure how common an issue this would actually be but I guess for some it's actually somewhat common though this was actually the first time I had run into the issue myself with a Joomla extension.
I was trying out Christophe Demco's External Login extension and I ran into the following error after I installed the External Login package and visited the component's main page which gave me the following error:
Error
Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='
SQL=SELECT a.*,u.name AS editor,e.enabled AS enabled
FROM `#__externallogin_servers` as a
LEFT JOIN #__users AS u ON u.id=a.checked_out
LEFT JOIN #__extensions AS e ON `e`.`type`='plugin' AND CONCAT_WS('.', `e`.`folder`, `e`.`element`)=`a`.`plugin`
WHERE (a.published >= 0) ORDER BY a.title asc
LIMIT 20
Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='
SQL=SELECT COUNT(*)
FROM `#__externallogin_servers` as a
LEFT JOIN #__users AS u ON u.id=a.checked_out
LEFT JOIN #__extensions AS e ON `e`.`type`='plugin' AND CONCAT_WS('.', `e`.`folder`, `e`.`element`)=`a`.`plugin`
WHERE (a.published >= 0)
Which was related to these lines in that extension's code:
https://github.com/chdemko/joomla-external-login/blob/master/src/pkg_externallogin/com_externallogin/admin/models/servers.php#L102-L105
First I looked at my database and did notice that Christophe's code used a different collation compared to what my other tables had:
https://github.com/chdemko/joomla-external-login/blob/master/src/pkg_externallogin/com_externallogin/admin/sql/install.mysql.utf8.sql#L21
So I spent a bit of time in the morning recreating all of the tables with a uniform collation but the error continued even after I thought everything had been set correctly.
Then I started looking into it more in depth and my thought was that it somehow had something to do with the '.' concatenation separator being used.
I then tested this theory and it seemed to work.
Lines before changes:
$query->join('LEFT', '#__extensions AS e ON ' .
$db->quoteName('e.type') . '=' . $db->quote('plugin') . ' AND ' .
$query->concatenate(array($db->quoteName('e.folder'), $db->quoteName('e.element')), '.') . '=' . $db->quoteName('a.plugin')
);
Lines after changes:
$query->join('LEFT', '#__extensions AS e ON ' .
$db->quoteName('e.type') . '=' . $db->quote('plugin') . ' AND ' .
"CONCAT_WS('.' COLLATE " . $db->getCollation() . ', ' . $db->quoteName('e.folder') . ', ' . $db->quoteName('e.element') .')' . '=' . $db->quoteName('a.plugin')
);
What I added specifically was the COLLATE part for the separator which explicitly casts it to use the same one as the database instead of the implicit (incorrect) one it was choosing automatically.
I needed to add in the CONCAT_WS() call manually because currently the concatenate() query method doesn't provide a good way of passing in the collation so this might require some more thought to correct within the JDatabaseQueryMysqli class so I thought I'd share here.
The External Login component page to open normally in the Admin area.
The error shown above.
Joomla 3.6.5
PHP 7.0.9
MariaDB 10.1.16
Joomla Database and all Tables set to utf8mb4_unicode_ci collation
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-03-07 04:00:02 |
Closed_By | ⇒ | orware |
I tried again using a fresh Joomla 3.6.5 install and didn't have any trouble so I'm chalking this issue up to Joomlart's Quickstart package I utilized from one of their free templates to get started the other day with a new project.