[Rt-commit] rt branch, global-destruction, created. rt-3.8.8-522-gb228592
Shawn Moore
sartak at bestpractical.com
Tue Aug 24 02:57:08 EDT 2010
The branch, global-destruction has been created
at b2285926f2000ab17034237e27fd6c3f626d6949 (commit)
- Log -----------------------------------------------------------------
commit b2285926f2000ab17034237e27fd6c3f626d6949
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Aug 24 02:54:08 2010 -0400
Whine about transaction batches running during global destruction
Trying to run SQL queries as the interpreter (nondeterministically)
rids itself of global variables (like, say, those in RT::Config) can
end badly. This happens a lot during tests which spews lots of stack
trace after the tests are done running. This only adds a new warning
(which can't use RT::Logger since that might have been GCed!) but
still tries to go ahead and run the transaction scrips since they
may still actually work.
This adds a new dependency on Devel::GlobalDestruction which does
include XS. I think it's worth it. If any of our upstream uses Moose
then we already have D:GD anyway.
diff --git a/lib/RT/Ticket_Overlay.pm b/lib/RT/Ticket_Overlay.pm
index d7f30cc..ed91256 100755
--- a/lib/RT/Ticket_Overlay.pm
+++ b/lib/RT/Ticket_Overlay.pm
@@ -82,6 +82,7 @@ use RT::Reminders;
use RT::URI::fsck_com_rt;
use RT::URI;
use MIME::Entity;
+use Devel::GlobalDestruction;
# {{{ LINKTYPEMAP
@@ -3356,6 +3357,10 @@ sub DESTROY {
# when an object's refcount is changed in its destructor.
return if $self->{_Destroyed}++;
+ if (in_global_destruction()) {
+ warn "Too late to safely run transaction-batch scrips! This is typically caused by using ticket objects at the top-level of a script which uses the RT API. Be sure to explicitly undef such ticket objects, or put them inside of a lexical scope.";
+ }
+
my $batch = $self->TransactionBatch;
return unless $batch && @$batch;
diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in
index a080ec8..4daefc1 100755
--- a/sbin/rt-test-dependencies.in
+++ b/sbin/rt-test-dependencies.in
@@ -205,6 +205,7 @@ CSS::Squish 0.06
File::Glob
Devel::StackTrace 1.19
Text::Password::Pronounceable
+Devel::GlobalDestruction
.
$deps{'MASON'} = [ text_to_hash( << '.') ];
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list