public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: GNU/Weeb Mailing List <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>,
	"M. Taufiq Hidayat Pohan" <[email protected]>,
	Ammar Faizi <[email protected]>
Subject: [PATCH] helpers2: Change 'INNER JOIN' to 'LEFT JOIN'
Date: Sat,  1 Mar 2025 05:24:50 +0700	[thread overview]
Message-ID: <[email protected]> (raw)

Taufiq reported that he was unable to login via the new interface.

After some debugging, it turned out the login query was returning an
empty result-set because Taufiq did not have an entry in the
"user_info" table and the query was using an "INNER JOIN" to fetch the
user's information.

Let's just fill the missing entry with NULL values by using
"LEFT JOIN".

If the user changes his/her information, the entry will be updated
accordingly.

Reported-by: M. Taufiq Hidayat Pohan <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 storage/gwmail-web/mail.gnuweeb.org/src/helpers2.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/storage/gwmail-web/mail.gnuweeb.org/src/helpers2.php b/storage/gwmail-web/mail.gnuweeb.org/src/helpers2.php
index 66ba13538464..98ddac967d11 100644
--- a/storage/gwmail-web/mail.gnuweeb.org/src/helpers2.php
+++ b/storage/gwmail-web/mail.gnuweeb.org/src/helpers2.php
@@ -374,7 +374,7 @@ function gwm_get_user_full(PDO $pdo, int $user_id): ?array
 		$fields .= "`user_info`.`{$f}`, ";
 	$fields = substr($fields, 0, -2);
 
-	$st = $pdo->prepare("SELECT {$fields} FROM `users` INNER JOIN `user_info` ON `users`.`id` = `user_info`.`user_id` WHERE `users`.`id` = ? LIMIT 1;");
+	$st = $pdo->prepare("SELECT {$fields} FROM `users` LEFT JOIN `user_info` ON `users`.`id` = `user_info`.`user_id` WHERE `users`.`id` = ? LIMIT 1;");
 	$st->execute([$user_id]);
 	$u = $st->fetch(PDO::FETCH_ASSOC);
 	if (!$u)
-- 
Ammar Faizi


             reply	other threads:[~2025-02-28 22:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28 22:24 Ammar Faizi [this message]
2025-02-28 22:27 ` [PATCH] helpers2: Change 'INNER JOIN' to 'LEFT JOIN' Alviro Iskandar Setiawan

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

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

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox