I am using a third-party application that works fine in my local development environment (uses MariaDB 10.4 with a reported drop-in compatibility for MySQL 5.7 [1]), but crashes in my deployment environment (uses MySQL server v8.0.27).
I could pinpoint the problem to the following MySQL query:
SELECT DISTINCT user_id,title,description,posted,expire,thumbnail,(SELECT MAX(us.id) FROM Wo_UserStory us WHERE us.user_id = Wo_UserStory.user_id) AS id FROM Wo_UserStory WHERE (user_id IN (SELECT following_id FROM Wo_Followers WHERE follower_id = '1') OR user_id = 1) AND user_id IN (SELECT user_id FROM Wo_Users WHERE active = '1') GROUP BY user_id ORDER BY id DESC LIMIT 4
which causes a 500 internal system error. When I execute this query in phpmyadmin, I get the error:
#1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'wowonder.Wo_UserStory.title' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
Reading further about this, I decided to remove ONLY_FULL_GROUP_BY from the flags inside the variable "sql mode". This did not solve my problem, and caused an application crash earlier in the execution flow.
So, how do I make this work in MySQL v8? Downgrading to MySQL v5.7 in my deployment server is not an option.
[1] https://mariadb.com/kb/en/mariadb-vs-mysql-compatibility/