about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiExternal.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-03-23 11:48:08 +0000
committerEric Wong <e@80x24.org>2021-03-24 01:33:26 +0000
commit97caa1fe259cd6904573f36e0ac078a269b6ec5f (patch)
tree1babb08442553884028f9177ce471188fbfd5c76 /lib/PublicInbox/LeiExternal.pm
parentd39ff2cf4400b87bf6f51d7fe9f4b0e2a72bf679 (diff)
downloadpublic-inbox-97caa1fe259cd6904573f36e0ac078a269b6ec5f.tar.gz
Instead of creating a short-lived circular reference,
ensure they don't exist in the first place.

Note the following changes to hold an extra ref to $sto:

	-	$self->_lei_store(1)->write_prepare($self);
	+	my $sto = $self->_lei_store(1);
	+	$sto->write_prepare($self);

I'm not a perlguts expert, but I actually wanted to switch
to the one-line version for LeiImport, but xt/lei-auth-fail.t
was getting stuck for some reason.  It seems the extra ref
to the LeiStore ($sto) object is necessary.
Diffstat (limited to 'lib/PublicInbox/LeiExternal.pm')
-rw-r--r--lib/PublicInbox/LeiExternal.pm3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/PublicInbox/LeiExternal.pm b/lib/PublicInbox/LeiExternal.pm
index 9a555831..56d6ef39 100644
--- a/lib/PublicInbox/LeiExternal.pm
+++ b/lib/PublicInbox/LeiExternal.pm
@@ -144,7 +144,8 @@ sub add_external_finish {
 
 sub lei_add_external {
         my ($self, $location) = @_;
-        $self->_lei_store(1)->write_prepare($self);
+        my $sto = $self->_lei_store(1);
+        $sto->write_prepare($self);
         my $opt = $self->{opt};
         my $mirror = $opt->{mirror} // do {
                 my @fail;