public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] helpers2: Change 'INNER JOIN' to 'LEFT JOIN'
@ 2025-02-28 22:24 Ammar Faizi
  2025-02-28 22:27 ` Alviro Iskandar Setiawan
  0 siblings, 1 reply; 2+ messages in thread
From: Ammar Faizi @ 2025-02-28 22:24 UTC (permalink / raw)
  To: GNU/Weeb Mailing List
  Cc: Muhammad Rizki, Alviro Iskandar Setiawan, M. Taufiq Hidayat Pohan,
	Ammar Faizi

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-28 22:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28 22:24 [PATCH] helpers2: Change 'INNER JOIN' to 'LEFT JOIN' Ammar Faizi
2025-02-28 22:27 ` Alviro Iskandar Setiawan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox