Skip to content

Commit a67cd03

Browse files
committed
Instead of weakening the controller in the around_action hook, ensure
that the $SIG{__WARN__} handler is reset in the after_dispatch hook so that the reference to the controller is released.
1 parent a46c5a2 commit a67cd03

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/Mojolicious/WeBWorK.pm

+2-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ Mojolicious::WeBWorK - Mojolicious app for WeBWorK 2.
2424

2525
use Env qw(WEBWORK_SERVER_ADMIN);
2626

27-
use Mojo::JSON qw(encode_json);
28-
use Scalar::Util qw(weaken);
27+
use Mojo::JSON qw(encode_json);
2928

3029
use WeBWorK;
3130
use WeBWorK::CourseEnvironment;
@@ -147,8 +146,6 @@ sub startup ($app) {
147146
around_action => async sub ($next, $c, $action, $last) {
148147
return $next->() unless $c->isa('WeBWorK::ContentGenerator');
149148

150-
weaken $c;
151-
152149
my $uri = $c->req->url->path->to_string;
153150
$c->stash->{warnings} //= '';
154151

@@ -174,7 +171,7 @@ sub startup ($app) {
174171

175172
$app->hook(
176173
after_dispatch => sub ($c) {
177-
$SIG{__WARN__} = $c->stash->{orig_sig_warn} if defined $c->stash->{orig_sig_warn};
174+
$SIG{__WARN__} = ref($c->stash->{orig_sig_warn}) eq 'CODE' ? $c->stash->{orig_sig_warn} : 'DEFAULT';
178175

179176
if ($c->isa('WeBWorK::ContentGenerator') && $c->ce) {
180177
$c->authen->store_session if $c->authen;

0 commit comments

Comments
 (0)