MantisBT - TestLink
View Issue Details
0003993TestLinkAPI - XMLRPCpublic2010-11-09 08:352011-03-17 19:07
pablobitton 
fman 
normalminoralways
closedfixed 
1.9 RC 1 
2.0 (planned) 
N/A
0003993: [API] getFullPath can receive a list of node ids instead of one node
we use it intensively and require a method that gets a list.
the internal function it uses is called get_full_path_verbose and excepts both list and string..

another function can be provided, or this function can just remove the check for int and pass the argument on..
No tags attached.
has duplicate 0002719closed fman please expose new API function : get_full_path_verbose 
child of 0004039closed  Availables Fixes for 1.9.0 (Prague) 
patch xmlrpc.class.php.patch (878) 2010-11-10 18:43
http://mantis.testlink.org/file_download.php?file_id=1947&type=bug
zip fix-3993.zip (86,273) 2010-11-20 16:15
http://mantis.testlink.org/file_download.php?file_id=1981&type=bug
Issue History
2010-11-09 08:35pablobittonNew Issue
2010-11-10 09:04fmanNote Added: 0012357
2010-11-10 12:03pablobittonNote Added: 0012374
2010-11-10 14:17fmanNote Added: 0012377
2010-11-10 18:43pablobittonFile Added: xmlrpc.class.php.patch
2010-11-10 18:44pablobittonNote Added: 0012393
2010-11-14 07:53pablobittonNote Added: 0012443
2010-11-20 15:21fmanNote Added: 0012673
2010-11-20 15:22fmanNote Edited: 0012673bug_revision_view_page.php?bugnote_id=12673#r644
2010-11-20 16:08fmanNote Added: 0012674
2010-11-20 16:15fmanFile Added: fix-3993.zip
2010-11-20 16:16fmanNote Added: 0012675
2010-11-20 16:16fmanAssigned To => fman
2010-11-20 16:16fmanStatusnew => feedback
2010-11-20 16:16fmanFixed in Version => 2.0 (planned)
2010-11-20 16:53fmanRelationship addedchild of 0004039
2010-11-21 08:07pablobittonNote Added: 0012678
2010-11-21 08:07pablobittonStatusfeedback => assigned
2010-11-21 17:25fmanDatabasemysql => N/A
2010-11-21 17:25fmanSummarygetFullPath can receive a list of node ids instead of one node => [API] getFullPath can receive a list of node ids instead of one node
2010-12-19 16:14fmanNote Added: 0013038
2010-12-19 16:14fmanStatusassigned => resolved
2010-12-19 16:14fmanResolutionopen => fixed
2010-12-19 16:15fmanRelationship addedhas duplicate 0002719
2011-03-17 19:07fmanStatusresolved => closed
2013-04-25 17:30fmanCategoryTL API => XMLRPC API
2013-04-25 17:30fmanCategoryXMLRPC API => API - XMLRPC

Notes
(0012357)
fman   
2010-11-10 09:04   
>> we use it intensively and require a method that gets a list.
open to review your contribution.
(0012374)
pablobitton   
2010-11-10 12:03   
in function getFullPath:
line 3651 there is a check for $nodeID

the check is wrong

$nodeID can be single number or a list.

the check is going like this:

if (!is_int($nodeID) && $nodeID <=0)
    error.....

1. if $nodeID is a list, check should be done for every item on a list
not is tries to check $nodeID <=0 is $nodeID is not int....??

2. if $nodeID is a negative number, check would not raise error because second part of if would be executed (here i am not sure)
(0012377)
fman   
2010-11-10 14:17   
Open to contribution means: provide full code tested
(0012393)
pablobitton   
2010-11-10 18:44   
attached patch as a file and also here in a note:




--- xmlrpc.class.php.orig 2010-11-10 21:29:16.000000000 +0200
+++ xmlrpc.class.php 2010-11-10 21:34:54.000000000 +0200
@@ -3647,13 +3647,16 @@
       
         if( $status_ok )
         {
- $nodeID=$this->args[self::$nodeIDParamName];
- if( !is_int($nodeID) || $nodeID <= 0 )
- {
- $msg = $msg_prefix . sprintf(NODEID_IS_NOT_INTEGER_STR);
- $this->errors[] = new IXR_Error(NODEID_IS_NOT_INTEGER, $msg);
- $status_ok=false;
- }
+ $nodeID=$this->args[self::$nodeIDParamName];
+ foreach ((array)$nodeID as $item)
+ {
+ if( !is_int($item) || ( is_int($item) && $item <= 0 ))
+ {
+ $msg = $msg_prefix . sprintf(NODEID_IS_NOT_INTEGER_STR);
+ $this->errors[] = new IXR_Error(NODEID_IS_NOT_INTEGER, $msg);
+ $status_ok=false;
+ }
+ }
         }
         
         if( $status_ok )
(0012443)
pablobitton   
2010-11-14 07:53   
fman, is it enough?
(0012673)
fman   
2010-11-20 15:21   
(edited on: 2010-11-20 15:22)
Is not enough, you have missed error check on this piece of code:

 $full_path = $this->tprojectMgr->tree_manager->get_full_path_verbose($nodeIDSet);
            if(is_null($full_path))
            {
                $msg = $msg_prefix . sprintf(NODEID_DOESNOT_EXIST_STR,$nodeID);
                $this->errors[] = new IXR_Error(NODEID_DOESNOT_EXIST, $msg);
                $status_ok=false;
            }

(0012674)
fman   
2010-11-20 16:08   
Refactored (for TL 2.0) when path can not be found instead of returning error, data structure returned will be identical, to data structure returned when everything OK, but instead of array with path, NULL will be returned
(0012675)
fman   
2010-11-20 16:16   
please use attached fix and let us know results
(0012678)
pablobitton   
2010-11-21 08:07   
seems working for now, I will continue testing and let you know if there is a problem
(0013038)
fman   
2010-12-19 16:14   
no more user feedback