On Wednesday 02 November 2011 09:47:22 you wrote:

Hi Michiel,

> No, it's now a known bug. When exactly did this happen? Were you
> creating a new queue? Are you using PostgreSQL as the database?

This happens on applying "Change Queue Relations for Response foo".
It's the postgres error message that i sent.

I found out, that there are 2 issues that might be responsible for this 
behavior.
- The @IDs Elements are not uniq but 35 times repeated.
- There's is an unecessary loop, that repetedly deletes and inserts the same 
values.
Both are responsible for massive loops in AdminQueueResponses.pm
The attached patch is a quick hack to fix these Problems.

Regards, Jens
--- /usr/src/otrs-3.0.10/Kernel/Modules/AdminQueueResponses.pm	2010-11-10 12:04:28.000000000 +0100
+++ /server/otrs/otrs-3.0.10/Kernel/Modules/AdminQueueResponses.pm	2011-11-01 12:46:15.000000000 +0100
@@ -116,15 +116,9 @@ sub Run {
         my $ID = $Self->{ParamObject}->GetParam( Param => 'ID' );
 
         # get user list
-        my %StandardResponseData
-            = $Self->{StandardResponseObject}->StandardResponseList( Valid => 1 );
-        for my $StandardResponseID ( keys %StandardResponseData ) {
-            my $Active = 0;
-            for my $QueueID (@IDs) {
-                next if $QueueID ne $StandardResponseID;
-                $Active = 1;
-                last;
-            }
+	
+        # $QueueID and $Active seem not to be needed here.
+	# This loop just slowed down processing everything massivly.
 
             # update db
             $Self->{DBObject}->Do(
@@ -132,6 +126,7 @@ sub Run {
                 Bind => [ \$ID ],
             );
             for my $NewID (@IDs) {
+		$Self->{LogObject}->Log( Priority => 'error', Message => "add user to groups: \$ID, \$NewID, \$Self->{UserID}, \$Self->{UserID}:  $ID, $NewID, $Self->{UserID}, $Self->{UserID}" );
                 $Self->{DBObject}->Do(
                     SQL => 'INSERT INTO queue_standard_response (queue_id, standard_response_id, '
                         . 'create_time, create_by, change_time, change_by) VALUES '
@@ -139,7 +134,6 @@ sub Run {
                     Bind => [ \$ID, \$NewID, \$Self->{UserID}, \$Self->{UserID} ],
                 );
             }
-        }
 
         return $Self->{LayoutObject}->Redirect( OP => "Action=$Self->{Action}" );
     }
@@ -150,34 +144,33 @@ sub Run {
     elsif ( $Self->{Subaction} eq 'ChangeResponse' ) {
 
         # get new role member
-        my @IDs = $Self->{ParamObject}->GetArray( Param => 'Response' );
+	# @IDs are 35 times doubled. Why? Uniq hack:
+        my @IDs = keys  %{{ map { $_ => 1 } $Self->{ParamObject}->GetArray( Param => 'Response' )}};
+	for my $fooID (@IDs) {
+		$Self->{LogObject}->Log( Priority => 'error', Message => "fooID: $fooID\n" );
+	}
 
         my $ID = $Self->{ParamObject}->GetParam( Param => 'ID' );
 
         # get user list
-        my %QueueData = $Self->{QueueObject}->QueueList( Valid => 1 );
-        for my $QueueID ( keys %QueueData ) {
-            my $Active = 0;
-            for my $StandardResponseID (@IDs) {
-                next if $StandardResponseID ne $QueueID;
-                $Active = 1;
-                last;
-            }
-
-            # update db
-            $Self->{DBObject}->Do(
-                SQL  => 'DELETE FROM queue_standard_response WHERE standard_response_id = ?',
-                Bind => [ \$ID ],
-            );
-            for my $NewID (@IDs) {
-                $Self->{DBObject}->Do(
-                    SQL => 'INSERT INTO queue_standard_response (queue_id, standard_response_id, '
-                        . 'create_time, create_by, change_time, change_by) VALUES '
-                        . ' (?, ?, current_timestamp, ?, current_timestamp, ?)',
-                    Bind => [ \$NewID, \$ID, \$Self->{UserID}, \$Self->{UserID} ],
-                );
-            }
-        }
+	# 
+	# $QueueID and Active seem not to be needed here.
+	# This loop just slowed down processing everything massivly.
+
+	    # update db
+	    $Self->{DBObject}->Do(
+		SQL  => 'DELETE FROM queue_standard_response WHERE standard_response_id = ?',
+		Bind => [ \$ID ],
+	    );
+	    for my $NewID (@IDs) {
+		$Self->{LogObject}->Log( Priority => 'error', Message => "groups to user: \$ID, \$NewID, \$Self->{UserID}, \$Self->{UserID}:  $ID, $NewID, $Self->{UserID}, $Self->{UserID}" );
+		$Self->{DBObject}->Do(
+		    SQL => 'INSERT INTO queue_standard_response (queue_id, standard_response_id, '
+			. 'create_time, create_by, change_time, change_by) VALUES '
+			. ' (?, ?, current_timestamp, ?, current_timestamp, ?)',
+		    Bind => [ \$NewID, \$ID, \$Self->{UserID}, \$Self->{UserID} ],
+		);
+	    }
 
         return $Self->{LayoutObject}->Redirect( OP => "Action=$Self->{Action}" );
     }
_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev

Reply via email to