[Rt-devel] Re: Bug in RT::Tickets::LimitMemberOf (3.0.12 & 3.2.3)

Ruediger Riediger ruediger.riediger at sun.com
Mon May 9 04:27:16 EDT 2005


-> this apparently affects also 3.2.3, I did not see any code changes
from 3.0.12 in the relevant parts.

Ruediger Riediger wrote:
>>>my $MyTickets = new RT::Tickets ($session{'CurrentUser'});
>>>$MyTickets->LimitMemberOf($Ticket->Id);
>>>I only get #101. Looks like a bug in "RT::Tickets::LimitMemberOf".
>>>Anyone noticed this before and/or got a fix?
>>
>>
>>What version of RT?
> 
> 
> see subject: 3.0.12
> I noticed this as RTIR uses the later while RT the first function to
> list children.

Some additional info: here is the table extract (table "Links") from the
DB and some tickets with children that have been merged into 1963:

mysql> select * from Links where LocalBase = 1963;
+------+-----------------------------------+-----------------------------------+------------+-------------+-----------+---------------+---------------------+---------+---------------------+
| id   | Base                              | Target
       | Type       | LocalTarget | LocalBase | LastUpdatedBy |
LastUpdated         | Creator | Created             |
+------+-----------------------------------+-----------------------------------+------------+-------------+-----------+---------------+---------------------+---------+---------------------+
| 1090 | fsck.com-rt://sun.com/ticket/1966 |
fsck.com-rt://sun.com/ticket/1963 | MergedInto |        1963 |      1963
|            12 | 2005-04-28 08:18:01 |      12 | 2005-04-28 08:18:01 |
| 1122 | fsck.com-rt://sun.com/ticket/2000 |
fsck.com-rt://sun.com/ticket/1963 | MergedInto |        1963 |      1963
|            12 | 2005-04-29 19:18:10 |      12 | 2005-04-29 19:18:10 |
| 1134 | fsck.com-rt://sun.com/ticket/2030 |
fsck.com-rt://sun.com/ticket/1963 | MergedInto |        1963 |      1963
|            39 | 2005-05-02 12:00:59 |      39 | 2005-05-02 12:00:59 |
| 1135 | fsck.com-rt://sun.com/ticket/2033 |
fsck.com-rt://sun.com/ticket/1963 | MergedInto |        1963 |      1963
|            39 | 2005-05-02 12:01:44 |      39 | 2005-05-02 12:01:44 |
+------+-----------------------------------+-----------------------------------+------------+-------------+-----------+---------------+---------------------+---------+---------------------+
4 rows in set (0.01 sec)

mysql> select * from Links where LocalTarget = 1963;
+------+-----------------------------------+-----------------------------------+------------+-------------+-----------+---------------+---------------------+---------+---------------------+
| id   | Base                              | Target
       | Type       | LocalTarget | LocalBase | LastUpdatedBy |
LastUpdated         | Creator | Created             |
+------+-----------------------------------+-----------------------------------+------------+-------------+-----------+---------------+---------------------+---------+---------------------+
| 1080 | fsck.com-rt://sun.com/ticket/1962 |
fsck.com-rt://sun.com/ticket/1963 | MemberOf   |        1963 |      1962
|             1 | 2005-04-28 03:46:29 |       1 | 2005-04-28 03:46:29 |
| 1081 | fsck.com-rt://sun.com/ticket/1964 |
fsck.com-rt://sun.com/ticket/1963 | MemberOf   |        1963 |      1964
|             1 | 2005-04-28 03:46:43 |       1 | 2005-04-28 03:46:43 |
| 1090 | fsck.com-rt://sun.com/ticket/1966 |
fsck.com-rt://sun.com/ticket/1963 | MergedInto |        1963 |      1963
|            12 | 2005-04-28 08:18:01 |      12 | 2005-04-28 08:18:01 |
| 1091 | fsck.com-rt://sun.com/ticket/1975 |
fsck.com-rt://sun.com/ticket/1963 | MemberOf   |        1963 |      1975
|             1 | 2005-04-28 08:48:44 |       1 | 2005-04-28 08:48:44 |
| 1092 | fsck.com-rt://sun.com/ticket/1976 |
fsck.com-rt://sun.com/ticket/1963 | MemberOf   |        1963 |      1976
|             1 | 2005-04-28 08:48:59 |       1 | 2005-04-28 08:48:59 |
| 1093 | fsck.com-rt://sun.com/ticket/1977 |
fsck.com-rt://sun.com/ticket/1963 | MemberOf   |        1963 |      1977
|             1 | 2005-04-28 09:05:00 |       1 | 2005-04-28 09:05:00 |
| 1122 | fsck.com-rt://sun.com/ticket/2000 |
fsck.com-rt://sun.com/ticket/1963 | MergedInto |        1963 |      1963
|            12 | 2005-04-29 19:18:10 |      12 | 2005-04-29 19:18:10 |
| 1134 | fsck.com-rt://sun.com/ticket/2030 |
fsck.com-rt://sun.com/ticket/1963 | MergedInto |        1963 |      1963
|            39 | 2005-05-02 12:00:59 |      39 | 2005-05-02 12:00:59 |
| 1135 | fsck.com-rt://sun.com/ticket/2033 |
fsck.com-rt://sun.com/ticket/1963 | MergedInto |        1963 |      1963
|            39 | 2005-05-02 12:01:44 |      39 | 2005-05-02 12:01:44 |
+------+-----------------------------------+-----------------------------------+------------+-------------+-----------+---------------+---------------------+---------+---------------------+
9 rows in set (0.00 sec)


And now one ticket that should be empty (but is not):

mysql> select * from Links where LocalBase = 2000;
Empty set (0.00 sec)

mysql> select * from Links where LocalTarget = 2000;
+------+-----------------------------------+-----------------------------------+----------+-------------+-----------+---------------+---------------------+---------+---------------------+
| id   | Base                              | Target
       | Type     | LocalTarget | LocalBase | LastUpdatedBy |
LastUpdated         | Creator | Created             |
+------+-----------------------------------+-----------------------------------+----------+-------------+-----------+---------------+---------------------+---------+---------------------+
| 1109 | fsck.com-rt://sun.com/ticket/1999 |
fsck.com-rt://sun.com/ticket/1963 | MemberOf |        2000 |      1999 |
           12 | 2005-04-29 19:18:10 |       1 | 2005-04-29 01:42:28 |
| 1110 | fsck.com-rt://sun.com/ticket/2001 |
fsck.com-rt://sun.com/ticket/1963 | MemberOf |        2000 |      2001 |
           12 | 2005-04-29 19:18:10 |       1 | 2005-04-29 05:55:17 |
| 1115 | fsck.com-rt://sun.com/ticket/2007 |
fsck.com-rt://sun.com/ticket/1963 | MemberOf |        2000 |      2007 |
           12 | 2005-04-29 19:18:10 |       1 | 2005-04-29 07:23:02 |
+------+-----------------------------------+-----------------------------------+----------+-------------+-----------+---------------+---------------------+---------+---------------------+
3 rows in set (0.00 sec)

Shouldn't be LocalTarget be rather 1963 as well? Looking through the
whole table, I only see "Target" mismatches with "MemberOf":

mysql> select * from Links where Target LIKE "fsck.com-rt://sun.com/%"
AND Target != concat("fsck.com-rt://sun.com/ticket/", LocalTarget);
+------+-----------------------------------+-----------------------------------+------------+-------------+-----------+---------------+---------------------+---------+---------------------+
| id   | Base                              | Target
       | Type       | LocalTarget | LocalBase | LastUpdatedBy |
LastUpdated         | Creator | Created             |
+------+-----------------------------------+-----------------------------------+------------+-------------+-----------+---------------+---------------------+---------+---------------------+
|   44 | fsck.com-rt://sun.com/ticket/111  |
fsck.com-rt://sun.com/ticket/223  | MemberOf   |         119 |       111
|            39 | 2004-12-09 10:31:01 |      39 | 2004-11-25 08:40:25 |
|   45 | fsck.com-rt://sun.com/ticket/120  |
fsck.com-rt://sun.com/ticket/223  | MemberOf   |         119 |       120
|            39 | 2004-12-09 10:31:02 |      39 | 2004-11-25 08:44:26 |
|   60 | fsck.com-rt://sun.com/ticket/145  |
fsck.com-rt://sun.com/ticket/223  | MemberOf   |         119 |       145
|            39 | 2004-12-09 10:31:02 |      39 | 2004-11-29 14:57:20 |
|   81 | fsck.com-rt://sun.com/ticket/171  |
fsck.com-rt://sun.com/ticket/223  | MemberOf   |         119 |       171
|            39 | 2004-12-09 10:31:02 |      39 | 2004-11-30 12:05:41 |
[...]


Base has the same issues with "MergedInto":
mysql> select * from Links where Target LIKE "fsck.com-rt://sun.com/%"
AND Base != concat("fsck.com-rt://sun.com/ticket/", LocalBase);
+------+-----------------------------------+-----------------------------------+------------+-------------+-----------+---------------+---------------------+---------+---------------------+
| id   | Base                              | Target
       | Type       | LocalTarget | LocalBase | LastUpdatedBy |
LastUpdated         | Creator | Created             |
+------+-----------------------------------+-----------------------------------+------------+-------------+-----------+---------------+---------------------+---------+---------------------+
|    5 | fsck.com-rt://sun.com/ticket/10   |
fsck.com-rt://sun.com/ticket/12   | MergedInto |          12 |        12
|            41 | 2004-11-17 18:30:29 |      41 | 2004-11-17 18:30:29 |
|    6 | fsck.com-rt://sun.com/ticket/17   |
fsck.com-rt://sun.com/ticket/16   | MergedInto |          16 |        16
|            41 | 2004-11-17 19:26:19 |      41 | 2004-11-17 19:26:19 |
|   17 | fsck.com-rt://sun.com/ticket/60   |
fsck.com-rt://sun.com/ticket/52   | MergedInto |          52 |        52
|            39 | 2004-11-20 12:43:04 |      39 | 2004-11-20 12:43:04 |
|   18 | fsck.com-rt://sun.com/ticket/77   |
fsck.com-rt://sun.com/ticket/76   | MergedInto |          76 |        76
|            39 | 2004-11-21 23:17:55 |      39 | 2004-11-21 23:17:55 |
|   23 | fsck.com-rt://sun.com/ticket/81   |
fsck.com-rt://sun.com/ticket/79   | MergedInto |          79 |        79
|            39 | 2004-11-22 00:24:17 |      39 | 2004-11-22 00:24:17 |
[...]


Is this rather a problem of the "Ticket->MergeInto" function? Please let
me know, so I can start to fix it at the right place. Don't want to make
a mess of rewriting it.

In Link_Overlay, a link is created with both "LocalTarget" and "Target",
however, only the later is updated by "Ticket->MergeInto":

Link->SUPER::Create( Base        => $base->URI,
                     Target      => $target->URI,
                     LocalBase   => $base_id,
                     LocalTarget => $target_id,
                     Type        => $args{'Type'} );


Target->MergeInto:

    # update all the links that point to that old ticket
    my $old_links_to = RT::Links->new($self->CurrentUser);
    $old_links_to->Limit(FIELD => 'Target', VALUE => $self->URI);

    while (my $link = $old_links_to->Next) {
        if ($link->Base eq $NewTicket->URI) {
            $link->Delete;
        } else {
            $link->SetTarget($NewTicket->URI);
        }

    }

(same for Base)

Tickets->Limit seems to use the Local... entry:

my $matchfield = ( $value  =~ /^(\d+)$/ ? "LocalTarget" : "Target" );
[...]
my $matchfield = ( $value  =~ /^(\d+)$/ ? "LocalBase" : "Base" );

while enumerating the URIs obviously gives the correct results.

Best regards,

	Ruediger Riediger

-- 
Dr. Ruediger Riediger                              Sun Microsystems GmbH
NSG - SunCERT                                             Komturstr. 18a
mailto:Ruediger.Riediger at Sun.com                          D-12099 Berlin
------------------------------------------------------------------------
NOTICE:  This email message is for the sole use of the intended
recipient(s) and may contain confidential and privileged information.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
------------------------------------------------------------------------
PGP 2048RSA/0x2C5020E9          964C E189 0FF0 8882  2BAB 65E2 6912 1FF2
------------------------------------------------------------------------


More information about the Rt-devel mailing list