[Rt-devel] RT 3.6 PATCH Added Once option to /Elements/Callback

Todd Chapman todd at chaka.net
Fri Jun 23 03:43:09 EDT 2006


Logic bug fixed. See attached.

On Fri, Jun 23, 2006 at 02:55:35AM -0400, Todd Chapman wrote:
> Added Once option to /Elements/Callback so that callbacks
> that don't need to run for each request don't run for
> each request. :)
> 
> -Todd

> ==== Patch <callback> level 1
> Source: [No source]
> Target: e417ac7c-1bcc-0310-8ffa-8f5827389a85:/rt/branches/3.6-RELEASE/html/Elements:5408
>         (svn://svn.bestpractical.com)
> Log:
> Added Once option to /Elements/Callback so that callbacks
> that don't need to run for each request don't run for
> each request. :)
> === Callback
> ==================================================================
> --- Callback	(revision 5408)
> +++ Callback	(patch callback level 1)
> @@ -45,6 +45,7 @@
>  %# END BPS TAGGED BLOCK }}}
>  <%once>
>  my %cache;
> +my %call_cache;
>  </%once>
>  <%init>
>  $Page = $m->callers(1)->path unless ($Page);
> @@ -80,11 +81,14 @@
>  
>  my @rv;
>  foreach my $comp (sort @$callbacks) {
> -    push @rv, $m->comp($comp, %ARGS);
> +    push @rv, $m->comp($comp, %ARGS)
> +        if $RT::DevelMode or ( !$call_cache{$comp} and $Once );
> +    $call_cache{$comp} = 1 if $Once;
>  }
>  return @rv;
>  </%init>
>  <%args>
>  $_CallbackName => 'Default'
>  $Page => undef
> +$Once => 0
>  </%args>
> 
> ==== BEGIN SVK PATCH BLOCK ====
> Version: svk 1.07 (linux)
> 
> eJxtUztv2zAQ9iygQ5duBViARprB0YOSJdmJ4KBxlzZpkKRdBZo8xUJl0qUoo0EYoBkzZW3/bSna
> LjJUA4Hj99Dpu9NHdTOdhaYoAoPDwFx/+zSZXFLNlkNb4bEBXmupcGIa2ECDiWnkLY6NoCuwqKbq
> FnRRhFacbcVzJ9ibxL3HgmopWpw7s1IrAByaaEbMLDL2tEVoQbkGUSoptbVPwySxYNm3xBrZQtlL
> e3rS06M9vaobwJn5QJtmQdl357RTk16d7NS8VsBsW3c9Y2vjULpeN3elhp+aQ6OpsyaRqSClQPNx
> EtCARgkJoQoCnoeQkZDRnOCI9FFdDAa/zZ/7V4/ng+e3g6fB0+vnN78ez1Z3aMhsR6WHdk9dIXx1
> M5mc9RmeSw5IKvQevcOOxihbwj1mcrV+QFRwhL8IBuhw6vT/4Zyg0Fn2tKn34CnQnRJopjZT79gf
> 1qLWhXc8tLNpCw+X+3Qu7MzQSYEOzqCiXaMPPHxJb91VJzhU3va9tgx6m618Fr+cgst7F9KCMUh4
> HKVpvqjSNCUsWYxZFkMcA0/GuRtGGGXmlHPgyHnLta6lQFoif97ACoRu/X17qJVIL6lGbHfReq7k
> UhxoJMB6WJ3qBKpsemADQQp+dNDuKTvIewkdocmhXZC9ZVFEBkfRdlNv3PJOJl9FvQHV0mY4NnZ7
> 1lQv7Z4r2Nii62qOSWZ8pf2FosJOofXJ0Xh0Nf88P72e+0u9av59ixUkcZBhYv+bOEwpS9kotDmN
> AhIGo6yqqD2SLEpJltMs+QtS8Byo
> ==== END SVK PATCH BLOCK ====

> _______________________________________________
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
> 
> Best Practical is hiring! Come hack Perl for us: http://bestpractical.com/about/jobs.html
-------------- next part --------------
==== Patch <callback> level 1
Source: [No source]
Target: e417ac7c-1bcc-0310-8ffa-8f5827389a85:/rt/branches/3.6-RELEASE/html/Elements:5408
        (svn://svn.bestpractical.com)
Log:
Added Once option to /Elements/Callback so that callbacks
that don't need to run for each request don't run for
each request. :)
=== Callback
==================================================================
--- Callback	(revision 5408)
+++ Callback	(patch callback level 1)
@@ -45,6 +45,7 @@
 %# END BPS TAGGED BLOCK }}}
 <%once>
 my %cache;
+my %call_cache;
 </%once>
 <%init>
 $Page = $m->callers(1)->path unless ($Page);
@@ -80,11 +81,14 @@
 
 my @rv;
 foreach my $comp (sort @$callbacks) {
-    push @rv, $m->comp($comp, %ARGS);
+    push @rv, $m->comp($comp, %ARGS)
+        if $RT::DevelMode or !$Once or ( !$call_cache{$comp} and $Once );
+    $call_cache{$comp} = 1 if $Once;
 }
 return @rv;
 </%init>
 <%args>
 $_CallbackName => 'Default'
 $Page => undef
+$Once => 0
 </%args>

==== BEGIN SVK PATCH BLOCK ====
Version: svk 1.07 (linux)

eJxtU0Fv0zAU7oVLJA5cuCEZydXYoUucxG3SblEnVi7AmLYBx8i1X9aI1C6OUzHhSey4066IX4uT
tGgHcrD8/L7vy/P3nt/p69mc2CwLLCaBvfryfjq9YIavhi7CYwuiNEpjaivYQoUjW6kbHFvJ1uCy
hukbMFlGHDnpyYuOsBeJW40lM0rWOO3EcqMBMLHhPLLz0LrVBcQl1QZkrpUyTn5CKHXJvC2JV6qG
vKW2cNrCwz28KCvAiX3LqmrJ+LdOaceOWjbdsUWpgbuybltEL9Nl2WZT3eYGfhgBlWGddBTaAiYM
WDqmAQtYSCMCRRCIlEASEc7SCIdxa9X5YPDb/nn2/P7r4PHV4GHw8OLx5a/78/UtGnJXUe6h3VcW
CF9eT6dnrYcflQCkNHqNP0ne7d64fUfgjK/gJ+ZqvblDTArUQw5nndJ/MCeIdOItbObdeRpMoyWa
6+3MO/aHpSxN5h0PXZfqzMP53qdz1z10kqGDMyhYU5kDD1+wm+6okQIKr/+vC4NWpqfP46f96Jzf
2cWKkEJIRBzFAeeUpjSJWRCkgtNkWcRp1xYSJvZUCBCov/bGlEoio5C/qGAN0tT+vjxUK2RWzCC+
O6i9LhRKHhgkwWk4nm4kKpx74AxBGr43UO8hu5T3NHWEpoduVPaSWRZaHIb9zF53YzydfpblFnTN
quHYujnaMLNyE69h64KmKQWOEutr4y81k64LtR8djUeXiw+L06uFvzLr6t9dHIHGQYIj94JiMmF8
wkdkyfkoiEgwSoqCuYUm4SRKUpbQv40lHrk=
==== END SVK PATCH BLOCK ====


More information about the Rt-devel mailing list