[Rt-commit] rt branch, 4.2/selecttemplate-warnings, created. rt-4.2.3-84-gb22dce9
Kevin Falcone
falcone at bestpractical.com
Mon Apr 14 13:14:14 EDT 2014
The branch, 4.2/selecttemplate-warnings has been created
at b22dce95172f691eb408b6c839d892b5a33135c3 (commit)
- Log -----------------------------------------------------------------
commit b22dce95172f691eb408b6c839d892b5a33135c3
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Mon Apr 14 12:43:30 2014 -0400
If you can't see global templates, this generated warnings for each one
Because Templates uses Next rather than NewItem to implement ACL
checking, ItemsArrayRef returns every global template, but calling Name
will then ACL check and get you undef.
We can add a grep { defined } to the call chain, but then you *still*
get warnings because ItemsArrayRef calls ItemsOrderBy which since Name
is readable, will run sort() on lc($_->Name) which is of course undef
because of the eventual ACL checking.
The fully correct solution is to stop using Next to implement ACL
checks, but in the interest of fixing this warning exposed in RTIR I've
optimized for simplicity over cleverness. I suspect you can expose the
same issue with Queue Admins who have limit access.
diff --git a/share/html/Admin/Scrips/Elements/SelectTemplate b/share/html/Admin/Scrips/Elements/SelectTemplate
index 29f660a..2a8d9cd 100644
--- a/share/html/Admin/Scrips/Elements/SelectTemplate
+++ b/share/html/Admin/Scrips/Elements/SelectTemplate
@@ -74,7 +74,10 @@ if ( $Scrip && $Scrip->id && !$Scrip->IsAddedToAny ) {
$global->LimitToGlobal;
my %global;
- $global{ lc $_ } = $_ foreach map $_->Name, @{ $global->ItemsArrayRef };
+
+ while (my $t = $global->Next) {
+ $global{ lc $t->Name } = $t->Name
+ }
my @queues;
push @queues, @{ $Scrip->AddedTo->ItemsArrayRef } if $Scrip && $Scrip->id;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list