Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 Response on clients-membership-requests.php #590

Closed
KILLERJC opened this issue Jun 7, 2018 · 3 comments
Closed

500 Response on clients-membership-requests.php #590

KILLERJC opened this issue Jun 7, 2018 · 3 comments

Comments

@KILLERJC
Copy link

KILLERJC commented Jun 7, 2018

Type

This is a:

[X] Bug report

[] Feature request

Description of the problem

Lack of english language so my response will be short.
500 Internal Server Error when try to access clients-membership-requests.php from admin panel.

List the steps to reproduce the issue

  1. Access as admin
  2. Try to access it by the menu

Environment

  • ProjectSend version: r1053
  • php version: 7.0.27-0+deb9ui
  • MySQL version: 10.1.26-MariaDB-0+deb9u1

Additional information

I commented where it execute a SQL sentence and it finally the page worked (fully load). I put some echo and var_dump to see the content that use the SQL sentence too, to try to understand why is failing.

Code commented (near line 215):

	$count_sql	= $dbh->prepare( $tq );
	$tq_row		= $count_sql->execute($params);
	$tq_row		= $count_sql->fetch();
	$count_for_pagination = $tq_row['client_id'];

Dump of tq,cq and params vars:

tq:
SELECT client_id, COUNT(group_id) as amount, GROUP_CONCAT(group_id SEPARATOR ',') AS groups FROM tbl_members_requests WHERE denied='0' GROUP BY client_id LIMIT 0 UNION ALL SELECT COUNT(DISTINCT client_id) as clients, COUNT(group_id) as total, null FROM tbl_members_requests WHERE denied='0'

cq:
SELECT client_id, COUNT(group_id) as amount, GROUP_CONCAT(group_id SEPARATOR ',') AS groups FROM tbl_members_requests WHERE denied='0' GROUP BY client_id

params:
array(0) { }

PHP error:

This is the error i get on prepare() line:

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1221 Incorrect usage of UNION and LIMIT in /var/www/html/projectsend/clients-membership-requests.php:223 Stack trace: #0 /var/www/html/projectsend/clients-membership-requests.php(223): PDO->prepare('SELECT client_i...') #1 {main} thrown in /var/www/html/projectsend/clients-membership-requests.php on line 223

phpmyadmin give me the same error

I hope this info will help, i use to program microcontrollers in C, no experience in SQL or PHP, so this is something out of my league.

@KILLERJC
Copy link
Author

KILLERJC commented Jun 12, 2018

Maybe is not the correct solution but.... On MariaDB documentation:

ORDER BY and LIMIT
Individual SELECTs can contain their own ORDER BY and LIMIT clauses. In this case, the individual queries need to be wrapped between parentheses.

Adding parentheses on the first SELECT of the query solve the issue.

(SELECT client_id, COUNT(group_id) as amount, GROUP_CONCAT(group_id SEPARATOR ',') AS groups FROM tbl_members_requests WHERE denied='0' GROUP BY client_id LIMIT 0) UNION ALL SELECT COUNT(DISTINCT client_id) as clients, COUNT(group_id) as total, null FROM tbl_members_requests WHERE denied='0'

And now show the new request fine.

@ignacionelson
Copy link
Collaborator

This was solved on #571 by the user ofrzeta :)
Thank you for the report!!

@KILLERJC
Copy link
Author

Sorry my bad, i searched on open issues and couldn't find anything similar. And im new to git, so i will look also on the code next time, to verify if you or somebody else solved it before.

Thank for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants