about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiQuery.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/LeiQuery.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/LeiQuery.pm')
-rw-r--r--lib/PublicInbox/LeiQuery.pm2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm
index 148e8524..84996e7e 100644
--- a/lib/PublicInbox/LeiQuery.pm
+++ b/lib/PublicInbox/LeiQuery.pm
@@ -50,11 +50,11 @@ sub lei_q {
         # --local is enabled by default unless --only is used
         # we'll allow "--only $LOCATION --local"
         my $sto = $self->_lei_store(1);
-        my $lse = $sto->search;
         if (($opt->{'import-remote'} //= 1) |
                         (($opt->{'import-before'} //= \1) ? 1 : 0)) {
                 $sto->write_prepare($self);
         }
+        my $lse = $sto->search;
         if ($opt->{'local'} //= scalar(@only) ? 0 : 1) {
                 $lxs->prepare_external($lse);
         }