View Issue Details

IDProjectCategoryView StatusLast Update
0023746mantisbtapi soappublic2018-02-06 21:17
Reporterchadmiss Assigned Tovboctor  
PrioritynormalSeverityblockReproducibilityhave not tried
Status closedResolutionfixed 
Product Version2.9.0 
Target Version2.10.1Fixed in Version2.10.1 
Summary0023746: unable to create a bug with customfields via SOAP
Description

using Mantis 2.9.0, mantisconnect via PHP

when creating a bug with mc_issue_add, while the issue data contains customfields, the server side throws an error "Cannot use object of type stdClass as array".
(ticket is created anyway but without any data in customfields)

After further debugging I find the error triggers in api/soap/mc_issue_api lines 1055 - 1058

 $t_cf_result = mci_project_custom_fields_validate( $t_project_id, $p_issue['custom_fields'] );
        if( ApiObjectFactory::isFault( $t_cf_result ) ) {
                return $t_cf_result;
        }

When disabling these lines it works

the function mci_project_custom_fields_validate() get the parameter $p_custom_fields as object but it is expecting at as array. thus line 674 in api/soap/mc_project_api.php

foreach( $p_custom_fields as $t_custom_field ) {

crashes with the aforementioned error.

client side this short script to create a bug is used (Custom-field "Prio" is a simple integer input):

<?php

        $mantis = new soapclient("path_to_wsdl");

/* tried also to send custom_field data as stdClass
        $cf = new stdClass();
        #$cf->field = new stdClass();
        $cf->field["name"] = "Prio";
        $cf->value = 1;
*/

        $cf = array();
        $cf["field"] = array("name" => "Prio");
        $cf["value"] = "1";

        $t_issue = array(       'handler' => array( 'id' => 160),
                                'project' => array( 'id' => 218),
                                'summary' => "Test Mantis-SOAP-API",
                                'description' => "Test",
                                'reproducibility' => array('id' =>  10),
                                'additional_information' => "...",
                                'view_state' => array('id' => 10),
                                'severity' => array('id' => 10), 
        'priority' => array('id' => 10),
        'category' => 'Interface',
        'custom_fields' => array($cf)
        );

         try {
               $result = $mantis->mc_issue_add("user", "pass", $t_issue);

                var_dump($result);

        } catch(SoapFault $e) {
                var_dump($e);
        }
TagsNo tags attached.
Attached Files

Relationships

related to 0023577 closedvboctor REST APIs don't enforce required custom fields when reporting issues 
has duplicate 0023833 closed return error when calling mc_issue_add with custom_fields 

Activities

chadmiss

chadmiss

2017-12-21 04:48

reporter   ~0058435

sorry for bad formatting of the code chunks :(

dregad

dregad

2017-12-21 05:28

developer   ~0058436

sorry for bad formatting of the code chunks :(

Fixed.

rombert

rombert

2018-01-12 05:32

reporter   ~0058529

Multiple reports, setting to acknowledged. Moreover, this seems to be a regression from 2.8.0 . @vboctor, is this maybe related to your recent work on the REST API?

dregad

dregad

2018-01-12 08:45

developer   ~0058534

Using the provided test script, git bisect traces introduction of the bug to MantisBT master 03db938d

 ~/dev/mantisbt(master) $ git bisect start release-2.9.0 release-2.8.0
Bisecting: 47 revisions left to test after this (roughly 6 steps)
[b109e2fd52925bb73396c90eb954896ebe05eaaa] Use config_get_global for file_type_icons

~/dev/mantisbt((b109e2fd5...)|BISECTING) $ git bisect run test_23746.php
running test_23746.php
Bisecting: 23 revisions left to test after this (roughly 5 steps)
[16aa170ff6e9348cf85bcd1fc37b7cc78ec35f0c] Use config_get_global for cookie_time_length
running test_23746.php
Bisecting: 11 revisions left to test after this (roughly 4 steps)
[0bfa11aa75113861ab60eca56d712599ccfbf3f5] Merge branch 'master-2.8'
running test_23746.php
Bisecting: 5 revisions left to test after this (roughly 3 steps)
[23eb41a7936b1aa495884770a0f5893a89080bf8] Fix email error when reporting issues with date field
running test_23746.php
Bisecting: 2 revisions left to test after this (roughly 2 steps)
[0e071b6784a56f90e2f2a23bf031224972c949b2] Return 400 when category doesn't exist
running test_23746.php
Bisecting: 0 revisions left to test after this (roughly 1 step)
[8b9b2a3227ff908265f492a31a3d60a2172ab7aa] Fix handling custom date fields with value `{now}`
running test_23746.php
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[03db938d703dcd57abd004103414bf673faa6ab6] Ensure required custom fields specified on create issue
running test_23746.php
03db938d703dcd57abd004103414bf673faa6ab6 is the first bad commit
commit 03db938d703dcd57abd004103414bf673faa6ab6
Author: Victor Boctor <victor@mantishub.net>
Date:   Sun Nov 5 05:14:08 2017 +0000

    Ensure required custom fields specified on create issue

    Fixes #23577

:040000 040000 39edf6bf0b57e74e603ed0527d15e6b5c122fe08 591af4065b3d36191a29157272bee53a67c34856 M      api
bisect run success
vboctor

vboctor

2018-01-12 20:25

manager   ~0058535

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

vboctor

vboctor

2018-01-12 20:46

manager   ~0058536

@chadmiss @tuanklnew can you please confirm if the fix in the pull request below addresses the issue for you:
PR: https://github.com/mantisbt/mantisbt/pull/1268

tuanklnew

tuanklnew

2018-01-13 01:01

reporter   ~0058537

Yes, it works. Once again thank for that.

fixed.PNG (17,114 bytes)   
fixed.PNG (17,114 bytes)   
mantisiator

mantisiator

2018-01-18 03:50

reporter   ~0058555

Hi,
Thanks a lot for the fix . I have integrated the patch in 2.9.0 and it works fine. Do you know in which version this is planned ot be merged to ?

atrol

atrol

2018-01-18 03:59

developer   ~0058557

Do you know in which version this is planned ot be merged to ?

It's merged to branch master-2.10, so it will be part of release 2.10.1.

Todo: Merge to master to have it also in 2.11.0

Related Changesets

MantisBT: master-2.10 9d7be13a

2018-01-12 15:24

vboctor


Details Diff
Fix create a bug with custom fields via SOAP

Fixes 0023746
Affected Issues
0023746
mod - api/soap/mc_project_api.php Diff File