[Rt-commit] rt branch 5.0/fix-clear-mason-cache created. rt-5.0.2-26-g7f94cac59f

BPS Git Server git at git.bestpractical.com
Thu Sep 30 00:12:22 UTC 2021


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/fix-clear-mason-cache has been created
        at  7f94cac59fbb457806075de35eca302d420d9a76 (commit)

- Log -----------------------------------------------------------------
commit 7f94cac59fbb457806075de35eca302d420d9a76
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Sep 30 07:48:20 2021 +0800

    Clear callback cache too when mason cache is cleared
    
    Without this, the callbacks could be outdated. Even worse, callbacks
    that are marked as "CallbackOnce" wouldn't be called again.
    
    Fixes: I#37248

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index bfe7f9e81a..c1fb39fab2 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -282,6 +282,7 @@ sub HandleRequest {
         my $mason_cache_created = MasonCacheCreatedDate();
         if ( $HTML::Mason::Commands::m->interp->{rt_mason_cache_created} ne $mason_cache_created ) {
             $HTML::Mason::Commands::m->interp->flush_code_cache;
+            $HTML::Mason::Commands::m->clear_callback_cache;
             $HTML::Mason::Commands::m->interp->{rt_mason_cache_created} = $mason_cache_created;
         }
     }

commit ecf00e44cb35b7905205577f3dec56c3c7761ac4
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Sep 30 05:48:38 2021 +0800

    Store mason cache created time in mason interpreter
    
    $m is re-initialized on every request, so we can't use it to store info
    across requests. This caused flush_code_cache to be called on every
    request previously.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index ce0931f35a..bfe7f9e81a 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -266,6 +266,10 @@ sub WebRemoteUserAutocreateInfo {
     return {%user_info};
 }
 
+sub MasonCacheCreatedDate {
+    require File::Spec;
+    return ( stat File::Spec->catdir( $RT::MasonDataDir, 'obj' ) )[9] // '';
+}
 
 sub HandleRequest {
     my $ARGS = shift;
@@ -275,11 +279,10 @@ sub HandleRequest {
         Module::Refresh->refresh;
     }
     else {
-        require File::Spec;
-        my $mason_cache_created = ( stat File::Spec->catdir( $RT::MasonDataDir, 'obj' ) )[ 9 ] // '';
-        if ( ( $HTML::Mason::Commands::m->{rt_mason_cache_created} // '' ) ne $mason_cache_created ) {
+        my $mason_cache_created = MasonCacheCreatedDate();
+        if ( $HTML::Mason::Commands::m->interp->{rt_mason_cache_created} ne $mason_cache_created ) {
             $HTML::Mason::Commands::m->interp->flush_code_cache;
-            $HTML::Mason::Commands::m->{rt_mason_cache_created} = $mason_cache_created;
+            $HTML::Mason::Commands::m->interp->{rt_mason_cache_created} = $mason_cache_created;
         }
     }
 
diff --git a/lib/RT/Interface/Web/Handler.pm b/lib/RT/Interface/Web/Handler.pm
index dd6fc31801..649be05139 100644
--- a/lib/RT/Interface/Web/Handler.pm
+++ b/lib/RT/Interface/Web/Handler.pm
@@ -120,6 +120,11 @@ sub NewHandler {
     $handler->interp->set_escape( h => \&RT::Interface::Web::EscapeHTML );
     $handler->interp->set_escape( u => \&RT::Interface::Web::EscapeURI  );
     $handler->interp->set_escape( j => \&RT::Interface::Web::EscapeJS   );
+
+    if ( !RT->Config->Get('DevelMode') ) {
+        $handler->interp->{rt_mason_cache_created} = RT::Interface::Web::MasonCacheCreatedDate;
+    }
+
     return($handler);
 }
 
diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
index 37a3a694b2..de5ae21c40 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -165,9 +165,9 @@ for my $type (qw/Tickets Queues Transactions Groups PrivilegedUsers Unprivileged
 
     <&|/Widgets/TitleBox, title => loc("Mason template search order") &>
 
-% if ( $m->{rt_mason_cache_created} ) {
+% if ( $m->interp->{rt_mason_cache_created} ) {
 % my $mason_obj_date = RT::Date->new( $session{CurrentUser} );
-% $mason_obj_date->Set( Format => 'Unix', Value => $m->{rt_mason_cache_created} );
+% $mason_obj_date->Set( Format => 'Unix', Value => $m->interp->{rt_mason_cache_created} );
 
 <div class="mason-cache">
   <div class="mason-cache-info py-1 d-inline-block">

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list