From d205aa12971e08f4127b993df4462c230b689eba Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 1 Jan 2026 16:49:24 +0100 Subject: [PATCH 1/5] Make LoTW login test code more bullet-proof --- application/controllers/Lotw.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 90686c458..911db8d98 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -849,20 +849,17 @@ class Lotw extends CI_Controller { curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); $content = curl_exec($ch); - if ($content) { - if(curl_errno($ch)) { - $ret['status']='failed'; - $ret['details']== sprintf(__("LoTW login failed for user %s: %s."), $data['user_lotw_name'], curl_strerror(curl_errno($ch))." (".curl_errno($ch).")"); - } else if (str_contains($content,"Username/password incorrect")) { + if(curl_errno($ch)) { + $ret['status']='failed'; + $ret['details'] = sprintf(__("LoTW login failed for user %s: %s."), $data['user_lotw_name'], curl_strerror(curl_errno($ch))." (".curl_errno($ch).")"); + } else { + if (str_contains($content,"Username/password incorrect")) { $ret['status']='failed_wrong_creds'; $ret['details']= sprintf(__("LoTW login failed for user %s: %s."), $data['user_lotw_name'], __("Username/password incorrect")); } else { $ret['status']='OK'; $ret['details']= __("LoTW login OK!"); } - } else { - $ret['status']='failed_na'; - $ret['details']= __("LoTW currently not available. Try again later."); } } else { if (($ret['status'] ?? '') == '') { From 82872bf09878af82877990ac5950dd345fcd7623 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 1 Jan 2026 19:39:02 +0100 Subject: [PATCH 2/5] Less low level info to the user and more to the log --- application/controllers/Lotw.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 911db8d98..4a5a017ab 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -851,7 +851,8 @@ class Lotw extends CI_Controller { $content = curl_exec($ch); if(curl_errno($ch)) { $ret['status']='failed'; - $ret['details'] = sprintf(__("LoTW login failed for user %s: %s."), $data['user_lotw_name'], curl_strerror(curl_errno($ch))." (".curl_errno($ch).")"); + $ret['details'] = __("Connection to LoTW failed."); + log_message('debug', "Connection to LoTW failed: "curl_strerror(curl_errno($ch))." (".curl_errno($ch).")"); } else { if (str_contains($content,"Username/password incorrect")) { $ret['status']='failed_wrong_creds'; From 0f802470027e4f476f261001a2cde21066f74e20 Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 2 Jan 2026 10:39:11 +0100 Subject: [PATCH 3/5] Fix syntax error and handle previously removed case where $content may be empty --- application/controllers/Lotw.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 4a5a017ab..e85c5af84 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -852,11 +852,15 @@ class Lotw extends CI_Controller { if(curl_errno($ch)) { $ret['status']='failed'; $ret['details'] = __("Connection to LoTW failed."); - log_message('debug', "Connection to LoTW failed: "curl_strerror(curl_errno($ch))." (".curl_errno($ch).")"); + log_message('debug', "LoTW error: Connection to LoTW failed: ".curl_strerror(curl_errno($ch))." (".curl_errno($ch).")"); } else { if (str_contains($content,"Username/password incorrect")) { $ret['status']='failed_wrong_creds'; $ret['details']= sprintf(__("LoTW login failed for user %s: %s."), $data['user_lotw_name'], __("Username/password incorrect")); + } elseif (!$content) { + $ret['status']='failed_na'; + $ret['details']= __("LoTW currently not available. Try again later."); + log_message('debug', "LoTW error: Connecting LoTW gave an empty result"); } else { $ret['status']='OK'; $ret['details']= __("LoTW login OK!"); From 206e11ba2af6aeb1d12d042781ea5223c28546b2 Mon Sep 17 00:00:00 2001 From: "Florian (DF2ET)" Date: Fri, 2 Jan 2026 13:12:47 +0100 Subject: [PATCH 4/5] Update application/controllers/Lotw.php Co-authored-by: Joerg (DJ7NT) --- application/controllers/Lotw.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index e85c5af84..c39dd07b1 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -847,7 +847,8 @@ class Lotw extends CI_Controller { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $lotw_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); +curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); +curl_setopt($ch, CURLOPT_TIMEOUT, 20); $content = curl_exec($ch); if(curl_errno($ch)) { $ret['status']='failed'; From 4ab79af72c11624399d01fde3c6b9d3373dbdfbb Mon Sep 17 00:00:00 2001 From: phl0 Date: Fri, 2 Jan 2026 13:13:39 +0100 Subject: [PATCH 5/5] Restore core formatting --- application/controllers/Lotw.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index c39dd07b1..748ca5d70 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -847,8 +847,8 @@ class Lotw extends CI_Controller { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $lotw_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); -curl_setopt($ch, CURLOPT_TIMEOUT, 20); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($ch, CURLOPT_TIMEOUT, 20); $content = curl_exec($ch); if(curl_errno($ch)) { $ret['status']='failed';