Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b3276bb

Browse files
committedFeb 25, 2013
Fix crash when report_bug_threshold=array in access_has_bug_level
When displaying a bug for which the user is not the reporter, $g_limit_reporters=ON and the workflow is set so report_bug_threshold is an array, MantisBT crashes with "PHP Fatal error: Unsupported operand types". This is due to use of '+ 1' to indicate that user should have the next higher access level to view the issue. We now use the same logic but within a foreach loop to check against each array element. Fixes #15538
1 parent 73317ba commit b3276bb

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed
 

‎core/access_api.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,20 @@ function access_has_bug_level( $p_access_level, $p_bug_id, $p_user_id = null ) {
422422
# reporters can view just issues they reported
423423
$t_limit_reporters = config_get( 'limit_reporters', null, $p_user_id, $t_project_id );
424424
$t_report_bug_threshold = config_get( 'report_bug_threshold', null, $p_user_id, $t_project_id );
425-
if ( $t_limit_reporters && !bug_is_user_reporter( $p_bug_id, $p_user_id ) && !access_has_project_level( $t_report_bug_threshold + 1, $t_project_id, $p_user_id ) ) {
426-
return false;
425+
if( !is_array( $t_report_bug_threshold ) ) {
426+
$t_report_bug_threshold = array( $t_report_bug_threshold );
427+
}
428+
if( $t_limit_reporters && !bug_is_user_reporter( $p_bug_id, $p_user_id ) ) {
429+
$t_has_access = false;
430+
foreach( $t_report_bug_threshold as $t_threshold ) {
431+
if( access_has_project_level( $t_threshold + 1, $t_project_id, $p_user_id ) ) {
432+
$t_has_access = true;
433+
break;
434+
}
435+
}
436+
if( !$t_has_access ) {
437+
return false;
438+
}
427439
}
428440

429441
# If the bug is private and the user is not the reporter, then

0 commit comments

Comments
 (0)
Please sign in to comment.