Skip to content

Commit 0399c10

Browse files
authored
Merge pull request #2703 from drgrice1/memory-leaks
Fix memory leaks.
2 parents 8edb453 + ba749a4 commit 0399c10

File tree

8 files changed

+12
-42
lines changed

8 files changed

+12
-42
lines changed

lib/Mojolicious/WeBWorK.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ sub startup ($app) {
171171

172172
$app->hook(
173173
after_dispatch => sub ($c) {
174-
$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';
175175

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

lib/WeBWorK/Authen/LTIAdvanced.pm

-23
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,6 @@ use WeBWorK::Authen::LTIAdvanced::Nonce;
4040

4141
$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A;
4242

43-
=head1 CONSTRUCTOR
44-
45-
=over
46-
47-
=item new($c)
48-
49-
Instantiates a new WeBWorK::Authen object for the given WeBWorK::Controller ($c).
50-
51-
=cut
52-
53-
sub new {
54-
my ($invocant, $c) = @_;
55-
my $class = ref($invocant) || $invocant;
56-
my $self = { c => $c, };
57-
#initialize
58-
bless $self, $class;
59-
return $self;
60-
}
61-
62-
=back
63-
64-
=cut
65-
6643
## this is only overridden for debug logging
6744
#sub verify {
6845
# debug("BEGIN LTIAdvanced VERIFY");

lib/WeBWorK/Authen/LTIAdvantage.pm

-16
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,6 @@ use WeBWorK::Utils::DateTime qw(formatDateTime);
3333
use WeBWorK::Utils::Instructor qw(assignSetToUser);
3434
use WeBWorK::Authen::LTIAdvantage::SubmitGrade;
3535

36-
=head1 CONSTRUCTOR
37-
38-
=over
39-
40-
=item new($c)
41-
42-
Instantiates a new WeBWorK::Authen object for the given WeBWorK::Controller ($c).
43-
44-
=back
45-
46-
=cut
47-
48-
sub new ($invocant, $c) {
49-
return bless { c => $c }, ref($invocant) || $invocant;
50-
}
51-
5236
sub request_has_data_for_this_verification_module ($self) {
5337
debug('LTIAdvantage has been called for data verification');
5438
my $c = $self->{c};

lib/WeBWorK/Authz.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ sub new {
8484
my ($invocant, $c) = @_;
8585
my $class = ref($invocant) || $invocant;
8686
my $self = { c => $c, };
87-
#weaken $self->{c};
87+
weaken $self->{c};
8888

8989
$c->{permission_retrieval_error} = 0;
9090
bless $self, $class;

lib/WeBWorK/ContentGenerator/Home.pm

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ WeBWorK::ContentGenerator::Home - display a list of courses.
2323
=cut
2424

2525
use WeBWorK::Utils::Files qw(readFile);
26-
use WeBWorK::Localize;
2726

2827
sub info ($c) {
2928
my $result;

lib/WeBWorK/DB/Schema.pm

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ dependent. C<$db> is provided so that schemas can query other schemas.
8181
8282
=cut
8383

84+
use Scalar::Util qw(weaken);
85+
8486
sub new {
8587
my ($proto, $db, $driver, $table, $record, $params, $engine, $character_set) = @_;
8688
my $class = ref($proto) || $proto;
@@ -103,6 +105,8 @@ sub new {
103105
character_set => $character_set,
104106
};
105107
bless $self, $class;
108+
weaken $self->{db};
109+
106110
return $self;
107111
}
108112

lib/WeBWorK/DB/Schema/NewSQL/Merge.pm

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ use warnings;
2828
use Carp qw(croak);
2929
use Iterator;
3030
use Iterator::Util;
31+
use Scalar::Util qw(weaken);
32+
3133
use WeBWorK::DB::Utils::SQLAbstractIdentTrans;
3234
use WeBWorK::Debug;
3335

@@ -121,6 +123,7 @@ sub merge_init {
121123

122124
sub sql_init {
123125
my $self = shift;
126+
weaken $self;
124127

125128
# Transformation function for table names. This allows us to pass the WeBWorK table names to
126129
# SQL::Abstract, and have it translate them to the SQL table names from tableOverride.

lib/WeBWorK/DB/Schema/NewSQL/Std.pm

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ use Iterator;
2929
use Iterator::Util;
3030
use File::Temp;
3131
use String::ShellQuote;
32+
use Scalar::Util qw(weaken);
33+
3234
use WeBWorK::DB::Utils::SQLAbstractIdentTrans;
3335
use WeBWorK::Debug;
3436

@@ -64,6 +66,7 @@ sub new {
6466

6567
sub sql_init {
6668
my $self = shift;
69+
weaken $self;
6770

6871
# Transformation function for table names. This allows us to pass the WeBWorK table names to
6972
# SQL::Abstract, and have it translate them to the SQL table names from tableOverride.

0 commit comments

Comments
 (0)