View Issue Details

IDProjectCategoryView StatusLast Update
0024462mantisbtapi soappublic2018-06-06 00:39
Reporterrheydenr Assigned Toatrol  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version2.14.0 
Target Version2.15.0Fixed in Version2.15.0 
Summary0024462: Error while querying for issue header with PHP 7.2
Description

If you call mci_issue_data_as_header_array then you get the error message "count(): Parameter must be an array or an object that implements Countable" from PHP if you use PHP from version 7.2 on. This breaks the mylyn connector in Eclipse IDE (unable to get the issues list).
I've changed some code (just commented out something) in mc_issue_api.php (patch appended), now it works for me, but I don't know if I've caught all occurences of this bug...

TagsNo tags attached.
Attached Files
mc_issue_api.php.patch (506 bytes)   
27a28,29
> use Mantis\Exceptions\ClientException;
> 
489c491
< 	return count( $t_custom_fields ) == 0 ? null : $t_custom_fields;
---
> 	return /* count( $t_custom_fields ) == 0 ? null : */ $t_custom_fields;
601c603
< 	return (count( $t_relationships ) == 0 ? null : $t_relationships );
---
> 	return /* count( $t_relationships ) == 0 ? null : */ $t_relationships ;
680c682
< 	return count( $t_result ) == 0 ? null : $t_result;
---
> 	return /* count( $t_result ) == 0 ? null : */ $t_result;
mc_issue_api.php.patch (506 bytes)   

Activities

atrol

atrol

2018-05-21 14:49

developer   ~0059898

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

Thanks @rheydenr for your contribution.
In case you provide more patches, to make it easier for us to review, test and merge such changes, it would be fine if you submit your patches as pull requests via Github.

atrol

atrol

2018-05-21 15:36

developer   ~0059899

I am not sure if this is the right fix, as I had to change also our tests.

If there is an issue without notes, attachments, custom fields and relationships, this is an example extract of a response after the change

            &lt;attachments SOAP-ENC:arrayType=&quot;ns1:AttachmentData[0]&quot; xsi:type=&quot;SOAP-ENC:Array&quot;/>
            &lt;relationships SOAP-ENC:arrayType=&quot;ns1:RelationshipData[0]&quot; xsi:type=&quot;SOAP-ENC:Array&quot;/>
            &lt;notes SOAP-ENC:arrayType=&quot;ns1:IssueNoteData[0]&quot; xsi:type=&quot;SOAP-ENC:Array&quot;/>
            &lt;custom_fields SOAP-ENC:arrayType=&quot;ns1:CustomFieldValueForIssueData[0]&quot; xsi:type=&quot;SOAP-ENC:Array&quot;/>
            &lt;due_date xsi:nil=&quot;true&quot; xsi:type=&quot;xsd:dateTime&quot;/>
            &lt;monitors SOAP-ENC:arrayType=&quot;ns1:AccountData[0]&quot; xsi:type=&quot;SOAP-ENC:Array&quot;/>
            &lt;sticky xsi:type=&quot;xsd:boolean&quot;>false&lt;/sticky>
            &lt;tags SOAP-ENC:arrayType=&quot;ns1:ObjectRef[0]&quot; xsi:type=&quot;SOAP-ENC:Array&quot;/>

before the change we had

            &lt;attachments SOAP-ENC:arrayType=&quot;ns1:AttachmentData[0]&quot; xsi:type=&quot;SOAP-ENC:Array&quot;/>
            &lt;due_date xsi:nil=&quot;true&quot; xsi:type=&quot;xsd:dateTime&quot;/>
            &lt;monitors SOAP-ENC:arrayType=&quot;ns1:AccountData[0]&quot; xsi:type=&quot;SOAP-ENC:Array&quot;/>
            &lt;sticky xsi:type=&quot;xsd:boolean&quot;>false&lt;/sticky>
            &lt;tags SOAP-ENC:arrayType=&quot;ns1:ObjectRef[0]&quot; xsi:type=&quot;SOAP-ENC:Array&quot;/>

Pros of the change

  • uniform behavior if fields are not set

Cons of the change

  • larger/slower response
  • changed response might break clients

I am not experienced in writing SOAP clients.
If we break clients, we would have to implement another approach to fix the issue.
Some null checks before calling count at some places should be enough for it.

rheydenr

rheydenr

2018-05-21 18:47

reporter   ~0059905

ok, perhaps it was a too "quick" hack. I'll review it and test it for myself.

atrol

atrol

2018-05-22 03:14

developer   ~0059912

@rheydenr could you please try if this fixes your issue https://github.com/mantisbt/mantisbt/pull/1354 ?

Related Changesets

MantisBT: master 27021735

2018-05-21 23:08

atrol


Details Diff
Fix PHP 7.2 system warnings in SOAP API

Fixes 0024470
Affected Issues
0024462
mod - api/soap/mc_issue_api.php Diff File