View Issue Details

IDProjectCategoryView StatusLast Update
0024877mantisbtbugtrackerpublic2019-01-02 17:25
ReportervboctorAssigned Tovboctor 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.18.0 
Target Version2.19.0Fixed in Version2.19.0 
Summary0024877: IssueNoteAddCommand: reassign_on_feedback doesn't work if reporter is not specified
Description

The web UI and REST API provide the reporter explicitly, but if not, and the id is retrieved from logged in user, the user id can be a string instead of an integer which causes the following check to fail:

        if( config_get( 'reassign_on_feedback' ) &&
            $this->issue->status === config_get( 'bug_feedback_status' ) &&
            $this->issue->handler_id !== $this->reporterId &&
            $this->issue->reporter_id === $this->reporterId ) {
            if( $this->issue->handler_id !== NO_USER ) {
                bug_set_field( $this->issue->id, 'status', config_get( 'bug_assigned_status' ) );
            } else {
                bug_set_field( $this->issue->id, 'status', config_get( 'bug_submit_status' ) );
            }
        }

The specific check that fails is: $this->issue->reporter_id === $this->reporterId due to the issue reporter id being an integer and the $this->reporterId being a string.

The workaround is to set the reporter explicitly.

Steps To Reproduce

Here a sample script that reproduces the problem. Note that includes are excluded.

auth_attempt_script_login( 'someuser' );

$t_issue_id = 1;
$t_note_text = 'test comment';

$t_payload = array(
    'text' => $t_note_text
);

$t_data = array(
    'query' => array( 'issue_id' => $t_issue_id ),
    'payload' => $t_payload
);

$t_command = new IssueNoteAddCommand( $t_data );
$t_result = $t_command->execute();
$t_note_id = $t_result['id'];   

echo "added note $t_note_id";
TagsNo tags attached.

Relationships

related to 0023712 closedvboctor auth_get_current_user_id can return strings while that is not expected 

Activities

vboctor

vboctor

2018-10-21 00:33

manager   ~0060835

PR: https://github.com/mantisbt/mantisbt/pull/1401

atrol

atrol

2018-10-21 03:38

developer   ~0060836

@vboctor do you think that 0023712 and https://mantisbt.org/forums/viewtopic.php?f=3&t=25080 are the same issue like this one?
In both cases I didn't understand / find how it can happen that the user id is a string.

vboctor

vboctor

2018-10-22 01:33

manager   ~0060839

@atrol yes, I have updated the PR to reflect that in the commit message and added a couple of extra defensive fixes.

vboctor

vboctor

2018-10-22 01:41

manager   ~0060840

I have pushed the changes to the source branch but github didn't pick it up in the PR due to semi-outage issues. Changes can be viewed at:
https://github.com/vboctor/mantisbt/commits/issue24877_fix_user_id_type

vboctor

vboctor

2018-10-28 17:41

manager   ~0060867

@atrol are you ok with merging this PR?

atrol

atrol

2018-10-29 18:45

developer   ~0060873

I approved the PR.

Related Changesets

MantisBT: master 183a4a94

2018-10-21 00:32:20

vboctor

Details Diff
Fix IssueNoteAddCommand re-assign on feedback

The issue was caused by logged in user id being returned as a string.

Fixes 0024877, 0023712
Affected Issues
0023712, 0024877
mod - core/authentication_api.php Diff File
mod - core/current_user_api.php Diff File
mod - core/user_api.php Diff File

Issue History

Date Modified Username Field Change
2018-10-21 00:30 vboctor New Issue
2018-10-21 00:30 vboctor Status new => assigned
2018-10-21 00:30 vboctor Assigned To => vboctor
2018-10-21 00:33 vboctor Note Added: 0060835
2018-10-21 03:38 atrol Note Added: 0060836
2018-10-22 01:25 vboctor Relationship added related to 0023712
2018-10-22 01:33 vboctor Note Added: 0060839
2018-10-22 01:41 vboctor Note Added: 0060840
2018-10-28 17:41 vboctor Note Added: 0060867
2018-10-29 18:45 atrol Note Added: 0060873
2018-10-29 18:57 vboctor Changeset attached => MantisBT master 183a4a94
2018-10-29 18:57 vboctor Status assigned => resolved
2018-10-29 18:57 vboctor Resolution open => fixed
2018-10-29 18:57 vboctor Fixed in Version => 2.19.0
2019-01-02 17:25 vboctor Status resolved => closed