Gargaj / wuhu

Lightweight Party Management System

Home Page:http://wuhu.function.hu/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MySQL 5.7 incompatibility

sesse opened this issue · comments

Hi,

It seems there's an SQL error with MySQL 5.7:

[Sat May 12 10:53:56.338737 2018] [:error] [pid 23535] [client 192.168.1.1:35380] PHP Fatal error:  Uncaught exception 'Exception' with message '<pre>\nMySQL ERROR:\nError: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'wuhu.votes_range.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by\nQuery: select * from votes_range group by userid' in /srv/wuhu/www_admin/sqllib.inc.php:56\nStack trace:\n#0 /srv/wuhu/www_admin/sqllib.inc.php(70): SQLLib::Query('select * from v...')\n#1 /srv/wuhu/www_admin/votesystem.inc.php(30): SQLLib::SelectRows('select * from v...')\n#2 /srv/wuhu/www_admin/index.php(20): VoteRange->GetVoteCount()\n#3 {main}\n  thrown in /srv/wuhu/www_admin/sqllib.inc.php on line 56

I would assume this is the code in question:

  function GetVoteCount()
  {
    $v = SQLLib::selectRows(sprintf_esc("select * from votes_range group by userid"));
    return count($v);
  }

I'd supply a patch, but I don't honestly know what this query is supposed to mean? What would GROUP BY without any aggregates mean?

OK, after reading the manual, I assume what you want is

SELECT COUNT(DISTINCT userid) FROM votes_range;

Yeah just send a PR.