Data from JIRA not returning properly

Ask community to help.

Moderators: Amaradana, TurboPT, TL Developers

Post Reply
eeijlar
Advanced user
Posts: 28
Joined: Mon Apr 06, 2009 4:25 pm

Data from JIRA not returning properly

Post by eeijlar »

Hi,

I am have connected an instance of JIRA (running on Oracle) to Testlink. The connection to the JIRA database seems to be fine, but Testlink is not parsing the data returned from JIRA properly. In the file:

/lib/int_jira.php

The section where it gets the bug status has the following php code:

Code: Select all

  
       function getBugStatus($id)
        {
                $myFile = "jir.log";
                $fh = fopen($myFile, 'w');

                if (!$this->isConnected())
                        return false;

                $status = false;

                // 20070818 - francisco.mancardi@gruppotesi.com
                // $query = "SELECT issuestatus FROM jiraissue WHERE pkey='$id'";
                $query = "SELECT s.pname as issuestatus " .
                         "FROM issuestatus s, jiraissue i " .
                         "WHERE i.pkey='$id' AND i.issuestatus = s.ID";

                fwrite($fh, $query);


                $result = $this->dbConnection->exec_query($query);
                fwrite($fh,$result);
                if ($result)
                {
                        $status = $this->dbConnection->fetch_array($result);
                        if ($status)
                        {
                                $status = $status['issuestatus'];
                        }
                        else
                                $status = null;
                }
                fwrite($fh, "\n");
                fwrite($fh, "Status: ");
                fwrite($fh,$status);
                fclose($fh);
                return $status;

        }

(Please ignore my debug mods) I have printed out the query to the database and ran it in SQL developer:

Code: Select all

SELECT s.pname as issuestatus " .
                         "FROM issuestatus s, jiraissue i " .
                         "WHERE i.pkey='$id' AND i.issuestatus = s.ID
It returns the status as closed. I have also printed out the $result object which the query is returned to:

Code: Select all

$result = $this->dbConnection->exec_query($query);
The contents of the object are too big to post here but you can clearly see the status of the bug as closed in it. Then it goes into the next code block and executes this:

Code: Select all

  $status = $this->dbConnection->fetch_array($result);
The $status variable is set, so it then does:

Code: Select all

 $status = $status['issuestatus'];
The problem is that when I check the value of $status, it's always blank, even though I know for a fact that the database is returning 'Closed' for this particular bug.

Any ideas?

/Jlar
eeijlar
Advanced user
Posts: 28
Joined: Mon Apr 06, 2009 4:25 pm

Post by eeijlar »

I finally tracked down the source of this problem. I'm not sure if it's a bug in Testlink or not, but this was the only way I could get it to work. I had to make the following changes to get the Jira integration to work:

In the file testlink/functions/database.class.php:

I had to change this line:

Code: Select all

if( $this->db->databaseType == 'mysql')
to this:

Code: Select all

if( $this->db->databaseType == 'oci8' || $this->db->databaseType == 'mysql')
Then, in the file testlink/lib/int_jira.php, the values for 'issuestatus' and 'summary' had to be changed to upper case.

I think the reason for this is explained by printing out the $result object:

Code: Select all

ADORecordSet_array Object
(
    [databaseType] => array
    [_array] => Array
        (
            [0] => Array
                (
                    [ISSUESTATUS] => Closed
                )

        )

    [_types] =>
    [_colnames] =>
    [_skiprow1] =>
    [_fieldobjects] => Array
        (
            [0] => ADOFieldObject Object
                (
                    [name] => issuestatus
                    [max_length] => 60
                    [type] => VARCHAR2
                )

        )

    [canSeek] => 1
    [affectedrows] =>
    [insertid] =>
    [sql] => SELECT s.pname as issuestatus FROM issuestatus s, jiraissue i WHERE i.pkey='TEST-148' AND i.issuestatus = s.ID
    [compat] =>
    [dataProvider] => oci8
    [fields] => Array
        (
            [ISSUESTATUS] => Closed
        )


)
You can see above that the [_array] entry has a sub array within it; whereas the [fields] entry does not have a sub array, so fetching [fields] returns the data in the form that int_jira.php is expecting and the other one [_array] does not.
[/code]
ptimo3
TestLink user
Posts: 4
Joined: Wed Mar 24, 2010 3:53 pm

Post by ptimo3 »

That solved it for me :-) Thanks, i had trouble getting feedback from the bugs from jira :-)
Post Reply