MantisBT - TestLink
View Issue Details
0001967TestLinkReportspublic2009-01-07 13:552009-01-20 05:19
1.8 RC 2 
1.8 RC 3 
0001967: SQL Error in Requirements based Report sublinks
Please see the attached SWF file for the exact steps to reproduce this issue. Let me know if still any concerns.
No tags attached.
? bug requirements.swf (652,489) 2009-01-07 13:55
Issue History
2009-01-07 13:55amitkhullarNew Issue
2009-01-07 13:55amitkhullarFile Added: bug requirements.swf
2009-01-07 15:59amitkhullarNote Added: 0004946
2009-01-07 18:18amitkhullarNote Added: 0004948
2009-01-07 18:26amitkhullarNote Added: 0004949
2009-01-08 17:34fmanStatusnew => assigned
2009-01-08 17:34fmanAssigned To => fman
2009-01-12 17:54fmanStatusassigned => resolved
2009-01-12 17:54fmanFixed in Version => next development 1.8 RC3
2009-01-12 17:54fmanResolutionopen => fixed
2009-01-20 05:19mhavlatStatusresolved => closed

2009-01-07 15:59   
I think I have found the issue but not sure how to fix it
the function init_args in reqSpecView.php should use the following line to get the value of the req_spec_id since the _REQUEST doesnt have any variable with name req_spec_id but instead the name editReq or idSRS to get a value not sure which one would be assigned here. The variable req_spec_id is not present in $_REQUEST.
// $args->req_spec_id = isset($_REQUEST['req_spec_id']) ? $_REQUEST['req_spec_id'] : null;

The file reqSpecView.php line 45 tries to pass 2 params to the funct html_table_of_custom_field_values
$gui->cfields = $req_spec_mgr->html_table_of_custom_field_values($args->req_spec_id,$args->tproject_id);
This directs it to requirement_spec_mgr.class.php
function html_table_of_custom_field_values($id)
(NOTE: the function accepts only 1 param here : id , project id is missing)
$PID_NO_NEEDED = null;
$cf_map = $this->get_linked_cfields($id,$PID_NO_NEEDED);

which calls the Function get_by_id in return but it doesnt set the value for the $req_spec_info['testproject_id'] (this becomes null) which is being called in the function get_linked_cfields to set the variable $tproject_id (line730) so the next line in function get_linked_cfields($id,$parent_id=null) is
$cf_map = $this->cfield_mgr->get_linked_cfields_at_design($tproject_id,$enabled,null,
which passes null value in $tproject_id and this causes the query to be having empty project id at "WHERE CFTP.testproject_id= AND"
This would require a couple of changes but I am not sure how will it impact at the other places.

PS: I also noted the query being formed in the function get_by_id (in requirement_spec_mgr_class.php) being different from the same function in requirement_mgr_class.php. This function is doing some query on req_specs table for an author
SELECT *, '' AS author, '' AS modifier FROM req_specs WHERE id = XXX
2009-01-07 18:18   
My above analysis was on the basis that the clicking of the Requirement should open the Requirement Details in a popup for viewing but I think this is not the case here , it opens the Requirement Specification.

Also do NOTE one more thing that 2 pages call the same reqSpecView.php but with different parameter as a req_spec_id (from reqSpecAnalyse.php / .tpl) and idSRS (from resultsReqs.php/.tpl)

I think this is causing this issue since the main reqSpecView.php only captures the paramter as req_spec_id in init_args.

For this to work i did the changes below in the init_args function: Please verify them once :

    $id_request = isset($_REQUEST['idSRS']) ? $_REQUEST['idSRS'] : null;
    if (!is_null($id_request))
        $args->req_spec_id = isset($_REQUEST['idSRS']) ? $_REQUEST['idSRS'] : null;
        $args->req_spec_id = isset($_REQUEST['req_spec_id']) ? $_REQUEST['req_spec_id'] : null;
2009-01-07 18:26   
But I would still have a different opinion that we should be able to open the Requirement Detail rather than the Requirement Specification since the test cases are mapped against them and anyone could want to see the mapping between them.