Merge pull request #3037 from AndreasK79/callbook_null_error

[Callbook] Fix null error for source
This commit is contained in:
Andreas Kristiansen
2026-03-04 19:16:56 +01:00
committed by GitHub

View File

@@ -12,8 +12,8 @@ class Callbook {
// Duration of session keys // Duration of session keys
// QRZ.com // QRZ.com
// They write that session keys have no guaranteed lifetime. We should cache it to reuse it, but also be prepared // They write that session keys have no guaranteed lifetime. We should cache it to reuse it, but also be prepared
// to get a new one if the session key is invalid. // to get a new one if the session key is invalid.
// Older documents showed that the duration was between 12-24 hours. So we set it to 4 hours to be on the safe side. // Older documents showed that the duration was between 12-24 hours. So we set it to 4 hours to be on the safe side.
// Ref.: https://www.qrz.com/docs/xml/current_spec.html // Ref.: https://www.qrz.com/docs/xml/current_spec.html
@@ -28,13 +28,13 @@ class Callbook {
private $qrzcq_session_cachekey = null; private $qrzcq_session_cachekey = null;
// HamQTH.com // HamQTH.com
// Session Key is valid for 1 hour according to their documentation. We set it just a few moments below that to 55 Minutes. // Session Key is valid for 1 hour according to their documentation. We set it just a few moments below that to 55 Minutes.
// Ref.: https://www.hamqth.com/developers.php // Ref.: https://www.hamqth.com/developers.php
const HAMQTH_SESSION_DURATION = 3300; // 55 minutes const HAMQTH_SESSION_DURATION = 3300; // 55 minutes
private $hamqth_session_cachekey = null; private $hamqth_session_cachekey = null;
// QRZRU.com // QRZRU.com
// Session Key is valid for 1 hour according to their documentation. We set it just a few moments below that to 55 Minutes. // Session Key is valid for 1 hour according to their documentation. We set it just a few moments below that to 55 Minutes.
// Ref.: https://www.qrz.ru/help/api/xml // Ref.: https://www.qrz.ru/help/api/xml
const QRZRU_SESSION_DURATION = 3300; // 55 minutes const QRZRU_SESSION_DURATION = 3300; // 55 minutes
private $qrzru_session_cachekey = null; private $qrzru_session_cachekey = null;
@@ -47,7 +47,7 @@ class Callbook {
$this->ci = & get_instance(); $this->ci = & get_instance();
$this->ci->load->is_loaded('cache') ?: $this->ci->load->driver('cache', [ $this->ci->load->is_loaded('cache') ?: $this->ci->load->driver('cache', [
'adapter' => $this->ci->config->item('cache_adapter') ?? 'file', 'adapter' => $this->ci->config->item('cache_adapter') ?? 'file',
'backup' => $this->ci->config->item('cache_backup') ?? 'file', 'backup' => $this->ci->config->item('cache_backup') ?? 'file',
'key_prefix' => $this->ci->config->item('cache_key_prefix') ?? '' 'key_prefix' => $this->ci->config->item('cache_key_prefix') ?? ''
]); ]);
@@ -78,7 +78,7 @@ class Callbook {
break; break;
} else { } else {
$callbook_errors['error_'.$source] = $callbook['error']; $callbook_errors['error_'.$source] = $callbook['error'];
$callbook_errors['error_'.$source.'_name'] = $callbook['source']; $callbook_errors['error_'.$source.'_name'] = $callbook['source'] ?? '';
} }
} }
} else { } else {
@@ -138,11 +138,11 @@ class Callbook {
$callbook['source'] = $this->ci->qrz->sourcename(); $callbook['source'] = $this->ci->qrz->sourcename();
$username = trim($this->ci->config->item('qrz_username') ?? ''); $username = trim($this->ci->config->item('qrz_username') ?? '');
$password = trim($this->ci->config->item('qrz_password') ?? ''); $password = trim($this->ci->config->item('qrz_password') ?? '');
if ($username == '' || $password == '') { if ($username == '' || $password == '') {
$callbook['error'] = $this->logbook_not_configured; $callbook['error'] = $this->logbook_not_configured;
} else { } else {
if (!$this->ci->cache->get($this->qrz_session_cachekey)) { if (!$this->ci->cache->get($this->qrz_session_cachekey)) {
$qrz_session_key = $this->ci->qrz->session($username, $password); $qrz_session_key = $this->ci->qrz->session($username, $password);
if (!$this->_validate_sessionkey($qrz_session_key)) { if (!$this->_validate_sessionkey($qrz_session_key)) {
@@ -320,15 +320,15 @@ class Callbook {
if ($key == false || $key == '' || !is_string($key)) { if ($key == false || $key == '' || !is_string($key)) {
return false; return false;
} }
// All session keys should be at least 10 characters. Regarding to their documentation all keys have aprox. the same format // All session keys should be at least 10 characters. Regarding to their documentation all keys have aprox. the same format
// "2331uf894c4bd29f3923f3bacf02c532d7bd9" // "2331uf894c4bd29f3923f3bacf02c532d7bd9"
// Since it can differ and we want to don't overcomplicate things we simply check if the key is at least 10 characters long. // Since it can differ and we want to don't overcomplicate things we simply check if the key is at least 10 characters long.
// If not, we consider it as invalid. // If not, we consider it as invalid.
if (strlen($key) < 10) { if (strlen($key) < 10) {
return false; return false;
} }
return true; return true;
} }