[rt-users] (busy) function call causes browser timeout

Ryan von Gleich VonGleichR at lanusa.com
Thu Sep 22 10:49:58 EDT 2005


The error message that I am receiving is:

 

The page cannot be displayed 

Explanation: The request timed out before the page could be retrieved. 

Technical Information (for support personnel)

Error Code 1460: timeout 

Background: The gateway could not receive a timely response from the
website you are trying to access, a DNS server, or another gateway
server. This might indicate that the network is congested or that the
website is experiencing technical difficulties. 

 

I have an action that I added to Ticket_Overlay.pm that clones a current
ticket as many times as the user needs.  It is called from Display.html
with the following code  

 

elsif ( $ARGS{'Action'} eq 'Clone' ) {

    $TicketObj = LoadTicket($ARGS{'id'});

    my $ticketIdStr;

    unless ($TicketObj->CurrentUserHasRight('CreateTicket')){

    Abort('You have no permission to create tickets in that queue.');

    }

    if (defined $ARGS{'many'}) {

            $ticketIdStr = $TicketObj->Clone($ARGS{'many'});

    }else {

            $ticketIdStr = $TicketObj->Clone(1);

            }           

    push @Actions, "Ticket(s) $ticketIdStr cloned from ticket
$ARGS{'id'}";

    $ARGS{'id'} = $TicketObj->id;

 

If I use Clone( ) to make a large number of tickets, the browser will
timeout before Clone() can return a value.  Is there any way to thread
this or set a higher timeout value (not sure where this could be set)?
Not sure if I am posting to the right place, if not I will at least post
my Clone( ) code if anyone needs it or would like to critique.  I
appreciate any suggestions!

 

This is the code I added to Ticket_Overlay.pm using RT ver.3.4:

 

=head2 Clone

 

Clones an existing ticket and its create transaction; returns the new
Ticket

object.

 

=cut

 

sub Clone {

  my $self = shift;

  my $many = shift;

            

            my $ret;

            

 

  my $Requestor = split(",", $self->RequestorAddresses);

  my $Cc        = split(",", $self->CcAddresses);

  my $AdminCc   = split(",", $self->AdminCcAddresses);

 

  my $transactions = RT::Transactions->new($self->CurrentUser);

  $transactions->Limit( FIELD => 'Ticket', VALUE => $self->id() );

  $transactions->Limit( FIELD => 'Type',   VALUE => 'Create' );

  my $attachment = $transactions->Next->Message->Next;

 

  use MIME::Entity;

  my $MIMEObj = MIME::Entity->build( Data => $attachment->Content,

    map { /^([\w\-]+:)\s*(.*)$/; $1 => $2; } split(/\n/,
$attachment->Headers )

  );

  

  my $baseCFS = $self->CustomFields; 

  foreach my $tester($baseCFS) {

            $RT::Logger->debug("Tester check: " . $tester);

  }

  my @CFnames=();               

  my $count=0;                  

  while (my $CF = $baseCFS->Next) {

    $RT::Logger->debug("Checking Field: " . $CF->Name);

    @CFnames[$count++] = $CF->Name;  

  }

  #$RT::Logger->debug ("We found a merged ticket.". $self->id
."/".$self->EffectiveId);

  $RT::Logger->debug ("Number to clone.". $many);

  for (my $i=0; $i<$many; $i++) {

            my $clone = RT::Ticket->new($self->CurrentUser); 

            my $OCFVObj =
RT::ObjectCustomFieldValue->new($self->CurrentUser); 

            $clone->Create(

                  Queue           => $self->Queue,

                  Requestor       => $Requestor,

                  Cc              => $Cc,

                  AdminCc         => $AdminCc,

                  Owner           => $self->Owner,

                  Subject         => $self->Subject,

                  InitialPriority => $self->InitialPriority,

                  FinalPriority   => $self->FinalPriority,

                  Priority        => $self->Priority,

                  Status          => $self->Status,

                  TimeWorked      => 0,

#                  Type            => $self->Type,

                  Due             => $self->Due,

                  #Created         => $self->Created,

                  #Creator         => $self->Creator,

                  MIMEObj         => $MIMEObj,

                ) or return 0;

            

                        foreach my $CFname(@CFnames) {

                                    my $cfValues =
$self->CustomFieldValues($CFname);

                                    while (my $CurrValue =
$cfValues->Next) {

                                                $OCFVObj->Create (

                                                            CustomField
=> $CurrValue->CustomField,

                                                            ObjectType
=> $CurrValue->ObjectType,

                                                            ObjectId =>
$clone->Id,

                                                            Disabled =>
'0',

                                                            Content =>
$CurrValue->Content,

                                                            LargeContent
=> '',

                                                            ContentType
=> '',

 
ContentEncoding => '',

                                                );

                                    } #end while

            

                        } # end foreach

                        if ($i == 0) {

                                    $ret = $clone->id

                        }

                        else {

                                    $ret = $ret . ", " .$clone->Id;

                        } 

  }              

  return $ret; 

}

 

 ###END OF CLONE()

 

And this little piece is added to /Ticket/Elements/Tabs:

 

if ($Ticket->CurrentUserHasRight('CreateTicket')) {

    $actions->{'Clone'} = 

      {

       title => 'Clone',

       path  => "Ticket/Display.html?Action=Clone&id=$id",

      };

}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20050922/a312e8bf/attachment.htm>


More information about the rt-users mailing list