Logic bug on caching queues

I note that RT::Queue::StatusArray() is documented as

Returns an array of all statuses for this queue

Whilst the current implementation does not return different results per
queue, the facility seems to be there to do it.

However /html/Elements/SelectStatus has

<%ONCE>
my $queue = new RT::Queue($session{'CurrentUser'});
my @status = $queue->StatusArray();
</%ONCE>

Am I right in my understanding of Mason that that ONCE block is run exactly
once at the time of loading the page? If so, surely it will cache the status
list to early, and hence prevent a correct drop down if someone wishes to
customise RT to have different statuses available on different queues.

Nicholas Clark

I note that RT::Queue::StatusArray() is documented as

Returns an array of all statuses for this queue

Whilst the current implementation does not return different results
per
queue, the facility seems to be there to do it.

The facility is… partially there. I’d love to see patches to push
us further in that direction.

However /html/Elements/SelectStatus has

<%ONCE>
my $queue = new RT::Queue($session{'CurrentUser'});
my @status = $queue->StatusArray();
</%ONCE>

Am I right in my understanding of Mason that that ONCE block is run
exactly
once at the time of loading the page? If so, surely it will cache
the status
list to early, and hence prevent a correct drop down if someone
wishes to
customise RT to have different statuses available on different queues.

I’d be ok with flipping it from a <%once> to a <%init> block. but do
note that you’re never actaully loading a specific $queue in that code.

PGP.sig (186 Bytes)

I note that RT::Queue::StatusArray() is documented as

Returns an array of all statuses for this queue

Whilst the current implementation does not return different results per
queue, the facility seems to be there to do it.

However /html/Elements/SelectStatus has

<%ONCE>
my $queue = new RT::Queue($session{'CurrentUser'});
my @status = $queue->StatusArray();
</%ONCE>

Am I right in my understanding of Mason that that ONCE block is run exactly
once at the time of loading the page? If so, surely it will cache the status
list to early, and hence prevent a correct drop down if someone wishes to
customise RT to have different statuses available on different queues.
I agree with Jesse that we should move into this direction, but note
that even if you’ll change this part you’ll face another problem. In
the query builder we need list of all statuses we have in the select
box. Loading all queues and going through them is not a variant, so we
need new methods or adjust current methods. I see two variants:

  1. Add new methods AllStatusArray and other .Status. methods with All prefix.
  2. adjust methods we have, so they should return/validate all statuses
    if the object is not loaded (!$self->id).

I like the second one and think it’ll help us to get rid of the State
CF in RTIR.

Nicholas Clark


List info: The rt-devel Archives

Best regards, Ruslan.