Application Error #401 - Time Tracking

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
PixelBoxes
Posts: 6
Joined: 12 Oct 2018, 19:39

Application Error #401 - Time Tracking

Post by PixelBoxes »

Hello again all,

I'm back with another error that is beyond my knowledge scope and I unfortunately have not been able to find a clear or direct answer/fix for my issue while browsing the forums. Hopefully someone here may be able to shed some light on this!

First, I know Mantis supports MySQL but we are using MSSQL 2016 and it has been working splendidly until this new problem. I appreciate any help that can be given.

System Specs
MantisBT version 2.17.1 on a fresh Hyper-V VM in Server 2012 R2 Standard in IIS 8.5.
2 virtual processors | 4GB of RAM
SQL Server 2016 as database software
PHP versions installed are v5.3 and v7.2 with v7.2 the one being utilized.

The Problem
After enabling the Time Tracking feature, I discovered that it appears to work fine when I go to Time Tracking on the left window area and search, but when I am inside of a ticket (having clicked on a ticket number) and then go to Time Tracking, I get the following error - -
APPLICATION ERROR #401

Database query failed. Error received from database was #8120: SQLState: 42000
Error Code: 8120
Message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Column 'mantis_user_table.id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
for the query: SELECT u.id AS user_id, username, realname, SUM(time_tracking) AS sum_time_tracking
FROM mantis_user_table u, mantis_bugnote_table bn
WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND
bn.bug_id = ? AND bn.date_submitted >= 1551852000 AND bn.date_submitted <= 1552024799 GROUP BY u.username, u.realname.

Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.
One minor difference I wanted to point out (which may be nothing) was that when I look at the Time Tracking from within the ticket, there is a little box with a + sign in it next to the words "Time Tracking" that I assume was meant to be expanded, but does nothing when I click it.
TimeTracking.PNG
TimeTracking.PNG (14.57 KiB) Viewed 4038 times

Thank you in advance for any assistance!
cas
Posts: 1586
Joined: 11 Mar 2006, 16:08
Contact:

Re: Application Error #401 - Time Tracking

Post by cas »

I have seen this before on MYSQL and could overcome that by using the following statement on the database:
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''))

Apparently MSSQL has a similar issue, see here:
https://stackoverflow.com/questions/271 ... group-by-c

Theer is more to find via your friend google, just serach for "mssql 8120: SQLState: 42000".
PixelBoxes
Posts: 6
Joined: 12 Oct 2018, 19:39

Re: Application Error #401 - Time Tracking

Post by PixelBoxes »

Thank you Cas! I'll pass this info over to one of our SQL people to see if they can try to resolve this issue. I had tried to Google the issue, but I was more going straight at it as a Mantis error and not directly the SQL one - my fault there.

I'll post back with the results ASAP.
PixelBoxes
Posts: 6
Joined: 12 Oct 2018, 19:39

Re: Application Error #401 - Time Tracking

Post by PixelBoxes »

Confirmed that the Stack Overflow answer was correct. Our SQL fellow stated this is how the issue was fixed on our end.

Under MantisBT\core\bugnote_api.php > function_bugnote_stats_get_events_array > $t_query section > added u.id to the GROUP BY list.

Original Code
$t_query = 'SELECT u.id AS user_id, username, realname, SUM(time_tracking) AS sum_time_tracking FROM {user} u, {bugnote} bn WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = ' . db_param() . $t_from_where . $t_to_where . ' GROUP BY u.username, u.realname';
New Code
$t_query = 'SELECT u.id AS user_id, username, realname, SUM(time_tracking) AS sum_time_tracking FROM {user} u, {bugnote} bn WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = ' . db_param() . $t_from_where . $t_to_where . ' GROUP BY u.id, u.username, u.realname';
Thank you again for your help Cas! :D
Post Reply