user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Cc: meta@public-inbox.org
Subject: [PATCH] www: avoid potential auto-vivification on ibx->{url}
Date: Fri, 27 Aug 2021 22:03:02 +0000	[thread overview]
Message-ID: <20210827220302.GA15524@dcvr> (raw)
In-Reply-To: <CAMwyc-Tw=v5yT1U1U66GSwwTK8OJXv8_YDu-=oXbZO3tHSnYWw@mail.gmail.com>

Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
> On Fri, 27 Aug 2021 at 09:03, Konstantin Ryabitsev
> <konstantin@linuxfoundation.org> wrote:
> > > Just making /all/ show up at the top like a normal inbox (and
> > > letting the admin decide on description) seems sufficient.  If
> > > users can get to /all/ then they can search /all/ as normal.
> >
> > Sure, this works for me, too, thanks!
> > https://x-lore.kernel.org/
> 
> Hmm.. I just noticed that the "all" link has vanished. The source is showing:
> 
> <pre>* 2021-08-27 13:24 - <a
> href=""></a>
>   All of lore.kernel.org
> 
> Restarting public-inbox-httpd fixes it, but I wonder if it will happen again.

If it happens once, it'll happen again.  I'm not sure which code
path triggers it, but maybe this will fix it.  There's also a secondary
patch below which may be more complete, but may also be
unneeded.

--------------8<-------------
Subject: [PATCH] www: avoid potential auto-vivification on ibx->{url}

This may fix problems with the "all" link disappearing.

Link: https://public-inbox.org/meta/CAMwyc-Tw=v5yT1U1U66GSwwTK8OJXv8_YDu-=oXbZO3tHSnYWw@mail.gmail.com/
---
 lib/PublicInbox/Inbox.pm      | 3 ++-
 lib/PublicInbox/WwwListing.pm | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index df140cac..b0bb9dcc 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -250,7 +250,8 @@ sub base_url {
 	}
 	# called from a non-PSGI environment (e.g. NNTP/POP3):
 	$self->{-base_url} ||= do {
-		my $url = $self->{url}->[0] or return undef;
+		my $url = $self->{url} // return undef;
+		$url = $url->[0] // return undef;
 		# expand protocol-relative URLs to HTTPS if we're
 		# not inside a web server
 		$url = "https:$url" if $url =~ m!\A//!;
diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm
index 1bb5fbd0..fe5ee087 100644
--- a/lib/PublicInbox/WwwListing.pm
+++ b/lib/PublicInbox/WwwListing.pm
@@ -41,7 +41,7 @@ sub list_match_i { # ConfigIter callback
 		return if $section !~ m!\Apublicinbox\.([^/]+)\z!;
 		my $ibx = $cfg->lookup_name($1) or return;
 		if (!$ibx->{-hide}->{$ctx->hide_key} &&
-					grep(/$re/, @{$ibx->{url}})) {
+					grep(/$re/, @{$ibx->{url} // []})) {
 			$ctx->ibx_entry($ibx);
 		}
 	} else { # undef == "EOF"

--------8<------
Secondary patch in case extindex $ibx->{url} got vivified somewhere:

diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm
index fe5ee087..ef9048b5 100644
--- a/lib/PublicInbox/WwwListing.pm
+++ b/lib/PublicInbox/WwwListing.pm
@@ -17,7 +17,7 @@ sub ibx_entry {
 	my $desc = ascii_html($ce->{description} //= $ibx->description);
 	my $ts = fmt_ts($ce->{-modified} //= $ibx->modified);
 	my ($url, $href);
-	if (defined($ibx->{url})) {
+	if (scalar(@{$ibx->{url} // []})) {
 		$url = $href = ascii_html(prurl($ctx->{env}, $ibx->{url}));
 	} else {
 		$href = ascii_html(uri_escape_utf8($ibx->{name})) . '/';

  reply	other threads:[~2021-08-27 22:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 17:01 Add a way to search all from wwwlisting Konstantin Ryabitsev
2021-08-27 12:08 ` [PATCH 0/2] wwwlisting shows /all/ Eric Wong
2021-08-27 12:08   ` [PATCH 1/2] www_listing: show ->ALL at top of HTML listing Eric Wong
2021-08-27 12:08   ` [PATCH 2/2] www_listing: fix odd "locate inbox" cases Eric Wong
2021-08-27 13:03   ` [PATCH 0/2] wwwlisting shows /all/ Konstantin Ryabitsev
2021-08-27 14:33     ` Konstantin Ryabitsev
2021-08-27 22:03       ` Eric Wong [this message]
2021-08-28 18:00         ` [PATCH] www: avoid potential auto-vivification on ibx->{url} Konstantin Ryabitsev
2021-08-27 21:15     ` [PATCH 0/2] wwwlisting shows /all/ Eric Wong
2021-09-26  1:30   ` [PATCH] www_listing: support /all/ search as a 302 redirect Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210827220302.GA15524@dcvr \
    --to=e@80x24.org \
    --cc=konstantin@linuxfoundation.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).