Commit e1443b42 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(captive portal) fix report PHP Warning: SQLite3::query(): Unable to prepare...

(captive portal) fix report PHP Warning:  SQLite3::query(): Unable to prepare statement: 5, database is locked in /usr/local/opnsense/scripts/OPNsense/CaptivePortal/process_accounting_messages.php on line 53

(cherry picked from commit 94e28e10)
parent 3867f651
...@@ -35,6 +35,7 @@ use OPNsense\Auth\AuthenticationFactory; ...@@ -35,6 +35,7 @@ use OPNsense\Auth\AuthenticationFactory;
// open database // open database
$database_filename = '/var/captiveportal/captiveportal.sqlite'; $database_filename = '/var/captiveportal/captiveportal.sqlite';
$db = new SQLite3($database_filename); $db = new SQLite3($database_filename);
$db->busyTimeout(2000);
// query all sessions with client restrictions // query all sessions with client restrictions
$result = $db->query(' $result = $db->query('
...@@ -53,7 +54,8 @@ $result = $db->query(' ...@@ -53,7 +54,8 @@ $result = $db->query('
'); ');
// process all sessions // process all sessions
while($row = $result->fetchArray(SQLITE3_ASSOC) ){ if ($result !== false) {
while($row = $result->fetchArray(SQLITE3_ASSOC) ){
$authFactory = new OPNsense\Auth\AuthenticationFactory(); $authFactory = new OPNsense\Auth\AuthenticationFactory();
$authenticator = $authFactory->get($row['authenticated_via']); $authenticator = $authFactory->get($row['authenticated_via']);
if ($authenticator != null) { if ($authenticator != null) {
...@@ -91,5 +93,7 @@ while($row = $result->fetchArray(SQLITE3_ASSOC) ){ ...@@ -91,5 +93,7 @@ while($row = $result->fetchArray(SQLITE3_ASSOC) ){
} }
} }
} }
}
} }
$db->close(); $db->close();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment