View Issue Details

IDProjectCategoryView StatusLast Update
0023337mantisbtapi soappublic2017-12-01 20:14
Reportermantisiator Assigned Torombert  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionno change required 
Product Version2.0.0 
Summary0023337: mc_filter_search_issues returns too many issues when called via curl
Description

Hi all,
When calling a Webservice in order to retrieve the (unique) issue Id asssociated to a custom field value and a project id, the function returns too many issues, as if the filter (described hereafter) was not working.

Does someone has any hint please ?

Thank you very much in advance !

<?xml version="1.0" encoding="UTF-8"?>

-<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-<soap:Body>
-<mc_filter_search_issues xmlns="http://mywebsite.fr/api/soap/mantisconnect/">

<username>XXXX</username>
<password>YYYY</password>
-<filter>
-<project_id>
<item>11</item>
</project_id>
-<custom_fields>
-<item>
-<field>
<id>67</id>
</field>
-<value>
<item>8759</item>
</value>
</item>
</custom_fields>
</filter>
</mc_filter_search_issues>
</soap:Body>
</soap:Envelope

TagsNo tags attached.

Activities

rombert

rombert

2017-09-10 15:20

reporter   ~0057658

Seems this is broken, indeed.

rombert

rombert

2017-09-10 15:39

reporter   ~0057659

@mantisiator - this works in my limited tests with 2.6.0 . Can you retry with an updated version or provide a reproducible test case?

Thanks.

mantisiator

mantisiator

2017-09-10 20:14

reporter   ~0057664

Hi @rombert,
I have started the above script getBRtitle.xml with the command:

curl -d @getBRtitle.xml -o getBRtitleRep.xml http://mywebsite.fr/api/soap/mantisconnect.php?WSDL

Based on your comment I will cross-check the code changes between the 2 versions.

mantisiator

mantisiator

2017-09-10 20:56

reporter   ~0057665

Hi,
Further to review, I could not find diffs between the 2.6.0 and the the 2.0.0 versions implémentations in the soap api.

mantisiator

mantisiator

2017-09-10 21:11

reporter   ~0057666

In fact, further to addicitonal testing:

  • executing the script with or without the custom field filter returns the same result, as if teh query was simply returning all the issues of the project without taking into account the custom field filter.
    Note that the "Add to filter" is added in the custom field definition. Is there may be another flag to add to make the filter work on the custom fields via the soap api please ?

Thanks a lot for your help !

rombert

rombert

2017-09-11 03:05

reporter   ~0057668

The 'add to filter' config should control if it is shown in the view issues page. The field should work out-of-the box. Does the user have enough access rights to query that field? Maybe run the query with an admin user to rule out that possibility.

mantisiator

mantisiator

2017-09-11 03:47

reporter   ~0057670

I have performed the test as an admin and do have the same result.
Did you do a test in 2.6.0 version with a custom field please ?

rombert

rombert

2017-09-11 03:51

reporter   ~0057672

Yes, I tested with 2.6.0 ( actually latest git ) . Can you add your custom field definition?

mantisiator

mantisiator

2017-10-11 04:24

reporter   ~0057928

Hi rombert,
Sorry for the late answer. Please allow me to come back to that topic.
The fied is Numeric.
Write access admin/Read access viewer

Thanks a lot for your support !

mantisiator

mantisiator

2017-10-11 04:40

reporter   ~0057929

Hi rombert,
In fact further to testing, my initial thought was not that incorrect:
When setting the field:

     * @global integer $g_default_limit_view
     * Set the default number of Viewed Issues in the View page to 10 for readability purpose
    */
    $g_default_limit_view = 1;

only the correct issue is returned, whereas when stting it to 10, 10 issues are returned and amon the 10, the correct one....

What do you think ?

mantisiator

mantisiator

2017-10-11 04:55

reporter   ~0057931

Amendment of preceeding Note:
if set to 10 - 10 issues are returned , the last isssue beeing the one we intend to retrieve
if set to 1 - 1 issue is returned, but not the correct one.
The attribute seems thus to have an impact

mantisiator

mantisiator

2017-10-16 04:17

reporter   ~0057966

Hello Rombert,
Please find below the request sent to the database in the filter_get_bug_rows_result function. There is no criteria relatedto teh custom fields filter, which explains why there is no filtering:

SELECT DISTINCT {bug}.* FROM {bug} JOIN {project} ON {project}.id = {bug}.project_id WHERE {project}.enabled = ? AND ( {bug}.project_id = 11 ) ORDER BY {bug}.last_updated DESC, {bug}.date_submitted DESC

mantisiator

mantisiator

2017-10-16 08:40

reporter   ~0057972

Hello,
Hereafter the logs indicating that :

  • in filter_get_bug_rows() function, t_query_clauses variable includes the custom field
    while
  • in filter_get_bug_count, the custom fileds are not present in the SQL query.

filter_api.php L1140 filter_get_bug_count(<array> { ['select'] => <array> { [0] => '{bug}.*' }, ['from'] => <array> { [0] => '{bug}' }, ['join'] => <array> { [0] => ' JOIN {project} ON {project}.id = {bug}.project_id' }, ['where'] => <array> { }, ['where_values'] => <array> { [0] => 1 }, ['project_where'] => <array> { [0] => '{project}.enabled = ?', [1] => '( {bug}.project_id = 11 )' }, ['operator'] => ' AND ', ['order'] => <array> { [0] => '{bug}.last_updated DESC', [1] => '{bug}.date_submitted DESC' } }, <boolean>false)

mc_filter_api.php L294 filter_get_bug_rows(<integer>1, <NULL>NULL, <integer>0, <integer>0, <array> { ['_view_type'] => 'advanced', ['project_id'] => <array> { [0] => 11 }, ['custom_fields'] => <array> { [67] => <array> { [0] => '8759' }, [81] => <array> { [0] => 0 }, [78] => <array> { [0] => 0 }, [93] => <array> { [0] => 0 }, [108] => <array> { [0] => 0 }, [98] => <array> { [0] => 0 }, [96] => <array> { [0] => 0 }, [107] => <array> { [0] => 0 }, [101] => <array> { [0] => 0 }, [106] => <array> { [0] => 0 }, [104] => <array> { [0] => 0 }, [97] => <array> { [0] => 0 }, [99] => <array> { [0] => 0 }, [103] => <array> { [0] => 0 }, [100] => <array> { [0] => 0 }, [105] => <array> { [0] => 0 }, [102] => <array> { [0] => 0 }, [76] => <array> { [0] => 0 }, [82] => <array> { [0] => 0 }, [59] => <array> { [0] => 0 }, [61] => <array> { [0] => 0 }, [31] => <array> { [0] => 0 }, [4] => <array> { [0] => 0 }, [54] => <array> { [0] => 0 }, [84] => <array> { [0] => 0 }, [73] => <array> { [0] => 0 }, [75] => <array> { [0] => 0 }, [74] => <array> { [0] => 0 }, [36] => <array> { [0] => 0 }, [72] => <array> { [0] => 0 }, [49] => <array> { [0] => 0 }, [34] => <array> { [0] => 0 }, [35] => <array> { [0] => 0 }, [32] => <array> { [0] => 0 }, [91] => <array> { [0] => 0 }, [2] => <array> { [0] => 0 }, [33] => <array> { [0] => 0 }, [14] => <array> { [0] => 0 }, [65] => <array> { [0] => 0 }, [87] => <array> { [0] => 0 }, [52] => <array> { [0] => 0 }, [90] => <array> { [0] => 0 }, [38] => <array> { [0] => 0 }, [62] => <array> { [0] => 0 }, [68] => <array> { [0] => 0 }, [3] => <array> { [0] => 0 }, [53] => <array> { [0] => 0 }, [80] => <array> { [0] => 0 }, [86] => <array> { [0] => 0 }, [47] => <array> { [0] => 0 }, [60] => <array> { [0] => 0 }, [70] => <array> { [0] => 0 }, [85] => <array> { [0] => 0 }, [55] => <array> { [0] => 0 }, [50] => <array> { [0] => 0 }, [88] => <array> { [0] => 0 }, [79] => <array> { [0] => 0 }, [64] => <array> { [0] => 0 }, [63] => <array> { [0] => 0 }, [9] => <array> { [0] => 0 }, [94] => <array> { [0] => 0 }, [83] => <array> { [0] => 0 }, [5] => <array> { [0] => 0 }, [7] => <array> { [0] => 0 }, [13] => <array> { [0] => 0 }, [42] => <array> { [0] => 0 }, [69] => <array> { [0] => 0 }, [71] => <array> { [0] => 0 }, [43] => <array> { [0] => 0 }, [77] => <array> { [0] => 0 }, [46] => <array> { [0] => 0 }, [6] => <array> { [0] => 0 }, [40] => <array> { [0] => 0 }, [1] => <array> { [0] => 0 }, [89] => <array> { [0] => 0 }, [66] => <array> { [0] => 0 }, [48] => <array> { [0] => 0 }, [8] => <array> { [0] => 0 }, [44] => <array> { [0] => 0 } }, ['_version'] => 'v9', ['per_page'] => 10, ['highlight_changed'] => 6, ['sticky'] => true, ['sort'] => 'last_updated', ['dir'] => 'DESC', ['platform'] => <array> { [0] => '0' }, ['os'] => <array> { [0] => '0' }, ['os_build'] => <array> { [0] => '0' }, ['start_month'] => '10', ['start_day'] => '1', ['start_year'] => '2017', ['end_month'] => '10', ['end_day'] => '16', ['end_year'] => '2017', ['search'] => '', ['filter_by_date'] => false, ['view_state'] => 0, ['relationship_type'] => -1, ['relationship_bug'] => 0, ['tag_string'] => '', ['tag_select'] => '', ['match_type'] => 0, ['category_id'] => <array> { [0] => '0' }, ['severity'] => <array> { [0] => 0 }, ['status'] => <array> { [0] => 0 }, ['reporter_id'] => <array> { [0] => 0 }, ['handler_id'] => <array> { [0] => 0 }, ['note_user_id'] => <array> { [0] => 0 }, ['resolution'] => <array> { [0] => 0 }, ['priority'] => <array> { [0] => 0 }, ['build'] => <array> { [0] => '0' }, ['version'] => <array> { [0] => '0' }, ['hide_status'] => <array> { [0] => -2 }, ['fixed_in_version'] => <array> { [0] => '0' }, ['target_version'] => <array> { [0] => '0' }, ['monitor_user_id'] => <array> { [0] => 0 }, ['profile_id'] => <array> { [0] => 0 } })\nmc_filter_api.php L343 mci_filter_search_get_rows(<string>'47', <Object><stdClass> ( [project_id] => <array> { [0] => 11 }, [custom_fields] => <array> { [0] => <Object><stdClass> ( [field] => <Object><stdClass> ( [id] => 67 ), [value] => <array> { [0] => '8759' } ) } ), <NULL>NULL, <NULL>NULL)

UnknownFile L? mc_filter_search_issues(<string>'mallab', <string>'e1u2r3o4c\\', <Object><stdClass> ( [project_id] => <array> { [0] => 11 }, [custom_fields] => <array> { [0] => <Object><stdClass> ( [field] => <Object><stdClass> ( [id] => 67 ), [value] => <array> { [0] => '8759' } ) } ), <NULL>NULL, <NULL>NULL)

dregad

dregad

2017-10-16 08:50

developer   ~0057973

@cproensa you may want to have a look at this - the inconsistency could be a consequence of the recent changes to filter api.

cproensa

cproensa

2017-10-16 09:14

developer   ~0057974

Which version exactly is this being reported for?

mantisiator

mantisiator

2017-10-16 10:09

reporter   ~0057975

Hi,
I am using version 2.0.0. It seems that 2.6.0 implementation is similar further to review
Thanks a lot for your feedback

cproensa

cproensa

2017-10-16 11:10

developer   ~0057976

changes to filter_api that dregad says were included in 2.1
@mantisiator please try with the latest 2.7

mantisiator

mantisiator

2017-10-16 14:01

reporter   ~0057977

I am planning to do a migraion from January 2018 on.
Do you know if I can patch the 2.0 version please until then ?

Thanks a lot !

mantisiator

mantisiator

2017-10-16 14:37

reporter   ~0057980

What's more, when I cross-checked 2.0 ans 2.6 implementation, these seem similar to me.

mantisiator

mantisiator

2017-10-17 14:57

reporter   ~0057988

Hello @cproensa,
I have checked with version 2.3.0 and the problem still appears.

Putting the custom fields data structure in the query or not has no impact on the quesry result.

Question:
Is may be something wrong in my xml script ?

<?xml version="1.0" encoding="UTF-8"?>

-<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
-<soap:Body>
-<mc_filter_search_issues xmlns="http://mywebsite.fr/api/soap/mantisconnect/";>

<username>XXXX</username>
<password>YYYY</password>
-<filter>
-<project_id>
<item>11</item>
</project_id>
-<custom_fields>
-<item>
-<field>
<id>67</id>
</field>
-<value>
<item>8759</item>
</value>
</item>
</custom_fields>
</filter>
</mc_filter_search_issues>
</soap:Body>
</soap:Envelope

mantisiator

mantisiator

2017-10-19 15:22

reporter   ~0057995

Further to a deeper analysis, the problem comes from the funciton filter_get_bug_rows_query_clauses()

# custom field filters
if( ON == config_get( 'filter_by_custom_fields' ) ) {
    # custom field filtering
    # @@@ At the moment this gets the linked fields relating to the current project
    #     It should get the ones relating to the project in the filter or all projects
    #     if multiple projects.
    $t_custom_fields = custom_field_get_linked_ids( $t_project_id );

which has been changed in 2.7.0 (which explains why the problem was still present in 2.3.0)

In fact, the function was not parsing the project defined in the xml query and was therefore not finding the custom field defined in the xml query.
Moving to 2.7.0 should sove the problem.

dregad

dregad

2017-10-20 04:06

developer   ~0057996

So can this issue be closed then ?

mantisiator

mantisiator

2017-11-19 14:55

reporter   ~0058224

Hi dregad,
Further to effective testing with the version 2.8.0, the problem does not appear. The issue can thus be closed. Thank you !