Closed mikesname closed 7 years ago
I thought there would be a problem with this once I'd initially heard about the 5.7 mode changes... Omeka is definitely dependent on the old nonstandard MySQL handling of GROUP BY in several places.
Fixing the queries or manually setting the SQL mode ourselves on startup are really the only options here, I think. I've tried to avoid setting the mode in the past.
Setting the mode on startup sounds good to me. Currently I've worked around this by doing:
SET GLOBAL sql_mode=(SELECT REPLACE(@@GLOBAL.sql_mode,'ONLY_FULL_GROUP_BY',''));
@mikesname Where did you implement this change?
@anuragji by setting the sql_mode
global in a root session, and adding this to /etc/my.cnf
so it sticks on restarts:
# Workaround Omeka problem with ONLY_FULL_GROUP_BY
sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
There may well be a better way to do it!
Thanks @mikesname - while there may be better ways, this one worked for me :)
I'm somewhat reluclant to go with the workaround, but I think nevertheless it's a good idea to include it in a 2.4 bugfix, as this is just going to get more relevant as more hosts upgrade MySQL and fixing the actual queries won't happen fast.
Also since it requires modifying the MySQL configuration itself, rather then being resolved within Omeka, it brings it's own set of related issues.
The Omeka-side solution would use this: https://github.com/omeka/Omeka/blob/master/application/libraries/Omeka/Test/Resource/Db.php#L86
Currently that's just being used to make sure we test against strict modes and things like that for the automated tests, but we could set it (even using that exact mode) in normal usage, too, to guarantee the mode's always the same for all users.
Let me know how that works for you.
On Ubuntu 16.04 LTS and probably Debian Jessie, you have to add the workaround to /etc/mysql/mysql.conf.d/mysqld.cnf just under the [mysqld] line. Restart MySQL with service mysql restart
if needed.
I can verify that caa's advice solves the problem on Ubuntu 16.04.
I've just ran into a MySQL 5.7 compatibility issue with Omeka 2.3.1 and 2.4, specifically with the default ONLY_FULL_GROUP_BY behaviour since MySQL 5.7.5. Specifically, sorting items by title (at say
/items/browse?sort_field=Dublin+Core%2CTitle
) results in this error:I'll try and add more details tomorrow when I get a chance to investigate further.