Page 1 of 1

"Limit reporter access" feature (Broken?) in MANTIS 1.2.0a1

Posted: 19 Jun 2008, 15:40
by iceninja
When I turn on the feature

(I've put the line
$g_limit_reporters = ON;
in the config_inc.php file)

any user with a reporter profile gets the following error after login


APPLICATION ERROR #401

Database query failed. Error received from database was #1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? AND mantis_project_table.id = mantis_bug_table.project_id AND ( ( mantis_bug_t' at line 3 for the query: SELECT Count(DISTINCT mantis_bug_table.id) as idcnt FROM mantis_project_table, mantis_bug_table

WHERE mantis_project_table.enabled = ? AND mantis_project_table.id = mantis_bug_table.project_id AND ( ( mantis_bug_table.project_id = 1 ) AND ( ( mantis_bug_table.view_state = 10 ) OR ( mantis_bug_table.reporter_id = 3 ) ) ) AND (mantis_bug_table.reporter_id=?) AND ( mantis_bug_table.handler_id=0 ) AND ( mantis_bug_table.status in (?, ?, ?, ?, ?, ?) )


Any ideas?

Thanks

Re: "Limit reporter access" feature (Broken?) in MANTIS 1.2.0a1

Posted: 19 Jun 2008, 18:08
by vzw614
It looks like there is a problem with some variables in the query not being replaced properly, hence all of the question marks. Check the database and see what data type the column mantis_bug_table.enabled is and then check the php code and make sure that those data types match. It might be something as simple as the database field being specified as a bool and variable in the php code is an int.

Re: "Limit reporter access" feature (Broken?) in MANTIS 1.2.0a1

Posted: 21 Jun 2008, 18:23
by iceninja
Thanks for the reply.
I made a fresh install of the Mantis 1.2.0a1 using MySQL 5.051b and PHP Version 5.2.6 and I haven't made any software changes.

Any ideas?

Re: "Limit reporter access" feature (Broken?) in MANTIS 1.2.0a1

Posted: 23 Jun 2008, 10:56
by iceninja
Following your hint I've found that the problem is due to an incorrect definition in a PHP variable.

So I've made the following changes in the file /core/filter_api.php:

Line 663:
Where is

Code: Select all

  $t_where_params = $c_reporter_id;
Replaced by

Code: Select all

$t_where_params[] = $c_reporter_id;
line 1372-1376:
Where is

Code: Select all

     $t_from_clauses = array( $t_bug_text_table, $t_project_table, $t_bug_table );
    } else {
     $t_from_clauses = array( $t_project_table, $t_bug_table );
Replaced by

Code: Select all

     $t_from_clauses = array_merge( array( $t_bug_text_table, $t_project_table, $t_bug_table ), $t_from_clauses );
    } else {
     $t_from_clauses = array_merge( array( $t_project_table, $t_bug_table ), $t_from_clauses );
I think that in the next Mantis version (maybe 1.2.0a2) this problem will be corrected.

Thanks for your suggestions.