partkeepr / PartKeepr

Open Source Inventory Management
http://www.partkeepr.org
GNU General Public License v3.0
1.38k stars 401 forks source link

getPartParameterNames: Internal Server Error #842

Open turdusmerula opened 7 years ago

turdusmerula commented 7 years ago

Hello, I am running a partkeepr 1.2 inside a docker container with apache2, a mysql database and PHP7.0.

I am having an error when I try to add some parameter inside a metapart, the parameter list stays empty and I can see this error from extjs.js:22

GET http://127.0.0.1:8080/api/parts/getPartParameterNames?_dc=1491261981904&page=1&start=0&limit=25 500 (Internal Server Error) {"@type":"Error","hydra:title":"An error occurred","hydra:description":"Internal Server Error"}

Is there any known issue with this functionality?

Drachenkaetzchen commented 7 years ago

No, it's not a known issue. If you get an error 500 you should have a look in app/logs/partkeepr.log to see what's going on

turdusmerula commented 7 years ago

I found this error inside partkeepr.log, request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occurred while executing 'SELECT p0_.name AS name_0, p0_.description AS description_1, p0_.valueType AS valueType_2, u1_.name AS name_3, u1_.symbol AS symbol_4 FROM PartParameter p0_ LEFT JOIN Unit u1_ ON p0_.unit_id = u1_.id GROUP BY p0_.name, p0_.description, p0_.valueType, u1_.name': SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'partkeepr.u1_.symbol' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by" at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 115 {"exception":"[object] (Doctrine\\DBAL\\Exception\\DriverException(code: 0): An exception occurred while executing 'SELECT p0_.name AS name_0, p0_.description AS description_1, p0_.valueType AS valueType_2, u1_.name AS name_3, u1_.symbol AS symbol_4 FROM PartParameter p0_ LEFT JOIN Unit u1_ ON p0_.unit_id = u1_.id GROUP BY p0_.name, p0_.description, p0_.valueType, u1_.name':\n\nSQLSTATE[42000]: Syntax error or access violation: 1055 Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'partkeepr.u1_.symbol' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:115, Doctrine\\DBAL\\Driver\\PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'partkeepr.u1_.symbol' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:106, PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'partkeepr.u1_.symbol' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:104)"} []

I suspect a requirement mismatch, which version of PHP is strongly recommended for partkeepr?

Drachenkaetzchen commented 7 years ago

PHP isn't the cause, it's MySQL. See http://stackoverflow.com/questions/23921117/disable-only-full-group-by

I'm not sure if sql_mode=only_full_group_by is default on MySQL 5.7, this needs to be investigated

Drachenkaetzchen commented 7 years ago

It seems that not only MySQL 5.7.5 does implement only_full_group_by, but it's enabled by default:

https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html

So right now, PartKeepr is not compatible with an out-of-the-box MySQL 5.7.5. Users should either downgrade to an earlier version of MySQL or set sql_mode' withoutonly_full_group_by`.

turdusmerula commented 7 years ago

By following the stackoverflow answer this works now. I added this command in my setup: SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

This is effectively a requirement problem related to MySQL 5.7 and not PHP, but with this patch it works well.

baradhili commented 4 years ago

Is this now fixed in 1.4?

christianlupus commented 4 years ago

Nope, the text ONLY_FULL_GROUP_BY is not in the current code base. If someone might want to do a small PR, you are welcome :)

baradhili commented 4 years ago

I think @turdusmerula 's answer resolves this

christianlupus commented 4 years ago

@baradhili Don't you think this should be done in the setup script to ensure that the variable is set correctly?

baradhili commented 4 years ago

@christianlupus point taken.. I was thinking this was something done by the user.. not default in mysql 5.7